mirror of
https://github.com/YunoHost-Apps/luckysheet_ynh.git
synced 2024-09-03 19:36:21 +02:00
87 lines
4 KiB
Bash
87 lines
4 KiB
Bash
#!/bin/bash
|
|
|
|
source _common.sh
|
|
source /usr/share/yunohost/helpers
|
|
|
|
#=================================================
|
|
# INSTALL NODEJS
|
|
#=================================================
|
|
ynh_script_progression "Installing NodeJS..."
|
|
|
|
# Install Nodejs
|
|
ynh_nodejs_install
|
|
|
|
#=================================================
|
|
# ENSURE DOWNWARD COMPATIBILITY
|
|
#=================================================
|
|
ynh_script_progression "Ensuring downward compatibility..."
|
|
|
|
# Remove the service from the list of services known by YunoHost (added from `yunohost service add`)
|
|
if ynh_hide_warnings yunohost service status $app >/dev/null; then
|
|
ynh_script_progression "Removing $app service integration..."
|
|
yunohost service remove "$app"
|
|
fi
|
|
|
|
ynh_app_setting_delete --key=port
|
|
ynh_config_remove_systemd
|
|
|
|
if [[ -d "$install_dir/src/" ]]; then
|
|
mv "$install_dir/src" "$install_dir/live"
|
|
fi
|
|
|
|
#=================================================
|
|
# DOWNLOAD, CHECK AND UNPACK SOURCE
|
|
#=================================================
|
|
ynh_script_progression "Upgrading source files..."
|
|
|
|
# Download, check integrity, uncompress and patch the source from app.src
|
|
ynh_setup_source --dest_dir="$install_dir/source" --full_replace
|
|
|
|
#REMOVEME? Assuming the install dir is setup using ynh_setup_source, the proper chmod/chowns are now already applied and it shouldn't be necessary to tweak perms | chmod 750 "$install_dir"
|
|
#REMOVEME? Assuming the install dir is setup using ynh_setup_source, the proper chmod/chowns are now already applied and it shouldn't be necessary to tweak perms | chmod -R o-rwx "$install_dir"
|
|
#REMOVEME? Assuming the install dir is setup using ynh_setup_source, the proper chmod/chowns are now already applied and it shouldn't be necessary to tweak perms | chown -R "$app:www-data" "$install_dir"
|
|
#=================================================
|
|
# BUILD APP
|
|
#=================================================
|
|
ynh_script_progression "Building app... (this will take some time and resources!)"
|
|
|
|
pushd "$install_dir/source"
|
|
|
|
ynh_hide_warnings ynh_exec_as_app node_load_PATH" npm install
|
|
ynh_hide_warnings env node_load_PATH" npm install gulp -g
|
|
ynh_hide_warnings ynh_exec_as_app node_load_PATH" npm run build
|
|
popd
|
|
|
|
mv "$install_dir/live/config.js" "$install_dir/config.js"
|
|
|
|
ynh_safe_rm "$install_dir/live"
|
|
ynh_exec_as_app mv "$install_dir/source/dist" "$install_dir/live"
|
|
|
|
mv "$install_dir/config.js" "$install_dir/live/config.js"
|
|
|
|
#REMOVEME? Assuming the install dir is setup using ynh_setup_source, the proper chmod/chowns are now already applied and it shouldn't be necessary to tweak perms | chmod 750 "$install_dir"
|
|
#REMOVEME? Assuming the install dir is setup using ynh_setup_source, the proper chmod/chowns are now already applied and it shouldn't be necessary to tweak perms | chmod -R o-rwx "$install_dir"
|
|
#REMOVEME? Assuming the install dir is setup using ynh_setup_source, the proper chmod/chowns are now already applied and it shouldn't be necessary to tweak perms | chown -R "$app:www-data" "$install_dir"
|
|
#=================================================
|
|
# UPDATE A CONFIG FILE
|
|
#=================================================
|
|
ynh_script_progression "Updating configuration..."
|
|
|
|
ynh_config_add --template="config.example.js" --destination="$install_dir/live/config.js"
|
|
|
|
#REMOVEME? Assuming the file is setup using ynh_config_add, the proper chmod/chowns are now already applied and it shouldn't be necessary to tweak perms | chmod 400 "$install_dir/live/config.js"
|
|
#REMOVEME? Assuming the file is setup using ynh_config_add, the proper chmod/chowns are now already applied and it shouldn't be necessary to tweak perms | chown "$app:$app" "$install_dir/live/config.js"
|
|
|
|
#=================================================
|
|
# REAPPLY SYSTEM CONFIGURATIONS
|
|
#=================================================
|
|
ynh_script_progression "Upgrading system configurations related to $app..."
|
|
|
|
# Create a dedicated NGINX config
|
|
ynh_config_add_nginx
|
|
|
|
#=================================================
|
|
# END OF SCRIPT
|
|
#=================================================
|
|
|
|
ynh_script_progression "Upgrade of $app completed"
|