-
Notifications
You must be signed in to change notification settings - Fork 26
/
init-all.sh
executable file
·98 lines (81 loc) · 2.08 KB
/
init-all.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
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
#!/bin/sh
set -e
cd `dirname $0`
if [ "$1" = "" ]; then
echo "Usage: $0 [ start | stop | restart | reboot ]"
echo ""
echo "reboot is meant for cronjobs @reboot and unconditionally removes pid files before proceeding"
exit 2
fi
if [ ! -f "lib/AmuseWikiFarm.pm" ]; then
echo "In the wrong directory!";
exit 2
fi
. ./script/add-texlive-to-path.sh
mkdir -p opt/cache
mkdir -p log
export TMPDIR=$(pwd)/var/tmp
mkdir -p $TMPDIR
prepare_app () {
# this looks like a bit of an overkill, but better have the files
# locally, without adding more work to the sysadmin
./script/install_js.sh
export PERL_USE_UNSAFE_INC=1
carton install --deployment || cpanm -L local --installdeps .
export PERL_USE_UNSAFE_INC=""
if carton exec perl -MImager -e 'foreach my $i (qw/jpeg png/) { die "Missing support for $i\n" unless $Imager::formats{$i} }'; then
echo "Imager loaded correctly";
else
echo "Imager was built without png and/or jpeg support. Are the development libraries installed?"
exit 2;
fi
carton exec ./script/amusewiki-upgrade-db
carton exec ./script/amusewiki-generate-nginx-conf
carton exec ./script/amusewiki-upgrade-lexicon repo/*
carton exec ./script/amusewiki-populate-webfonts
}
# echo `pwd`
start_web () {
prepare_app
rm -fv current_version_is_*.txt
amw_version=`carton exec perl -I lib -MAmuseWikiFarm -e 'print $AmuseWikiFarm::VERSION'`
touch current_version_is_$amw_version.txt
rm -rfv var/cache/*
carton exec ./script/init-fcgi.pl start
}
start_all () {
start_web
carton exec ./script/jobber.pl start
sleep 5
}
stop_all () {
carton exec ./script/jobber.pl stop
carton exec ./script/init-fcgi.pl stop
}
case $1 in
reboot)
rm -fv ./var/*.pid
start_all
;;
start-app)
start_web
;;
stop-app)
carton exec ./script/init-fcgi.pl stop
;;
start)
start_all
;;
stop)
stop_all
;;
restart)
stop_all
start_all
;;
*)
echo "uh?"
echo "Usage: $0 [ start | stop | restart ]"
exit 1
;;
esac