fix #50
This commit is contained in:
@@ -2,7 +2,7 @@
|
|||||||
"name": "VPN Client",
|
"name": "VPN Client",
|
||||||
"id": "vpnclient",
|
"id": "vpnclient",
|
||||||
"packaging_format": 1,
|
"packaging_format": 1,
|
||||||
"version": "1.3.1",
|
"version": "1.3.2",
|
||||||
"description": {
|
"description": {
|
||||||
"en": "Tunnel the internet traffic through a VPN",
|
"en": "Tunnel the internet traffic through a VPN",
|
||||||
"fr": "Fais passer le traffic internet à travers un VPN"
|
"fr": "Fais passer le traffic internet à travers un VPN"
|
||||||
@@ -14,7 +14,7 @@
|
|||||||
},
|
},
|
||||||
"multi_instance": false,
|
"multi_instance": false,
|
||||||
"requirements": {
|
"requirements": {
|
||||||
"yunohost": ">= 2.7.0"
|
"yunohost": ">= 3.2.0"
|
||||||
},
|
},
|
||||||
"services": [
|
"services": [
|
||||||
"nginx",
|
"nginx",
|
||||||
|
@@ -57,41 +57,6 @@ ynh_abort_if_up_to_date () {
|
|||||||
fi
|
fi
|
||||||
}
|
}
|
||||||
|
|
||||||
# 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
|
|
||||||
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
|
|
||||||
}
|
|
||||||
|
|
||||||
# Read the value of a key in a ynh manifest file
|
# Read the value of a key in a ynh manifest file
|
||||||
#
|
#
|
||||||
# usage: ynh_read_manifest manifest key
|
# usage: ynh_read_manifest manifest key
|
||||||
@@ -244,5 +209,6 @@ function vpnclient_deploy_files_and_services()
|
|||||||
install -o root -g root -m 0644 ../conf/ynh-vpnclient-checker.service /etc/systemd/system/
|
install -o root -g root -m 0644 ../conf/ynh-vpnclient-checker.service /etc/systemd/system/
|
||||||
install -o root -g root -m 0644 ../conf/ynh-vpnclient-checker.timer /etc/systemd/system/
|
install -o root -g root -m 0644 ../conf/ynh-vpnclient-checker.timer /etc/systemd/system/
|
||||||
|
|
||||||
|
# Reload systemd configuration
|
||||||
systemctl daemon-reload
|
systemctl daemon-reload
|
||||||
}
|
}
|
||||||
|
@@ -1,39 +0,0 @@
|
|||||||
#!/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
|
|
||||||
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
|
|
||||||
}
|
|
@@ -1,19 +1,19 @@
|
|||||||
#!/bin/bash
|
#!/bin/bash
|
||||||
|
|
||||||
# VPN Client app for YunoHost
|
# VPN Client app for YunoHost
|
||||||
# Copyright (C) 2015 Julien Vaubourg <julien@vaubourg.com>
|
# Copyright (C) 2015 Julien Vaubourg <julien@vaubourg.com>
|
||||||
# Contribute at https://github.com/labriqueinternet/vpnclient_ynh
|
# Contribute at https://github.com/labriqueinternet/vpnclient_ynh
|
||||||
#
|
#
|
||||||
# This program is free software: you can redistribute it and/or modify
|
# This program is free software: you can redistribute it and/or modify
|
||||||
# it under the terms of the GNU Affero General Public License as published by
|
# it under the terms of the GNU Affero General Public License as published by
|
||||||
# the Free Software Foundation, either version 3 of the License, or
|
# the Free Software Foundation, either version 3 of the License, or
|
||||||
# (at your option) any later version.
|
# (at your option) any later version.
|
||||||
#
|
#
|
||||||
# This program is distributed in the hope that it will be useful,
|
# This program is distributed in the hope that it will be useful,
|
||||||
# but WITHOUT ANY WARRANTY; without even the implied warranty of
|
# but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||||
# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
||||||
# GNU Affero General Public License for more details.
|
# GNU Affero General Public License for more details.
|
||||||
#
|
#
|
||||||
# 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/>.
|
||||||
|
|
||||||
@@ -43,6 +43,9 @@ path_url=$(ynh_normalize_url_path "$2")
|
|||||||
app=$YNH_APP_INSTANCE_NAME
|
app=$YNH_APP_INSTANCE_NAME
|
||||||
final_path="/var/www/$app"
|
final_path="/var/www/$app"
|
||||||
|
|
||||||
|
service_name="ynh-vpnclient"
|
||||||
|
service_checker_name=$service_name"-checker"
|
||||||
|
|
||||||
#=================================================
|
#=================================================
|
||||||
# CHECK IF THE APP CAN BE INSTALLED WITH THESE ARGS
|
# CHECK IF THE APP CAN BE INSTALLED WITH THESE ARGS
|
||||||
#=================================================
|
#=================================================
|
||||||
@@ -77,7 +80,7 @@ vpnclient_deploy_files_and_services "${domain}" "${app}"
|
|||||||
|
|
||||||
# Set default inits
|
# Set default inits
|
||||||
# The boot order of these services are important, so they are disabled by default
|
# The boot order of these services are important, so they are disabled by default
|
||||||
# and the ynh-vpnclient service handles them.
|
# and the vpnclient service handles them.
|
||||||
systemctl disable openvpn
|
systemctl disable openvpn
|
||||||
systemctl stop openvpn
|
systemctl stop openvpn
|
||||||
|
|
||||||
@@ -86,12 +89,17 @@ systemctl restart php5-fpm
|
|||||||
|
|
||||||
systemctl reload nginx
|
systemctl reload nginx
|
||||||
|
|
||||||
systemctl enable ynh-vpnclient
|
# main service
|
||||||
yunohost service add ynh-vpnclient
|
|
||||||
|
|
||||||
ynh_systemctl start ynh-vpnclient-checker.service
|
yunohost service add $service_name --description "tunnels the internet traffic through a VPN" --need_lock
|
||||||
systemctl enable ynh-vpnclient-checker.service
|
yunohost service enable $service_name
|
||||||
ynh_systemctl start ynh-vpnclient-checker.timer
|
|
||||||
systemctl enable ynh-vpnclient-checker.timer
|
# checker service
|
||||||
|
|
||||||
|
yunohost service add $service_checker_name --description "makes sure that the VPN service is running" --need_lock
|
||||||
|
yunohost service start $service_checker_name
|
||||||
|
yunohost service enable $service_checker_name
|
||||||
|
systemctl start $service_checker_name.timer
|
||||||
|
systemctl enable $service_checker_name.timer
|
||||||
|
|
||||||
yunohost app ssowatconf
|
yunohost app ssowatconf
|
||||||
|
@@ -33,16 +33,24 @@ source /usr/share/yunohost/helpers
|
|||||||
app=$YNH_APP_INSTANCE_NAME
|
app=$YNH_APP_INSTANCE_NAME
|
||||||
domain=$(ynh_app_setting_get $app domain)
|
domain=$(ynh_app_setting_get $app domain)
|
||||||
|
|
||||||
|
service_name="ynh-vpnclient"
|
||||||
|
service_checker_name=$service_name"-checker"
|
||||||
|
|
||||||
#=================================================
|
#=================================================
|
||||||
# The End
|
|
||||||
ynh_systemctl stop ynh-vpnclient-checker.service
|
# Stop and remove yunohost services
|
||||||
systemctl disable ynh-vpnclient-checker.service
|
|
||||||
ynh_systemctl stop ynh-vpnclient-checker.timer && sleep 1
|
yunohost service stop $service_checker_name
|
||||||
systemctl disable ynh-vpnclient-checker.timer
|
yunohost service disable $service_checker_name
|
||||||
ynh_systemctl stop ynh-vpnclient
|
yunohost service remove $service_checker_name
|
||||||
systemctl disable ynh-vpnclient
|
systemctl stop $service_checker_name.timer && sleep 1
|
||||||
yunohost service remove ynh-vpnclient
|
systemctl disable $service_checker_name.timer
|
||||||
for FILE in $(ls /etc/systemd/system/ynh-vpnclient* /usr/local/bin/ynh-vpnclient* /tmp/.ynh-vpnclient-*)
|
|
||||||
|
yunohost service stop $service_name
|
||||||
|
yunohost service disable $service_name
|
||||||
|
yunohost service remove $service_name
|
||||||
|
|
||||||
|
for FILE in $(ls /etc/systemd/system/$service_name* /usr/local/bin/ynh-vpnclient* /tmp/.ynh-vpnclient-*)
|
||||||
do
|
do
|
||||||
ynh_secure_remove "$FILE"
|
ynh_secure_remove "$FILE"
|
||||||
done
|
done
|
||||||
@@ -65,6 +73,9 @@ ynh_remove_app_dependencies
|
|||||||
# Remove sources
|
# Remove sources
|
||||||
ynh_secure_remove "/var/www/${app}"
|
ynh_secure_remove "/var/www/${app}"
|
||||||
|
|
||||||
|
# Reload systemd configuration
|
||||||
|
systemctl daemon-reload
|
||||||
|
|
||||||
# Restart services
|
# Restart services
|
||||||
# (this must happen before deleting the user, otherwise the user is
|
# (this must happen before deleting the user, otherwise the user is
|
||||||
# being used by one of the php pool process)
|
# being used by one of the php pool process)
|
||||||
|
@@ -21,6 +21,9 @@ is_public=$(ynh_app_setting_get $app is_public)
|
|||||||
final_path=$(ynh_app_setting_get $app final_path)
|
final_path=$(ynh_app_setting_get $app final_path)
|
||||||
server_name=$(ynh_app_setting_get $app server_name)
|
server_name=$(ynh_app_setting_get $app server_name)
|
||||||
|
|
||||||
|
service_name="ynh-vpnclient"
|
||||||
|
service_checker_name=$service_name"-checker"
|
||||||
|
|
||||||
#=================================================
|
#=================================================
|
||||||
# SPECIAL UPGRADE FOR VERSIONS < 1.2.0
|
# SPECIAL UPGRADE FOR VERSIONS < 1.2.0
|
||||||
#=================================================
|
#=================================================
|
||||||
@@ -83,10 +86,44 @@ ynh_secure_remove ${tmpdir}
|
|||||||
# RELOAD RELEVANT SERVICES
|
# RELOAD RELEVANT SERVICES
|
||||||
#=================================================
|
#=================================================
|
||||||
|
|
||||||
ynh_systemctl reload php5-fpm
|
systemctl reload php5-fpm
|
||||||
ynh_systemctl reload nginx
|
systemctl reload nginx
|
||||||
|
|
||||||
if systemctl is-active ynh-vpnclient >/dev/null;
|
### Make sure that the yunohost services have a description and need-lock enabled
|
||||||
|
|
||||||
|
# main service
|
||||||
|
|
||||||
|
yunohost service remove $service_name
|
||||||
|
yunohost service add $service_name --description "tunnels the internet traffic through a VPN" --need_lock
|
||||||
|
|
||||||
|
# checker service
|
||||||
|
|
||||||
|
yunohost service remove $service_checker_name
|
||||||
|
yunohost service add $service_checker_name --description "makes sure that the VPN service is running" --need_lock
|
||||||
|
|
||||||
|
# Reload systemd configuration
|
||||||
|
|
||||||
|
systemctl daemon-reload
|
||||||
|
|
||||||
|
### Restart services
|
||||||
|
|
||||||
|
# restart main service if needed
|
||||||
|
|
||||||
|
if systemctl is-active $service_name >/dev/null;
|
||||||
then
|
then
|
||||||
ynh_systemctl restart ynh-vpnclient
|
yunohost service restart $service_name
|
||||||
|
fi
|
||||||
|
|
||||||
|
# restart checker service if needed
|
||||||
|
|
||||||
|
if systemctl is-active $service_checker_name >/dev/null;
|
||||||
|
then
|
||||||
|
yunohost service restart $service_checker_name
|
||||||
|
fi
|
||||||
|
|
||||||
|
# restart checker service timer
|
||||||
|
|
||||||
|
if systemctl is-active $service_name.timer >/dev/null;
|
||||||
|
then
|
||||||
|
yunohost service restart $service_checker_name.timer
|
||||||
fi
|
fi
|
||||||
|
Reference in New Issue
Block a user