Use systemctl helper to avoid deadlocks with ynh 2.7 and check path avaibility with no deprecated method
This commit is contained in:
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
|
||||||
|
}
|
@@ -25,14 +25,12 @@ domain=${1}
|
|||||||
url_path=${2}
|
url_path=${2}
|
||||||
|
|
||||||
if ! $upgrade; then
|
if ! $upgrade; then
|
||||||
|
source ./helpers
|
||||||
source ./prerequisites
|
source ./prerequisites
|
||||||
fi
|
fi
|
||||||
|
|
||||||
# Check domain/path availability
|
# Check domain/path availability
|
||||||
sudo yunohost app checkurl ${domain}${url_path} -a vpnclient
|
ynh_webpath_register vpnclient $domain $url_path || exit 1
|
||||||
if [ ! $? -eq 0 ]; then
|
|
||||||
exit 1
|
|
||||||
fi
|
|
||||||
|
|
||||||
# Install packages
|
# Install packages
|
||||||
packages='php5-fpm sipcalc dnsutils openvpn curl'
|
packages='php5-fpm sipcalc dnsutils openvpn curl'
|
||||||
@@ -131,13 +129,13 @@ sudo systemctl reload nginx
|
|||||||
sudo systemctl enable ynh-vpnclient
|
sudo systemctl enable ynh-vpnclient
|
||||||
sudo yunohost service add ynh-vpnclient
|
sudo yunohost service add ynh-vpnclient
|
||||||
|
|
||||||
sudo systemctl start ynh-vpnclient-checker.service
|
ynh_systemctl start ynh-vpnclient-checker.service
|
||||||
sudo systemctl enable ynh-vpnclient-checker.service
|
sudo systemctl enable ynh-vpnclient-checker.service
|
||||||
sudo systemctl start ynh-vpnclient-checker.timer
|
ynh_systemctl start ynh-vpnclient-checker.timer
|
||||||
sudo systemctl enable ynh-vpnclient-checker.timer
|
sudo systemctl enable ynh-vpnclient-checker.timer
|
||||||
|
|
||||||
if ! $upgrade; then
|
if ! $upgrade; then
|
||||||
sudo systemctl start ynh-vpnclient
|
ynh_systemctl start ynh-vpnclient
|
||||||
|
|
||||||
# Check configuration consistency
|
# Check configuration consistency
|
||||||
|
|
||||||
|
@@ -17,15 +17,17 @@
|
|||||||
# 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 vpnclient domain)
|
domain=$(sudo yunohost app setting vpnclient domain)
|
||||||
|
|
||||||
# The End
|
# The End
|
||||||
sudo systemctl stop ynh-vpnclient-checker.service
|
ynh_systemctl stop ynh-vpnclient-checker.service
|
||||||
sudo systemctl disable ynh-vpnclient-checker.service
|
sudo systemctl disable ynh-vpnclient-checker.service
|
||||||
sudo systemctl stop ynh-vpnclient-checker.timer && sleep 1
|
ynh_systemctl stop ynh-vpnclient-checker.timer && sleep 1
|
||||||
sudo systemctl disable ynh-vpnclient-checker.timer
|
sudo systemctl disable ynh-vpnclient-checker.timer
|
||||||
sudo systemctl stop ynh-vpnclient
|
ynh_systemctl stop ynh-vpnclient
|
||||||
sudo systemctl disable ynh-vpnclient
|
sudo systemctl disable ynh-vpnclient
|
||||||
sudo yunohost service remove ynh-vpnclient
|
sudo yunohost service remove ynh-vpnclient
|
||||||
sudo rm -f /etc/systemd/system/ynh-vpnclient* /usr/local/bin/ynh-vpnclient*
|
sudo rm -f /etc/systemd/system/ynh-vpnclient* /usr/local/bin/ynh-vpnclient*
|
||||||
|
@@ -7,6 +7,7 @@ ynh_setting() {
|
|||||||
sudo grep "^${setting}:" "/etc/yunohost/apps/${app}/settings.yml" | sed s/^[^:]\\+:\\s*[\"\']\\?// | sed s/\\s*[\"\']\$//
|
sudo grep "^${setting}:" "/etc/yunohost/apps/${app}/settings.yml" | sed s/^[^:]\\+:\\s*[\"\']\\?// | sed s/\\s*[\"\']\$//
|
||||||
}
|
}
|
||||||
|
|
||||||
|
source ./helpers
|
||||||
source ./prerequisites
|
source ./prerequisites
|
||||||
|
|
||||||
domain=$(ynh_setting vpnclient domain)
|
domain=$(ynh_setting vpnclient domain)
|
||||||
@@ -41,6 +42,6 @@ if [ -z "$(ynh_setting vpnclient dns0)" ]; then
|
|||||||
sudo yunohost app setting vpnclient dns1 -v 2001:913::8
|
sudo yunohost app setting vpnclient dns1 -v 2001:913::8
|
||||||
fi
|
fi
|
||||||
|
|
||||||
sudo systemctl start ynh-vpnclient
|
ynh_systemctl start ynh-vpnclient
|
||||||
|
|
||||||
exit 0
|
exit 0
|
||||||
|
Reference in New Issue
Block a user