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
|
if ! $upgrade; then
|
||||||
|
|
||||||
|
source ./helpers
|
||||||
source ./prerequisites
|
source ./prerequisites
|
||||||
|
|
||||||
# Check arguments
|
# Check arguments
|
||||||
|
@ -52,10 +53,7 @@ if ! $upgrade; then
|
||||||
fi
|
fi
|
||||||
|
|
||||||
# Check domain/path availability
|
# Check domain/path availability
|
||||||
sudo yunohost app checkurl ${domain}${url_path} -a hotspot
|
ynh_webpath_register hotspot $domain $url_path || exit 1
|
||||||
if [ ! $? -eq 0 ]; then
|
|
||||||
exit 1
|
|
||||||
fi
|
|
||||||
|
|
||||||
# Install packages
|
# Install packages
|
||||||
packages='php5-fpm sipcalc hostapd iptables iw dnsmasq'
|
packages='php5-fpm sipcalc hostapd iptables iw dnsmasq'
|
||||||
|
@ -211,7 +209,7 @@ if [ "${wifi_device}" == none ]; then
|
||||||
fi
|
fi
|
||||||
|
|
||||||
if ! $upgrade; then
|
if ! $upgrade; then
|
||||||
sudo systemctl start ynh-hotspot
|
ynh_systemctl start ynh-hotspot
|
||||||
fi
|
fi
|
||||||
|
|
||||||
sudo yunohost app ssowatconf
|
sudo yunohost app ssowatconf
|
||||||
|
|
|
@ -17,11 +17,13 @@
|
||||||
# You should have received a copy of the GNU Affero General Public License
|
# 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/>.
|
# along with this program. If not, see <http://www.gnu.org/licenses/>.
|
||||||
|
|
||||||
|
source ./helpers
|
||||||
|
|
||||||
# Retrieve arguments
|
# Retrieve arguments
|
||||||
domain=$(sudo yunohost app setting hotspot domain)
|
domain=$(sudo yunohost app setting hotspot domain)
|
||||||
|
|
||||||
# The End
|
# The End
|
||||||
sudo systemctl stop ynh-hotspot
|
ynh_systemctl stop ynh-hotspot
|
||||||
sudo systemctl disable ynh-hotspot
|
sudo systemctl disable ynh-hotspot
|
||||||
sudo yunohost service remove ynh-hotspot
|
sudo yunohost service remove ynh-hotspot
|
||||||
sudo rm -f /etc/systemd/system/ynh-hotspot.service /usr/local/bin/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_ssid=$(ynh_setting hotspot wifi_ssid)
|
||||||
wifi_passphrase=$(ynh_setting hotspot wifi_passphrase)
|
wifi_passphrase=$(ynh_setting hotspot wifi_passphrase)
|
||||||
|
|
||||||
|
source ./helpers
|
||||||
source ./prerequisites
|
source ./prerequisites
|
||||||
|
|
||||||
if dpkg -l firmware-linux-nonfree &> /dev/null; then
|
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}"
|
sudo yunohost app setting hotspot ip6_firewall -v "${ip6_firewall}"
|
||||||
fi
|
fi
|
||||||
|
|
||||||
sudo systemctl start ynh-hotspot
|
ynh_systemctl start ynh-hotspot
|
||||||
|
|
||||||
exit 0
|
exit 0
|
||||||
|
|
Loading…
Add table
Reference in a new issue