From da76228184c5e87a36500b0ab31f738e240febb2 Mon Sep 17 00:00:00 2001 From: opi Date: Sat, 14 May 2016 09:56:38 +0200 Subject: [PATCH] [enh] Use env var in existing script (install/remove/upgrade). --- scripts/install | 17 +++++++++++------ scripts/remove | 21 ++++++++++++++++----- scripts/upgrade | 13 +++++++++---- 3 files changed, 36 insertions(+), 15 deletions(-) diff --git a/scripts/install b/scripts/install index fd5c5cd..163b8bd 100644 --- a/scripts/install +++ b/scripts/install @@ -1,10 +1,16 @@ #!/bin/bash -# Retrieve arguments -domain=$1 -path=$2 +# causes the shell to exit if any subcommand or pipeline returns a non-zero status +set -e -sudo yunohost app checkurl $domain$path -a transmission +# Get app instance name +app=$YNH_APP_INSTANCE_NAME + +# Retrieve arguments +domain=$YNH_APP_ARG_DOMAIN +path=$YNH_APP_ARG_PATH + +sudo yunohost app checkurl $domain$path -a $app if [[ ! $? -eq 0 ]]; then exit 1 fi @@ -50,6 +56,5 @@ sudo sed -i "s@
@< # Configure Nginx and reload sed -i "s@PATHTOCHANGE@$path@g" ../conf/nginx.conf -sudo cp ../conf/nginx.conf /etc/nginx/conf.d/$domain.d/transmission.conf +sudo cp ../conf/nginx.conf /etc/nginx/conf.d/$domain.d/$app.conf sudo service nginx reload -echo $? diff --git a/scripts/remove b/scripts/remove index 4de3f85..017db52 100644 --- a/scripts/remove +++ b/scripts/remove @@ -1,14 +1,25 @@ #!/bin/bash -sudo service transmission-daemon stop -sudo yunohost firewall disallow TCP 51413 -sudo yunohost service remove transmission-daemon -domain=$(sudo yunohost app setting transmission domain) +# Retreive app settings +app=$YNH_APP_INSTANCE_NAME +domain=$(sudo yunohost app setting $app domain) -sudo rm /etc/nginx/conf.d/$domain.d/transmission.conf +# Stop service +sudo service transmission-daemon stop +sudo yunohost service remove transmission-daemon + +# Disallow specific port +sudo yunohost firewall disallow TCP 51413 + +# Remove nginx configuration +sudo rm /etc/nginx/conf.d/$domain.d/$app.conf + +# Remove data sudo rm -rf /home/yunohost.transmission +# Remove Debian package sudo apt-get remove -y -qq transmission-daemon +# Reload nginx and ssowatconf sudo service nginx reload sudo yunohost app ssowatconf diff --git a/scripts/upgrade b/scripts/upgrade index 2902e77..56d008a 100644 --- a/scripts/upgrade +++ b/scripts/upgrade @@ -1,8 +1,13 @@ -#!/bin/bash + +# causes the shell to exit if any subcommand or pipeline returns a non-zero status +set -e + +# Get app instance name +app=$YNH_APP_INSTANCE_NAME # Retrieve arguments -domain=$(sudo yunohost app setting transmission domain) -path=$(sudo yunohost app setting transmission path) +domain=$YNH_APP_ARG_DOMAIN +path=$YNH_APP_ARG_PATH # Remove trailing "/" for next commands path=${path%/} @@ -37,5 +42,5 @@ fi # Configure Nginx and reload sed -i "s@PATHTOCHANGE@$path@g" ../conf/nginx.conf -sudo cp ../conf/nginx.conf /etc/nginx/conf.d/$domain.d/transmission.conf +sudo cp ../conf/nginx.conf /etc/nginx/conf.d/$domain.d/$app.conf sudo service nginx reload