1
0
Fork 0
mirror of https://github.com/YunoHost-Apps/duniter_ynh.git synced 2024-09-03 18:26:35 +02:00
duniter_ynh/scripts/upgrade
Moul 6f96db42ac [enh] #14: automatically retrieve last version
- retrive last version available for x64 or for armel architectures
- upgrade enable set -u
2016-08-20 01:35:46 +02:00

58 lines
1.7 KiB
Bash
Executable file
Raw Blame History

This file contains invisible Unicode characters

This file contains invisible Unicode characters that are indistinguishable to humans but may be processed differently by a computer. If you think that this is intentional, you can safely ignore this warning. Use the Escape button to reveal them.

#!/bin/bash
# Exit on command errors and treat unset variables as an error
set -eu
# Source app helpers
source /usr/share/yunohost/helpers
# Retrive arguments
app=$YNH_APP_INSTANCE_NAME
domain=$(ynh_app_setting_get "$app" domain)
path=$(ynh_app_setting_get "$app" path)
port=$(ynh_app_setting_get "$app" port)
arch=$(ynh_app_setting_get "$app" arch)
admin=$(ynh_app_setting_get "$app" admin)
# Check CPU arch
if [[ $arch != "x64" && $arch != "armv7l" ]]; then
ynh_die "$arch is not currently supported." 2
fi
# Stop duniter daemon
sudo $app stop
# Remove Duniter package
sudo dpkg -r duniter
# Retrieve url of latest version and number
url=$(curl -s https://api.github.com/repos/duniter/duniter/releases | grep "browser_" | grep $arch | head -1 | cut -d\" -f4)
version=$(curl -s https://api.github.com/repos/duniter/duniter/releases | grep "browser_" | grep $arch | head -1 | cut -d/ -f8)
# Retrieve Debian package and install it
wget -nc --quiet $url -P /tmp
sudo dpkg -i /tmp/duniter-$version-linux-$arch.deb
sudo rm -f /tmp/duniter-$version-linux-$arch.deb
# Start duniter daemon
sudo $app webstart
# Remove trailing "/" for next command
path=${path%/}
# Add admin to the allowed users
sudo yunohost app addaccess $app -u $admin
# Allow only allowed users to access admin panel
ynh_app_setting_set "$app" protected_uris "/"
# SSOwat Configuration
#ynh_app_setting_set "$app" unprotected_uris "/api/"
# Upgrade Nginx configuration
nginx_conf="../conf/nginx.conf"
#sudo sed -i "s@YNH_EXAMPLE_PATH@$path@g" $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 nginx -t && sudo service nginx reload