From 3e379d9fa8aa49a185e55ba06ab16f889ae83571 Mon Sep 17 00:00:00 2001 From: Moul Date: Thu, 29 Nov 2018 17:03:39 +0100 Subject: [PATCH] [mod] #51: remove no longer neccessary `sudo` --- scripts/functions.sh | 26 +++++++++++++------------- scripts/install | 12 ++++++------ scripts/remove | 10 +++++----- scripts/upgrade | 2 +- 4 files changed, 25 insertions(+), 25 deletions(-) diff --git a/scripts/functions.sh b/scripts/functions.sh index 3f5a0b3..fc37f7d 100644 --- a/scripts/functions.sh +++ b/scripts/functions.sh @@ -15,19 +15,19 @@ url="${git_repo}${middle_url}${deb}" # Retrieve debian package and install it wget -nc --quiet $url -P /tmp deb_path="/tmp/$deb" -sudo dpkg -i $deb_path > /dev/null -sudo rm -f $deb_path +dpkg -i $deb_path > /dev/null +rm -f $deb_path } CONFIGURE_DUNITER () { - sudo duniter config --ipv4 127.0.0.1 --port $port --remoteh $domain --remotep 80 --noupnp - sudo duniter config --addep "BMAS $domain 443" - sudo duniter config --ws2p-host 127.0.0.1 --ws2p-port 20901 --ws2p-remote-host $domain --ws2p-remote-port 443 --ws2p-noupnp + duniter config --ipv4 127.0.0.1 --port $port --remoteh $domain --remotep 80 --noupnp + duniter config --addep "BMAS $domain 443" + duniter config --ws2p-host 127.0.0.1 --ws2p-port 20901 --ws2p-remote-host $domain --ws2p-remote-port 443 --ws2p-noupnp } CONFIG_SSOWAT () { # Add admin to the allowed users -sudo yunohost app addaccess $app -u $admin +yunohost app addaccess $app -u $admin # Protect senstive sub-routes ynh_app_setting_set "$app" protected_uris "/webui","/webmin" @@ -42,19 +42,19 @@ ynh_app_setting_set "$app" redirected_urls "{'$domain/':'$domain/webui'}" CONFIG_NGINX () { # Configure Nginx nginx_conf="../conf/nginx.conf" -sudo sed -i "s@YNH_EXAMPLE_PORT@$port@" $nginx_conf -sudo sed -i "s@YNH_EXAMPLE_DOMAIN@$domain@" $nginx_conf -sudo cp $nginx_conf /etc/nginx/conf.d/$domain.d/$app.conf -sudo service nginx reload +sed -i "s@YNH_EXAMPLE_PORT@$port@" $nginx_conf +sed -i "s@YNH_EXAMPLE_DOMAIN@$domain@" $nginx_conf +cp $nginx_conf /etc/nginx/conf.d/$domain.d/$app.conf +service nginx reload } REMOVE_DUNITER () { # Stop duniter daemon if running -sudo duniter status +duniter status if [ `echo "$?"` == 0 ]; then - sudo duniter stop + duniter stop fi # Remove Duniter package -sudo dpkg -r duniter +dpkg -r duniter } diff --git a/scripts/install b/scripts/install index ee17e39..9ccc47a 100755 --- a/scripts/install +++ b/scripts/install @@ -15,11 +15,11 @@ source /usr/share/yunohost/helpers source functions.sh # Check domain/path availability -sudo yunohost app checkurl "${domain}${path}" -a "$app" \ +yunohost app checkurl "${domain}${path}" -a "$app" \ || ynh_die "Path not available: ${domain}${path}" # Check port availability -sudo yunohost app checkport $port +yunohost app checkport $port if [[ ! $? -eq 0 ]]; then ynh_die "Port not available: ${port}" fi @@ -42,19 +42,19 @@ ynh_app_setting_set $app arch $arch ynh_app_setting_set "$app" admin "$admin" # Open port on firewall -sudo yunohost firewall allow TCP $port > /dev/null 2>&1 +yunohost firewall allow TCP $port > /dev/null 2>&1 INSTALL_DUNITER_DEBIAN_PACKAGE CONFIGURE_DUNITER # Reset Duniter node's existing data (blockchain, not conf) -sudo duniter reset data > /dev/null +duniter reset data > /dev/null # Launch Duniter node -sudo duniter webstart +duniter webstart # Add Duniter service to the YunoHost monitoring -sudo yunohost service add $app --log /root/.config/$app/"$app"_default/"$app".log +yunohost service add $app --log /root/.config/$app/"$app"_default/"$app".log CONFIG_SSOWAT CONFIG_NGINX diff --git a/scripts/remove b/scripts/remove index 30922fa..2ce73ea 100755 --- a/scripts/remove +++ b/scripts/remove @@ -14,14 +14,14 @@ port=$(ynh_app_setting_get $app port) REMOVE_DUNITER # Remove data and conf -sudo rm -rf /root/.conf/duniter +rm -rf /root/.conf/duniter # Remove Duniter service to YunoHost monitoring -sudo yunohost service remove $app +yunohost service remove $app # Remove Nginx configuration -sudo rm -f /etc/nginx/conf.d/$domain.d/$app.conf -sudo service nginx reload +rm -f /etc/nginx/conf.d/$domain.d/$app.conf +service nginx reload # Close opened port -sudo yunohost firewall disallow TCP $port +yunohost firewall disallow TCP $port diff --git a/scripts/upgrade b/scripts/upgrade index 3bfe214..648da0c 100755 --- a/scripts/upgrade +++ b/scripts/upgrade @@ -19,7 +19,7 @@ INSTALL_DUNITER_DEBIAN_PACKAGE CONFIGURE_DUNITER # Start duniter daemon -sudo duniter webstart +duniter webstart CONFIG_SSOWAT CONFIG_NGINX