1
0
Fork 0
mirror of https://github.com/YunoHost-Apps/duniter_ynh.git synced 2024-09-03 18:26:35 +02:00

[mod] #51: remove no longer neccessary sudo

This commit is contained in:
Moul 2018-11-29 17:03:39 +01:00
parent 5dc4d3b259
commit 3e379d9fa8
4 changed files with 25 additions and 25 deletions

View file

@ -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
}

View file

@ -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

View file

@ -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

View file

@ -19,7 +19,7 @@ INSTALL_DUNITER_DEBIAN_PACKAGE
CONFIGURE_DUNITER
# Start duniter daemon
sudo duniter webstart
duniter webstart
CONFIG_SSOWAT
CONFIG_NGINX