1
0
Fork 0
mirror of https://github.com/YunoHost-Apps/keeweb_ynh.git synced 2024-09-03 19:26:33 +02:00
keeweb_ynh/scripts/upgrade

58 lines
1.7 KiB
Text
Raw Normal View History

2016-03-01 10:47:41 +01:00
#!/bin/bash
# Exit on command errors and treat unset variables as an error
set -eu
2016-03-01 10:47:41 +01:00
app=$YNH_APP_INSTANCE_NAME
2016-03-01 10:47:41 +01:00
# Source YunoHost helpers
source /usr/share/yunohost/helpers
2016-03-01 10:47:41 +01:00
# Retrieve arguments
domain=$(ynh_app_setting_get "$app" domain)
path=$(ynh_app_setting_get "$app" path)
is_public=$(ynh_app_setting_get "$app" is_public)
2016-03-01 10:47:41 +01:00
# Remove trailing "/" for next commands
path=${path%/}
# Check domain/path availability
sudo yunohost app checkurl "${domain}${path}" -a "$app" \
|| ynh_die "Path not available: ${domain}${path}"
# Download source
sudo wget https://raw.githubusercontent.com/keeweb/keeweb/gh-pages/index.html
sudo wget https://raw.githubusercontent.com/keeweb/keeweb/gh-pages/manifest.appcache
sudo sed -i.bak 's/(no-config)/config.json/g' index.html
2016-03-01 10:47:41 +01:00
# Copy source files
src_path=/var/www/$app
sudo mkdir -p $src_path
sudo cp -a index.html manifest.appcache ../conf/config.json $src_path
2016-03-01 10:47:41 +01:00
# Set permissions to app files
sudo chown -R root: $src_path
2016-03-01 10:47:41 +01:00
# Modify Nginx configuration file and copy it to Nginx conf directory
sed -i "s@YNH_WWW_PATH@$path@g" ../conf/nginx.conf
sed -i "s@YNH_WWW_ALIAS@$src_path/@g" ../conf/nginx.conf
2016-03-01 10:47:41 +01:00
sudo cp ../conf/nginx.conf /etc/nginx/conf.d/$domain.d/$app.conf
# Migrate old apps
if [ "$is_public" = "Yes" ]; then
2016-12-06 03:14:26 +01:00
ynh_app_setting_set "$app" is_public "1"
2016-12-06 03:16:17 +01:00
is_public=$(ynh_app_setting_get "$app" is_public)
elif [ "$is_public" = "No" ]; then
2016-12-06 03:14:26 +01:00
ynh_app_setting_set "$app" is_public "0"
2016-12-06 03:16:17 +01:00
is_public=$(ynh_app_setting_get "$app" is_public)
fi
2016-03-01 10:47:41 +01:00
# If app is public, add url to SSOWat conf as skipped_uris
if [[ $is_public -eq 1 ]]; then
# unprotected_uris allows SSO credentials to be passed anyway.
ynh_app_setting_set "$app" unprotected_uris "/"
2016-03-01 10:47:41 +01:00
fi
# Restart services
sudo service nginx reload