mirror of
https://github.com/YunoHost-Apps/hotspot_ynh.git
synced 2024-09-03 19:25:53 +02:00
Use systemctl helper to avoid deadlocks with ynh 2.7 and check path avaibility with no deprecated method
This commit is contained in:
parent
b125c82a8a
commit
5ee291480d
4 changed files with 47 additions and 7 deletions
39
scripts/helpers
Normal file
39
scripts/helpers
Normal file
|
@ -0,0 +1,39 @@
|
|||
#!/bin/bash
|
||||
|
||||
source /usr/share/yunohost/helpers
|
||||
|
||||
#
|
||||
# Helper to start/stop/.. a systemd service from a yunohost context,
|
||||
# *and* the systemd service itself needs to be able to run yunohost
|
||||
# commands.
|
||||
#
|
||||
# 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
|
||||
sudo systemctl "$ACTION" "$SERVICE" &
|
||||
local SYSCTLACTION=$!
|
||||
|
||||
# Save and release the lock...
|
||||
cp $LOCKFILE $LOCKFILE.bkp.$$
|
||||
rm $LOCKFILE
|
||||
|
||||
# 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
|
||||
}
|
|
@ -29,6 +29,7 @@ firmware_nonfree=${5}
|
|||
|
||||
if ! $upgrade; then
|
||||
|
||||
source ./helpers
|
||||
source ./prerequisites
|
||||
|
||||
# Check arguments
|
||||
|
@ -52,10 +53,7 @@ if ! $upgrade; then
|
|||
fi
|
||||
|
||||
# Check domain/path availability
|
||||
sudo yunohost app checkurl ${domain}${url_path} -a hotspot
|
||||
if [ ! $? -eq 0 ]; then
|
||||
exit 1
|
||||
fi
|
||||
ynh_webpath_register hotspot $domain $url_path || exit 1
|
||||
|
||||
# Install packages
|
||||
packages='php5-fpm sipcalc hostapd iptables iw dnsmasq'
|
||||
|
@ -211,7 +209,7 @@ if [ "${wifi_device}" == none ]; then
|
|||
fi
|
||||
|
||||
if ! $upgrade; then
|
||||
sudo systemctl start ynh-hotspot
|
||||
ynh_systemctl start ynh-hotspot
|
||||
fi
|
||||
|
||||
sudo yunohost app ssowatconf
|
||||
|
|
|
@ -17,11 +17,13 @@
|
|||
# You should have received a copy of the GNU Affero General Public License
|
||||
# along with this program. If not, see <http://www.gnu.org/licenses/>.
|
||||
|
||||
source ./helpers
|
||||
|
||||
# Retrieve arguments
|
||||
domain=$(sudo yunohost app setting hotspot domain)
|
||||
|
||||
# The End
|
||||
sudo systemctl stop ynh-hotspot
|
||||
ynh_systemctl stop ynh-hotspot
|
||||
sudo systemctl disable ynh-hotspot
|
||||
sudo yunohost service remove ynh-hotspot
|
||||
sudo rm -f /etc/systemd/system/ynh-hotspot.service /usr/local/bin/ynh-hotspot
|
||||
|
|
|
@ -12,6 +12,7 @@ path=$(ynh_setting hotspot path)
|
|||
wifi_ssid=$(ynh_setting hotspot wifi_ssid)
|
||||
wifi_passphrase=$(ynh_setting hotspot wifi_passphrase)
|
||||
|
||||
source ./helpers
|
||||
source ./prerequisites
|
||||
|
||||
if dpkg -l firmware-linux-nonfree &> /dev/null; then
|
||||
|
@ -40,6 +41,6 @@ if [ -z "$(ynh_setting hotspot ip6_firewall)" ]; then
|
|||
sudo yunohost app setting hotspot ip6_firewall -v "${ip6_firewall}"
|
||||
fi
|
||||
|
||||
sudo systemctl start ynh-hotspot
|
||||
ynh_systemctl start ynh-hotspot
|
||||
|
||||
exit 0
|
||||
|
|
Loading…
Add table
Reference in a new issue