mirror of
https://github.com/YunoHost-Apps/kresus_ynh.git
synced 2024-09-03 19:36:10 +02:00
Add upgrade
This commit is contained in:
parent
b28b31c280
commit
1321ab1b15
3 changed files with 142 additions and 26 deletions
|
@ -24,7 +24,7 @@
|
||||||
Level 1=auto
|
Level 1=auto
|
||||||
Level 2=auto
|
Level 2=auto
|
||||||
Level 3=auto
|
Level 3=auto
|
||||||
# Level 4: https://github.com/YunoHost-Apps/weblate_ynh/issues/4
|
# Level 4: kresus doesn't support any user
|
||||||
Level 4=1
|
Level 4=1
|
||||||
# Level 5:
|
# Level 5:
|
||||||
Level 5=auto
|
Level 5=auto
|
||||||
|
|
|
@ -56,13 +56,13 @@ ynh_app_setting_set "$app" port "$port"
|
||||||
# INSTALL DEPENDENCIES
|
# INSTALL DEPENDENCIES
|
||||||
#=================================================
|
#=================================================
|
||||||
|
|
||||||
ynh_install_app_dependencies python-pip python-dev python-lxml python-imaging python-virtualenv
|
ynh_install_app_dependencies dh-autoreconf \
|
||||||
|
python-pip python-dev python-lxml python-imaging python-virtualenv
|
||||||
|
|
||||||
#=================================================
|
#=================================================
|
||||||
# DOWNLOAD, CHECK AND UNPACK SOURCE
|
# DOWNLOAD, CHECK AND UNPACK SOURCE
|
||||||
#=================================================
|
#=================================================
|
||||||
|
|
||||||
# TODO: this app should be installable from a specific version
|
|
||||||
ynh_app_setting_set "$app" final_path "$final_path"
|
ynh_app_setting_set "$app" final_path "$final_path"
|
||||||
|
|
||||||
# Download, check integrity, uncompress and patch the source from app.src
|
# Download, check integrity, uncompress and patch the source from app.src
|
||||||
|
@ -154,4 +154,5 @@ chmod 600 "$final_path/config.ini"
|
||||||
# RELOAD NGINX
|
# RELOAD NGINX
|
||||||
#=================================================
|
#=================================================
|
||||||
|
|
||||||
|
service "$app" start
|
||||||
service nginx reload
|
service nginx reload
|
||||||
|
|
161
scripts/upgrade
161
scripts/upgrade
|
@ -20,31 +20,146 @@ ynh_abort_if_errors
|
||||||
|
|
||||||
app=$YNH_APP_INSTANCE_NAME
|
app=$YNH_APP_INSTANCE_NAME
|
||||||
|
|
||||||
# Source YunoHost helpers
|
domain=$(ynh_app_setting_get $app domain)
|
||||||
source /usr/share/yunohost/helpers
|
path_url=$(ynh_app_setting_get $app path)
|
||||||
|
final_path=$(ynh_app_setting_get $app final_path)
|
||||||
|
port=$(ynh_app_setting_get $app port)
|
||||||
|
|
||||||
# Retrieve app settings
|
#=================================================
|
||||||
# domain=$(ynh_app_setting_get "$app" domain)
|
# ENSURE DOWNWARD COMPATIBILITY
|
||||||
# path=$(ynh_app_setting_get "$app" path)
|
#=================================================
|
||||||
|
|
||||||
# Build the app
|
# If final_path doesn't exist, create it
|
||||||
# src_path=/home/yunohost.app/$app
|
if [ -z $final_path ]; then
|
||||||
# mkdir -p $src_path $src_path/node_modules
|
final_path=/var/www/$app
|
||||||
# git clone https://framagit.org/bnjbvr/kresus.git $src_path
|
ynh_app_setting_set $app final_path $final_path
|
||||||
# npm install --prefix $src_path $src_path
|
fi
|
||||||
# .$src_path/scripts/build.sh
|
|
||||||
|
|
||||||
# Modify Nginx configuration file and copy it to Nginx conf directory
|
#=================================================
|
||||||
# nginx_conf=../conf/nginx.conf
|
# BACKUP BEFORE UPGRADE THEN ACTIVE TRAP
|
||||||
# sed -i "s@YNH_WWW_PATH@$path@g" $nginx_conf
|
#=================================================
|
||||||
# cp $nginx_conf /etc/nginx/conf.d/$domain.d/$app.conf
|
|
||||||
|
|
||||||
# Setup service
|
# Backup the current version of the app
|
||||||
# systemd_service=../conf/kresus.service
|
# ynh_backup_before_upgrade
|
||||||
# sed -i "s@APP_TO_CHANGE@$app@g" $systemd_service
|
# ynh_clean_setup () {
|
||||||
# cp $systemd_service /etc/systemd/system/$app.service
|
# restore it if the upgrade fails
|
||||||
# systemctl enable $app
|
# ynh_restore_upgradebackup
|
||||||
# systemctl start $app
|
# }
|
||||||
|
|
||||||
# Reload nginx service
|
# Exit if an error occurs during the execution of the script
|
||||||
service nginx reload
|
ynh_abort_if_errors
|
||||||
|
|
||||||
|
#=================================================
|
||||||
|
# CHECK THE PATH
|
||||||
|
#=================================================
|
||||||
|
|
||||||
|
# Normalize the URL path syntax
|
||||||
|
path_url=$(ynh_normalize_url_path $path_url)
|
||||||
|
|
||||||
|
#=================================================
|
||||||
|
# STANDARD UPGRADE STEPS
|
||||||
|
#=================================================
|
||||||
|
# INSTALL DEPENDENCIES
|
||||||
|
#=================================================
|
||||||
|
|
||||||
|
ynh_install_app_dependencies dh-autoreconf \
|
||||||
|
python-pip python-dev python-lxml python-imaging python-virtualenv
|
||||||
|
|
||||||
|
#=================================================
|
||||||
|
# DOWNLOAD, CHECK AND UNPACK SOURCE
|
||||||
|
#=================================================
|
||||||
|
|
||||||
|
# Download, check integrity, uncompress and patch the source from app.src
|
||||||
|
ynh_setup_source "$final_path"
|
||||||
|
mkdir -p "$final_path/data"
|
||||||
|
|
||||||
|
#=================================================
|
||||||
|
# NGINX CONFIGURATION
|
||||||
|
#=================================================
|
||||||
|
|
||||||
|
# Create a dedicated nginx config
|
||||||
|
ynh_add_nginx_config
|
||||||
|
|
||||||
|
#=================================================
|
||||||
|
# CREATE DEDICATED USER
|
||||||
|
#=================================================
|
||||||
|
|
||||||
|
# Create a system user
|
||||||
|
ynh_system_user_create "$app"
|
||||||
|
|
||||||
|
|
||||||
|
#=================================================
|
||||||
|
# SPECIFIC UPGRADE
|
||||||
|
#=================================================
|
||||||
|
# Install nodesjs
|
||||||
|
#=================================================
|
||||||
|
|
||||||
|
# install nodejs
|
||||||
|
ynh_install_nodejs 8
|
||||||
|
|
||||||
|
#=================================================
|
||||||
|
# Install weboob with pip
|
||||||
|
#=================================================
|
||||||
|
|
||||||
|
virtualenv "${final_path}/venv"
|
||||||
|
(
|
||||||
|
set +o nounset
|
||||||
|
source "${final_path}/venv/bin/activate"
|
||||||
|
set -o nounset
|
||||||
|
|
||||||
|
pip install --upgrade pip
|
||||||
|
pip install weboob
|
||||||
|
)
|
||||||
|
|
||||||
|
#=================================================
|
||||||
|
# Install Kresus with npm
|
||||||
|
#=================================================
|
||||||
|
|
||||||
|
ynh_use_nodejs
|
||||||
|
(
|
||||||
|
cd "$final_path"
|
||||||
|
chown -R $app: "$final_path"
|
||||||
|
npm install --unsafe-perm
|
||||||
|
npm run build:prod
|
||||||
|
)
|
||||||
|
|
||||||
|
#=================================================
|
||||||
|
# CONFIGURE HASTE
|
||||||
|
#=================================================
|
||||||
|
|
||||||
|
cp ../conf/config.ini "$final_path/config.ini"
|
||||||
|
|
||||||
|
ynh_replace_string "__PORT__" "$port" "$final_path/config.ini"
|
||||||
|
ynh_replace_string "__PATH__" "$path_url" "$final_path/config.ini"
|
||||||
|
ynh_replace_string "__FINALPATH__" "$final_path" "$final_path/config.ini"
|
||||||
|
|
||||||
|
# Calculate and store the config file checksum into the app settings
|
||||||
|
ynh_store_file_checksum "$final_path/config.ini"
|
||||||
|
|
||||||
|
#=================================================
|
||||||
|
# SETUP SYSTEMD
|
||||||
|
#=================================================
|
||||||
|
|
||||||
|
ynh_replace_string "__NODEJS__" "$nodejs_use_version" ../conf/systemd.service
|
||||||
|
ynh_replace_string "__ENV_PATH__" "$PATH" ../conf/systemd.service
|
||||||
|
ynh_replace_string "__NODEPATH__" "$(dirname "$nodejs_path")" ../conf/systemd.service
|
||||||
|
|
||||||
|
# Create a dedicated systemd config
|
||||||
|
ynh_add_systemd_config
|
||||||
|
|
||||||
|
#=================================================
|
||||||
|
# GENERIC FINALIZATION
|
||||||
|
#=================================================
|
||||||
|
# SECURE FILES AND DIRECTORIES
|
||||||
|
#=================================================
|
||||||
|
|
||||||
|
# Set right permissions for curl installation
|
||||||
|
chown -R $app: $final_path
|
||||||
|
chmod 600 "$final_path/config.ini"
|
||||||
|
|
||||||
|
#=================================================
|
||||||
|
# RELOAD NGINX
|
||||||
|
#=================================================
|
||||||
|
|
||||||
|
service "$app" restart
|
||||||
|
systemctl reload nginx
|
||||||
|
|
Loading…
Add table
Reference in a new issue