1
0
Fork 0
mirror of https://github.com/YunoHost-Apps/movim_ynh.git synced 2024-09-03 19:46:19 +02:00

Remove legacy init.d support

This commit is contained in:
Jean-Baptiste Holcroft 2018-08-10 16:52:22 +02:00
parent 24c4ccb8a6
commit 7178bba198
4 changed files with 18 additions and 135 deletions

View file

@ -1,98 +0,0 @@
#!/bin/sh
### BEGIN INIT INFO
# Provides: movim
# Required-Start: $remote_fs $syslog mysql
# Required-Stop: $remote_fs $syslog
# Default-Start: 2 3 4 5
# Default-Stop: 0 1 6
# Short-Description: Start daemon at boot time
# Description: Enable service provided by daemon.
### END INIT INFO
dir="YHDIR"
cmd="php daemon.php start --url=https://YHURL --port=YHPORT"
user="movim"
name=`basename $0`
pid_file="/var/run/$name.pid"
stdout_log="/var/log/$name.log"
stderr_log="/var/log/$name.err"
get_pid() {
cat "$pid_file"
}
is_running() {
[ -f "$pid_file" ] && ps `get_pid` > /dev/null 2>&1
}
case "$1" in
start)
if is_running; then
echo "Already started"
else
echo "Starting $name"
cd "$dir"
if [ -z "$user" ]; then
sudo $cmd >> "$stdout_log" 2>> "$stderr_log" &
else
sudo -u "$user" $cmd >> "$stdout_log" 2>> "$stderr_log" &
fi
echo $! > "$pid_file"
if ! is_running; then
echo "Unable to start, see $stdout_log and $stderr_log"
exit 1
fi
fi
;;
stop)
if is_running; then
echo -n "Stopping $name.."
kill `get_pid`
for i in {1..10}
do
if ! is_running; then
break
fi
echo -n "."
sleep 1
done
echo
if is_running; then
echo "Not stopped; may still be shutting down or shutdown may have failed"
exit 1
else
echo "Stopped"
if [ -f "$pid_file" ]; then
rm "$pid_file"
fi
fi
else
echo "Not running"
fi
;;
restart)
$0 stop
if is_running; then
echo "Unable to stop, will not attempt to start"
exit 1
fi
$0 start
;;
status)
if is_running; then
echo "Running"
else
echo "Stopped"
exit 1
fi
;;
*)
echo "Usage: $0 {start|stop|restart|status}"
exit 1
;;
esac
exit 0

View file

@ -167,21 +167,14 @@ exec_cmd php mud.php config --loglevel=1 \
#=================================================
# Copy init script or systemd service
ynh_replace_string "YHURL" "${domain}${path_url}" ../conf/movim.{service,init}
ynh_replace_string "YHDIR" "${final_path}" ../conf/movim.{service,init}
ynh_replace_string "YHPORT" "${port}" ../conf/movim.{service,init}
ynh_replace_string "YHURL" "${domain}${path_url}" ../conf/movim.service
ynh_replace_string "YHDIR" "${final_path}" ../conf/movim.service
ynh_replace_string "YHPORT" "${port}" ../conf/movim.service
if [ -d /run/systemd/system ]; then
cp ../conf/movim.service /etc/systemd/system/
systemctl daemon-reload
systemctl enable movim.service
systemctl start movim.service
else
cp ../conf/movim.init /etc/init.d/movim
chmod 755 /etc/init.d/movim
update-rc.d movim defaults
/etc/init.d/movim start
fi
cp ../conf/movim.service /etc/systemd/system/
systemctl daemon-reload
systemctl enable movim.service
systemctl start movim.service
#=================================================
# PHP-FPM CONFIGURATION

View file

@ -42,14 +42,10 @@ service php5-fpm restart
#=================================================
service movim stop
if [ -d /run/systemd/system ]; then
systemctl --quiet disable movim.service
ynh_secure_remove /lib/systemd/system/movim.service
systemctl --quiet daemon-reload
else
update-rc.d -f movim remove
ynh_secure_remove /etc/init.d/movim
fi
systemctl --quiet disable movim.service
ynh_secure_remove /lib/systemd/system/movim.service
systemctl --quiet daemon-reload
#=================================================
# REMOVE DEPENDENCIES

View file

@ -170,21 +170,13 @@ fi
# SETUP SYSTEMD
#=================================================
# Update init scripts
ynh_replace_string "YHURL" "${domain}${path_url}" ../conf/movim.{service,init}
ynh_replace_string "YHDIR" "${final_path}" ../conf/movim.{service,init}
ynh_replace_string "YHPORT" "${port}" ../conf/movim.{service,init}
if [ -d /run/systemd/system ]; then
ynh_secure_remove /lib/systemd/system/movim.service
cp ../conf/movim.service /etc/systemd/system/
systemctl daemon-reload
else
/etc/init.d/movim stop
cp ../conf/movim.init /etc/init.d/movim
chmod 755 /etc/init.d/movim
update-rc.d movim defaults
/etc/init.d/movim start
fi
ynh_replace_string "YHURL" "${domain}${path_url}" ../conf/movim.service
ynh_replace_string "YHDIR" "${final_path}" ../conf/movim.service
ynh_replace_string "YHPORT" "${port}" ../conf/movim.service
ynh_secure_remove /lib/systemd/system/movim.service
cp ../conf/movim.service /etc/systemd/system/
systemctl daemon-reload
#=================================================
# PHP-FPM CONFIGURATION