mirror of https://github.com/sipwise/www_csc.git
parent
dfcfb2b0a6
commit
26920a00e7
@ -0,0 +1,103 @@
|
||||
#!/bin/sh
|
||||
### BEGIN INIT INFO
|
||||
# Provides: ngcp-www-csc
|
||||
# Required-Start: $syslog $network $local_fs $remote_fs $time
|
||||
# Required-Stop: $syslog $network $local_fs $remote_fs
|
||||
# Default-Start: 2 3 4 5
|
||||
# Default-Stop: 0 1 6
|
||||
# Short-Description: Start the ngcp-www-csc webapp
|
||||
# Description: Start the ngcp-www-csc webapp
|
||||
### END INIT INFO
|
||||
|
||||
. /lib/lsb/init-functions
|
||||
|
||||
HOMEDIR=/usr/share/ngcp-www-csc
|
||||
DAEMON=$HOMEDIR/script/csc_fastcgi.pl
|
||||
PIDFILE=/var/run/ngcp-www-csc.pid
|
||||
USER=www-data
|
||||
GROUP=www-data
|
||||
NAME="csc_fastcgi"
|
||||
DESC="NGCP-CSC Webapp"
|
||||
USOCKET=/var/run/ngcp-www-csc.sock
|
||||
LOGERR=/var/log/ngcp/ngcp-www-csc.log
|
||||
NPROC=1
|
||||
|
||||
OPTIONS="--listen $USOCKET --daemon --pidfile $PIDFILE --nproc $NPROC"
|
||||
|
||||
check_running() {
|
||||
[ -s $PIDFILE ] && kill -0 $(cat $PIDFILE) >/dev/null 2>&1
|
||||
}
|
||||
|
||||
_start() {
|
||||
rm -f $PIDFILE 2>/dev/null
|
||||
start-stop-daemon --start --quiet --pidfile $PIDFILE \
|
||||
--exec $DAEMON --chdir $HOMEDIR \
|
||||
--user $USER --group $GROUP \
|
||||
-- $OPTIONS || log_failure_msg "error"
|
||||
}
|
||||
|
||||
start() {
|
||||
log_daemon_msg "Starting $DESC: $NAME"
|
||||
if check_running; then
|
||||
log_progress_msg "already running"
|
||||
log_end_msg 0
|
||||
exit 0
|
||||
fi
|
||||
_start
|
||||
log_end_msg $?
|
||||
return $?
|
||||
}
|
||||
|
||||
_stop() {
|
||||
if [ -e $PIDFILE ]; then
|
||||
if ! check_running ; then
|
||||
log_daemon_msg " not running"
|
||||
return 0
|
||||
fi
|
||||
kill `cat $PIDFILE`;
|
||||
for i in 1 2 3 4 5 6 7; do
|
||||
echo -n "."
|
||||
sleep 1;
|
||||
if check_running ; then
|
||||
return 0
|
||||
fi
|
||||
done
|
||||
if check_running ; then
|
||||
return 1;
|
||||
fi
|
||||
fi
|
||||
}
|
||||
|
||||
stop() {
|
||||
log_daemon_msg "Stopping $DESC: $NAME"
|
||||
_stop
|
||||
log_end_msg $?
|
||||
return $?
|
||||
}
|
||||
|
||||
case "$1" in
|
||||
start)
|
||||
start
|
||||
;;
|
||||
stop)
|
||||
stop
|
||||
;;
|
||||
restart|force-reload)
|
||||
log_daemon_msg "Restarting web application" $NAME
|
||||
_stop
|
||||
_start
|
||||
log_end_msg $?
|
||||
return $?
|
||||
;;
|
||||
status)
|
||||
log_daemon_msg "Status of $DESC: "
|
||||
status_of_proc -p$PIDFILE $DAEMON $NAME
|
||||
;;
|
||||
*)
|
||||
N=/etc/init.d/$NAME
|
||||
echo "Usage: $N {start|stop|restart|force-reload|status}" >&2
|
||||
exit 1
|
||||
;;
|
||||
esac
|
||||
|
||||
exit 0
|
@ -0,0 +1,61 @@
|
||||
#!/bin/sh
|
||||
# preinst script for #PACKAGE#
|
||||
#
|
||||
# see: dh_installdeb(1)
|
||||
|
||||
set -e
|
||||
|
||||
# summary of how this script can be called:
|
||||
# * <new-preinst> `install'
|
||||
# * <new-preinst> `install' <old-version>
|
||||
# * <new-preinst> `upgrade' <old-version>
|
||||
# * <old-preinst> `abort-upgrade' <new-version>
|
||||
# for details, see http://www.debian.org/doc/debian-policy/ or
|
||||
# the debian-policy package
|
||||
|
||||
|
||||
case "$1" in
|
||||
install|upgrade)
|
||||
if [ -e /etc/apache2/sites-enabled/000-default ]; then
|
||||
echo "Deactivating default site on apache"
|
||||
rm /etc/apache2/sites-enabled/000-default
|
||||
FLAG=1
|
||||
fi
|
||||
if [ -e /etc/apache2/sites-enabled/ngcp-www-csc ]; then
|
||||
echo "Deactivating ngcp-www-csc on apache"
|
||||
rm /etc/apache2/sites-enabled/ngcp-www-csc
|
||||
FLAG=1
|
||||
fi
|
||||
if dpkg-maintscript-helper supports rm_conffile 2>/dev/null; then
|
||||
dpkg-maintscript-helper rm_conffile \
|
||||
/etc/ngcp-config/templates/etc/apache2/sites-available/ngcp-www-csc.tt2 \
|
||||
-- "$@"
|
||||
fi
|
||||
;;
|
||||
|
||||
abort-upgrade)
|
||||
;;
|
||||
|
||||
*)
|
||||
echo "preinst called with unknown argument \`$1'" >&2
|
||||
exit 1
|
||||
;;
|
||||
esac
|
||||
|
||||
if [ -n "$FLAG" ]; then
|
||||
# restart apache
|
||||
if [ -x /etc/init.d/apache2 ]; then
|
||||
if [ -x "`which invoke-rc.d 2>/dev/null`" ]; then
|
||||
invoke-rc.d apache2 restart|| true
|
||||
else
|
||||
/etc/init.d/apache2 restart || true
|
||||
fi
|
||||
fi
|
||||
fi
|
||||
|
||||
# dh_installdeb will replace this with shell code automatically
|
||||
# generated by other debhelper scripts.
|
||||
|
||||
#DEBHELPER#
|
||||
|
||||
exit 0
|
@ -1,2 +1,6 @@
|
||||
[% TAGS [- -] %]
|
||||
/etc/init.d/apache2 restart || true
|
||||
[- IF PRO -]
|
||||
monit restart ngcp-www-csc
|
||||
[- ELSE -]
|
||||
/etc/init.d/ngcp-www-csc restart
|
||||
[- END -]
|
||||
|
@ -0,0 +1,39 @@
|
||||
[% TAGS [- -] -%]
|
||||
|
||||
[% IF www_csc.apache.port != 80 && www_admin.apache.port != 80 && ossbss.apache.port != 80 %]
|
||||
server {
|
||||
listen [::]:80;
|
||||
|
||||
server_name [% www_csc.apache.servername %];
|
||||
|
||||
return 301 https://$server_name$request_uri;
|
||||
}
|
||||
[% END %]
|
||||
|
||||
server {
|
||||
listen [::]:[% www_csc.apache.port %];
|
||||
[% IF www_csc.apache.ssl_enable == "yes" %]
|
||||
ssl on;
|
||||
ssl_certificate [% www_csc.apache.sslcertfile %];
|
||||
ssl_certificate_key [% www_csc.apache.sslcertkeyfile %];
|
||||
[% END %]
|
||||
server_name [% www_csc.apache.servername %];
|
||||
|
||||
location /favicon.ico {
|
||||
alias /usr/share/ngcp-www-csc/lib/csc/root/favicon.ico;
|
||||
}
|
||||
|
||||
location /(css|grafik|js) {
|
||||
root /usr/share/ngcp-www-csc/lib/csc/root;
|
||||
}
|
||||
|
||||
location / {
|
||||
include /etc/nginx/fastcgi_params;
|
||||
# Catalyst requires setting PATH_INFO (instead of SCRIPT_NAME) to $fastcgi_script_name
|
||||
fastcgi_param SCRIPT_NAME '';
|
||||
fastcgi_param PATH_INFO $fastcgi_script_name;
|
||||
fastcgi_param HTTPS on;
|
||||
# TODO: configs for fastcgi process
|
||||
fastcgi_pass unix:/var/run/ngcp-www-csc.sock;
|
||||
}
|
||||
}
|
@ -0,0 +1,6 @@
|
||||
[% TAGS [- -] %]
|
||||
[- IF PRO -]
|
||||
monit restart ngcp-www-csc
|
||||
[- ELSE -]
|
||||
/etc/init.d/ngcp-www-csc restart
|
||||
[- END -]
|
Loading…
Reference in new issue