2017-08-30 14:30:14 +02:00
|
|
|
#!/bin/bash
|
|
|
|
|
2018-05-04 00:33:01 +02:00
|
|
|
#
|
|
|
|
# Common variables
|
|
|
|
#
|
|
|
|
|
|
|
|
pkg_dependencies="php5-fpm sipcalc hostapd iptables iw dnsmasq"
|
|
|
|
nonfree_packages="firmware-linux-free firmware-linux-nonfree firmware-atheros firmware-realtek firmware-ralink firmware-libertas atmel-firmware zd1211-firmware"
|
|
|
|
free_packages="firmware-linux-free"
|
2017-08-30 14:30:14 +02:00
|
|
|
|
|
|
|
#
|
|
|
|
# Helper to start/stop/.. a systemd service from a yunohost context,
|
|
|
|
# *and* the systemd service itself needs to be able to run yunohost
|
|
|
|
# commands.
|
2018-05-04 00:33:01 +02:00
|
|
|
#
|
2017-08-30 14:30:14 +02:00
|
|
|
# Hence the need to release the lock during the operation
|
|
|
|
#
|
|
|
|
# usage : ynh_systemctl yolo restart
|
|
|
|
#
|
|
|
|
function ynh_systemctl()
|
|
|
|
{
|
|
|
|
local ACTION="$1"
|
|
|
|
local SERVICE="$2"
|
|
|
|
local LOCKFILE="/var/run/moulinette_yunohost.lock"
|
|
|
|
|
|
|
|
# Launch the action
|
2019-02-09 12:42:19 +01:00
|
|
|
systemctl "$ACTION" "$SERVICE" &
|
2017-08-30 14:30:14 +02:00
|
|
|
local SYSCTLACTION=$!
|
|
|
|
|
|
|
|
# Save and release the lock...
|
|
|
|
cp $LOCKFILE $LOCKFILE.bkp.$$
|
|
|
|
rm $LOCKFILE
|
2018-05-04 00:33:01 +02:00
|
|
|
|
2017-08-30 14:30:14 +02:00
|
|
|
# Wait for the end of the action
|
|
|
|
wait $SYSCTLACTION
|
|
|
|
|
|
|
|
# Make sure the lock is released...
|
|
|
|
while [ -f $LOCKFILE ]
|
|
|
|
do
|
|
|
|
sleep 0.1
|
|
|
|
done
|
|
|
|
|
|
|
|
# Restore the old lock
|
|
|
|
mv $LOCKFILE.bkp.$$ $LOCKFILE
|
|
|
|
}
|