forked from joar/mediagoblin-init-scripts
-
Notifications
You must be signed in to change notification settings - Fork 0
/
installer.sh
76 lines (66 loc) · 2.67 KB
/
installer.sh
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
#!/bin/sh
## DESCRIPTION
# This script will download the mediagoblin init scripts and install them for
# you.
# The script needs to know where your mediagoblin installation is. By default
# this will be sed to what `pwd` will output when you run this script.
#
# This script uses the Dependency Based Boot in Debian >= 6.0
# <http://wiki.debian.org/LSBInitScripts/DependencyBasedBoot>
#
## USAGE
#
# # This will download the latest version of the installer.sh script directly
# # From gist.github.com (-L allowing a 302 redirect to raw.github.com), then
# # pipe the script directly through `sh` (presumably /bin/sh).
# $ curl -L http://wandborg.se/mediagoblin-init-scripts/installer.sh | sh
#
# By default the MG_ROOT will be set to `pwd` and the user will be set to the
# user you run the script as.
#
## LICENSE: CC0 <http://creativecommons.org/publicdomain/zero/1.0/>
# To the extent possible under law, Joar Wandborg <http://wandborg.se> has
# waived all copyright and related or neighboring rights to
# mediagoblin-paster. This work is published from Sweden.
if ! [ -z "$1" ]; then
MEDIAGOBLIN_ROOT=$1
else
MEDIAGOBLIN_ROOT=$(pwd)
fi
if ! [ -z "$2" ]; then
MEDIAGOBLIN_USER=$2
else
MEDIAGOBLIN_USER=$(whoami)
fi
PASTER_INIT_URL="http://wandborg.se/mediagoblin-init-scripts/mediagoblin-paster.sh"
PASTER_INIT_DESTINATION=/etc/init.d/mediagoblin-paster
CELERYD_INIT_URL="http://wandborg.se/mediagoblin-init-scripts/mediagoblin-celeryd.sh"
CELERYD_INIT_DESTINATION=/etc/init.d/mediagoblin-celeryd
verify_and_install () {
INIT_PATH=$1
# Check if installation of the init script was successful
if [ -f "$INIT_PATH" ]; then
# Set executable permissions on the init script
sudo chmod +x $INIT_PATH
echo "Installing the $INIT_PATH script"
# More on `insserv` at <http://wiki.debian.org/LSBInitScripts/DependencyBasedBoot>
sudo insserv $INIT_PATH
return 0
fi
return 1
}
# Download the mediagoblin-paster script from raw.github.com, replace the
# MG_ROOT variable value with the $MEDIAGOBLIN_ROOT value and the MG_USER
# variable value with the $MEDIAGOBLIN_USER value and pipe it to
# the init script destination ($PASTER_INIT_DESTINATION).
sudo su -c "curl $PASTER_INIT_URL \
| sed s,^MG_ROOT=.*\n,MG_ROOT=$MEDIAGOBLIN_ROOT, \
| sed s,^MG_USER=.*\n,MG_USER=$MEDIAGOBLIN_USER, \
> $PASTER_INIT_DESTINATION"
verify_and_install $PASTER_INIT_DESTINATION
# Download and fix the mediagoblin-celeryd script
sudo su -c "curl $CELERYD_INIT_URL \
| sed s,^MG_ROOT=.*\n,MG_ROOT=$MEDIAGOBLIN_ROOT, \
| sed s,^MG_USER=.*\n,MG_USER=$MEDIAGOBLIN_USER, \
> $CELERYD_INIT_DESTINATION"
verify_and_install $CELERYD_INIT_DESTINATION