fix #50
This commit is contained in:
@@ -2,7 +2,7 @@
|
||||
"name": "VPN Client",
|
||||
"id": "vpnclient",
|
||||
"packaging_format": 1,
|
||||
"version": "1.3.1",
|
||||
"version": "1.3.2",
|
||||
"description": {
|
||||
"en": "Tunnel the internet traffic through a VPN",
|
||||
"fr": "Fais passer le traffic internet à travers un VPN"
|
||||
@@ -14,7 +14,7 @@
|
||||
},
|
||||
"multi_instance": false,
|
||||
"requirements": {
|
||||
"yunohost": ">= 2.7.0"
|
||||
"yunohost": ">= 3.2.0"
|
||||
},
|
||||
"services": [
|
||||
"nginx",
|
||||
|
@@ -57,41 +57,6 @@ ynh_abort_if_up_to_date () {
|
||||
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
|
||||
#
|
||||
# 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.timer /etc/systemd/system/
|
||||
|
||||
# Reload systemd configuration
|
||||
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
|
||||
}
|
@@ -43,6 +43,9 @@ path_url=$(ynh_normalize_url_path "$2")
|
||||
app=$YNH_APP_INSTANCE_NAME
|
||||
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
|
||||
#=================================================
|
||||
@@ -77,7 +80,7 @@ vpnclient_deploy_files_and_services "${domain}" "${app}"
|
||||
|
||||
# Set default inits
|
||||
# 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 stop openvpn
|
||||
|
||||
@@ -86,12 +89,17 @@ systemctl restart php5-fpm
|
||||
|
||||
systemctl reload nginx
|
||||
|
||||
systemctl enable ynh-vpnclient
|
||||
yunohost service add ynh-vpnclient
|
||||
# main service
|
||||
|
||||
ynh_systemctl start ynh-vpnclient-checker.service
|
||||
systemctl enable ynh-vpnclient-checker.service
|
||||
ynh_systemctl start ynh-vpnclient-checker.timer
|
||||
systemctl enable ynh-vpnclient-checker.timer
|
||||
yunohost service add $service_name --description "tunnels the internet traffic through a VPN" --need_lock
|
||||
yunohost service enable $service_name
|
||||
|
||||
# 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
|
||||
|
@@ -33,16 +33,24 @@ source /usr/share/yunohost/helpers
|
||||
app=$YNH_APP_INSTANCE_NAME
|
||||
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
|
||||
systemctl disable ynh-vpnclient-checker.service
|
||||
ynh_systemctl stop ynh-vpnclient-checker.timer && sleep 1
|
||||
systemctl disable ynh-vpnclient-checker.timer
|
||||
ynh_systemctl stop ynh-vpnclient
|
||||
systemctl disable ynh-vpnclient
|
||||
yunohost service remove ynh-vpnclient
|
||||
for FILE in $(ls /etc/systemd/system/ynh-vpnclient* /usr/local/bin/ynh-vpnclient* /tmp/.ynh-vpnclient-*)
|
||||
|
||||
# Stop and remove yunohost services
|
||||
|
||||
yunohost service stop $service_checker_name
|
||||
yunohost service disable $service_checker_name
|
||||
yunohost service remove $service_checker_name
|
||||
systemctl stop $service_checker_name.timer && sleep 1
|
||||
systemctl disable $service_checker_name.timer
|
||||
|
||||
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
|
||||
ynh_secure_remove "$FILE"
|
||||
done
|
||||
@@ -65,6 +73,9 @@ ynh_remove_app_dependencies
|
||||
# Remove sources
|
||||
ynh_secure_remove "/var/www/${app}"
|
||||
|
||||
# Reload systemd configuration
|
||||
systemctl daemon-reload
|
||||
|
||||
# Restart services
|
||||
# (this must happen before deleting the user, otherwise the user is
|
||||
# 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)
|
||||
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
|
||||
#=================================================
|
||||
@@ -83,10 +86,44 @@ ynh_secure_remove ${tmpdir}
|
||||
# RELOAD RELEVANT SERVICES
|
||||
#=================================================
|
||||
|
||||
ynh_systemctl reload php5-fpm
|
||||
ynh_systemctl reload nginx
|
||||
systemctl reload php5-fpm
|
||||
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
|
||||
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
|
||||
|
Reference in New Issue
Block a user