1
0
Fork 0
mirror of https://github.com/YunoHost-Apps/BicBucStriim_ynh.git synced 2024-09-03 18:15:53 +02:00
This commit is contained in:
ericgaspar 2020-10-15 11:35:35 +02:00
parent 9d0ee4d9c8
commit c3abd51129
No known key found for this signature in database
GPG key ID: 574F281483054D44
5 changed files with 255 additions and 91 deletions

View file

@ -1,5 +1,5 @@
SOURCE_URL=http://projekte.textmulch.de/bicbucstriim/downloads/BicBucStriim-1.3.6.zip SOURCE_URL=http://projekte.textmulch.de/bicbucstriim/downloads/BicBucStriim-1.5.0.zip
SOURCE_SUM= SOURCE_SUM=07e260cddcf893524fb87e376e1d4e2b0f0df395574aeb348cec5d3ac9245c43
SOURCE_SUM_PRG=sha256sum SOURCE_SUM_PRG=sha256sum
SOURCE_FORMAT=zip SOURCE_FORMAT=zip
SOURCE_IN_SUBDIR=true SOURCE_IN_SUBDIR=true

View file

@ -80,7 +80,20 @@ ynh_script_progression --message="Configuring NGINX web server..." --weight=2
# Create a dedicated NGINX config # Create a dedicated NGINX config
ynh_add_nginx_config ynh_add_nginx_config
#=================================================
# PHP-FPM CONFIGURATION
#=================================================
ynh_script_progression --message="Configuring PHP-FPM..." --weight=2
# Create a dedicated PHP-FPM config
ynh_add_fpm_config --phpversion=$YNH_PHP_VERSION --package="$extra_php_dependencies"
phpversion=$(ynh_app_setting_get --app=$app --key=phpversion)
#=================================================
# SPECIFIC SETUP
#=================================================
# CONFIGURE BICBUCSTRIIM
#=================================================
books_path=/home/$admin/calibre_library books_path=/home/$admin/calibre_library
cp -r ../empty_library $books_path cp -r ../empty_library $books_path

View file

@ -1,27 +1,59 @@
#!/bin/bash #!/bin/bash
# See comments in install script #=================================================
app=$YNH_APP_INSTANCE_NAME # GENERIC START
#=================================================
# IMPORT GENERIC HELPERS
#=================================================
# Source YunoHost helpers source _common.sh
source /usr/share/yunohost/helpers source /usr/share/yunohost/helpers
# Retrieve app settings #=================================================
# LOAD SETTINGS
#=================================================
ynh_script_progression --message="Loading installation settings..." --weight=3
app=$YNH_APP_INSTANCE_NAME
domain=$(ynh_app_setting_get "$app" domain) domain=$(ynh_app_setting_get "$app" domain)
admin=$(ynh_app_setting_get "$app" admin) admin=$(ynh_app_setting_get "$app" admin)
books_path=/home/$admin/calibre_library books_path=/home/$admin/calibre_library
# Remove php5-sqlite dependency #=================================================
ynh_package_remove php5-sqlite # REMOVE APP MAIN DIR
#=================================================
ynh_script_progression --message="Removing app main directory..." --weight=4
# Remove sources # Remove the app directory securely
sudo rm -rf /var/www/$app ynh_secure_remove --file="$final_path"
# Remove calibre library #=================================================
sudo rm -rf $books_path # REMOVE CALIBRE LIBRARY
#=================================================
ynh_script_progression --message="Removing app main directory..." --weight=4
# Remove nginx configuration file # Remove the app directory securely
sudo rm -f /etc/nginx/conf.d/$domain.d/$app.conf ynh_secure_remove --file="$books_path"
# Reload nginx service #=================================================
sudo service nginx reload # REMOVE NGINX CONFIGURATION
#=================================================
ynh_script_progression --message="Removing NGINX web server configuration..." --weight=1
# Remove the dedicated NGINX config
ynh_remove_nginx_config
#=================================================
# REMOVE PHP-FPM CONFIGURATION
#=================================================
ynh_script_progression --message="Removing PHP-FPM configuration..." --weight=3
# Remove the dedicated PHP-FPM config
ynh_remove_fpm_config
#=================================================
# END OF SCRIPT
#=================================================
ynh_script_progression --message="Removal of $app completed" --last

View file

@ -1,57 +1,95 @@
#!/bin/bash #!/bin/bash
# Note: each files and directories you've saved using the ynh_backup helper #=================================================
# will be located in the current directory, regarding the last argument. # GENERIC START
#=================================================
# IMPORT GENERIC HELPERS
#=================================================
# Exit on command errors and treat unset variables as an error source ../settings/scripts/_common.sh
set -eu
# See comments in install script
app=$YNH_APP_INSTANCE_NAME
# Source YunoHost helpers
source /usr/share/yunohost/helpers source /usr/share/yunohost/helpers
# Retrieve old app settings #=================================================
# MANAGE SCRIPT FAILURE
#=================================================
# Exit if an error occurs during the execution of the script
ynh_abort_if_errors
#=================================================
# LOAD SETTINGS
#=================================================
ynh_script_progression --message="Loading settings..." --weight=1
app=$YNH_APP_INSTANCE_NAME
domain=$(ynh_app_setting_get "$app" domain) domain=$(ynh_app_setting_get "$app" domain)
path=$(ynh_app_setting_get "$app" path) path=$(ynh_app_setting_get "$app" path)
admin=$(ynh_app_setting_get "$app" admin) admin=$(ynh_app_setting_get "$app" admin)
#=================================================
# CHECK IF THE APP CAN BE RESTORED
#=================================================
ynh_script_progression --message="Validating restoration parameters..." --weight=2
ynh_webpath_available --domain=$domain --path_url=$path_url \
|| ynh_die --message="Path not available: ${domain}${path_url}"
test ! -d $final_path \
|| ynh_die --message="There is already a directory: $final_path "
#=================================================
# STANDARD RESTORATION STEPS
#=================================================
# RESTORE THE NGINX CONFIGURATION
#=================================================
ynh_restore_file --origin_path="/etc/nginx/conf.d/$domain.d/$app.conf"
#=================================================
# RESTORE THE APP MAIN DIR
#=================================================
ynh_script_progression --message="Restoring the app main directory..." --weight=2
ynh_restore_file --origin_path="$final_path"
#=================================================
# RESTORE USER RIGHTS
#=================================================
# you may need to make some file and/or directory writeable by www-data (nginx user)
chown -R root: "$src_path"
chown -R $admin "$books_path"
#=================================================
# RESTORE THE PHP-FPM CONFIGURATION
#=================================================
ynh_script_progression --message="Reconfiguring PHP-FPM..." --weight=50
ynh_restore_file --origin_path="/etc/php/$phpversion/fpm/pool.d/$app.conf"
ynh_add_fpm_config --phpversion=$YNH_PHP_VERSION --package="$extra_php_dependencies"
# Check domain/path availability
sudo yunohost app checkurl "${domain}${path}" -a "$app" \
|| ynh_die "Path not available: ${domain}${path}"
# Restore sources & data # Restore sources & data
src_path="/var/www/${app}" src_path="/var/www/${app}"
sudo cp -a ./sources "$src_path" cp -a ./sources "$src_path"
books_path=/home/$admin/calibre_library books_path=/home/$admin/calibre_library
sudo cp -a ./data "$books_path" cp -a ./data "$books_path"
# Restore permissions to app files
# you may need to make some file and/or directory writeable by www-data (nginx user)
sudo chown -R root: "$src_path"
sudo chown -R $admin "$books_path"
### MySQL (remove if not used) ### #=================================================
# If a MySQL database is used: # GENERIC FINALIZATION
# # Create and restore the database #=================================================
# dbname=$app # RELOAD NGINX AND PHP-FPM
# dbuser=$app #=================================================
# dbpass=$(ynh_app_setting_get "$app" mysqlpwd) ynh_script_progression --message="Reloading NGINX web server and PHP-FPM..." --weight=2
# ynh_mysql_create_db "$dbname" "$dbuser" "$dbpass"
# ynh_mysql_connect_as "$dbuser" "$dbpass" "$dbname" < ./dump.sql
### MySQL end ###
# Restore NGINX configuration ynh_systemd_action --service_name=php${phpversion}-fpm --action=reload
sudo cp -a ./nginx.conf "/etc/nginx/conf.d/${domain}.d/${app}.conf" ynh_systemd_action --service_name=nginx --action=reload
### PHP (remove if not used) ### #=================================================
# If a dedicated php-fpm process is used: # END OF SCRIPT
# # Copy PHP-FPM pool configuration and reload the service #=================================================
# sudo cp -a ./php-fpm.conf "/etc/php5/fpm/pool.d/${app}.conf"
# sudo service php5-fpm reload
### PHP end ###
# Restart webserver ynh_script_progression --message="Restoration completed for $app" --last
sudo service nginx reload

View file

@ -1,53 +1,122 @@
#!/bin/bash #!/bin/bash
# Exit on command errors and treat unset variables as an error #=================================================
set -eu # GENERIC START
#=================================================
# IMPORT GENERIC HELPERS
#=================================================
# See comments in install script source _common.sh
app=$YNH_APP_INSTANCE_NAME
# Source YunoHost helpers
source /usr/share/yunohost/helpers source /usr/share/yunohost/helpers
# Retrieve app settings #=================================================
# LOAD SETTINGS
#=================================================
ynh_script_progression --message="Loading installation settings..." --weight=1
app=$YNH_APP_INSTANCE_NAME
domain=$(ynh_app_setting_get "$app" domain) domain=$(ynh_app_setting_get "$app" domain)
path=$(ynh_app_setting_get "$app" path) path=$(ynh_app_setting_get "$app" path)
admin=$(ynh_app_setting_get "$app" admin) admin=$(ynh_app_setting_get "$app" admin)
is_public=$(ynh_app_setting_get "$app" is_public) is_public=$(ynh_app_setting_get "$app" is_public)
language=$(ynh_app_setting_get "$app" language) language=$(ynh_app_setting_get "$app" language)
# Remove trailing "/" for next commands #=================================================
path=${path%/} # CHECK VERSION
#=================================================
# Copy source files upgrade_type=$(ynh_check_app_version_changed)
src_path=/var/www/$app
sudo mkdir -p $src_path #=================================================
sudo cp -a ../sources/. $src_path # ENSURE DOWNWARD COMPATIBILITY
#=================================================
ynh_script_progression --message="Ensuring downward compatibility..." --weight=2
# If final_path doesn't exist, create it
if [ -z "$final_path" ]; then
final_path=/var/www/$app
ynh_app_setting_set --app=$app --key=final_path --value=$final_path
fi
# If db_name doesn't exist, create it
if [ -z "$db_name" ]; then
db_name=$(ynh_sanitize_dbid --db_name=$app)
ynh_app_setting_set --app=$app --key=db_name --value=$db_name
fi
#=================================================
# BACKUP BEFORE UPGRADE THEN ACTIVE TRAP
#=================================================
ynh_script_progression --message="Backing up $app before upgrading (may take a while)..." --weight=7
# Backup the current version of the app
ynh_backup_before_upgrade
ynh_clean_setup () {
# restore it if the upgrade fails
ynh_restore_upgradebackup
}
# Exit if an error occurs during the execution of the script
ynh_abort_if_errors
#=================================================
# STANDARD UPGRADE STEPS
#=================================================
# DOWNLOAD, CHECK AND UNPACK SOURCE
#=================================================
if [ "$upgrade_type" == "UPGRADE_APP" ]
then
ynh_script_progression --message="Upgrading source files..." --weight=7
# Create a temporary directory
#tmpdir="$(ynh_smart_mktemp --min_size=10)"
# Download, check integrity, uncompress and patch the source from app.src
ynh_setup_source --dest_dir="$final_path"
fi
#=================================================
# DOWNLOAD, CHECK AND UNPACK SOURCE
#=================================================
# ynh_script_progression --message="Setting up source files..." --weight=7
# ynh_app_setting_set --app=$app --key=final_path --value=$final_path
# # Download, check integrity, uncompress and patch the source from app.src
# #ynh_setup_source --dest_dir="$final_path"
# # Copy source files
# #src_path=/var/www/$app
# mkdir -p $final_path
# wget -q -P "$final_path" http://projekte.textmulch.de/bicbucstriim/downloads/BicBucStriim-1.3.6.zip -O "$final_path"/bbs.zip
# unzip -q "$final_path"/bbs.zip -d "$final_path"
# cp -R "$final_path"/BicBucStriim-1.3.6/* "$final_path"
# rm "$final_path"/bbs.zip
# rm -rf "$final_path"/BicBucStriim-1.3.6
#=================================================
# NGINX CONFIGURATION
#=================================================
ynh_script_progression --message="Configuring NGINX web server..." --weight=2
# Create a dedicated NGINX config
ynh_add_nginx_config
#=================================================
# SECURE FILES AND DIRECTORIES
#=================================================
# Set permissions to app files # Set permissions to app files
# you may need to make some file and/or directory writeable by www-data (nginx user) chown -R root: $src_path
sudo chown -R root: $src_path #chmod -R ga+w $src_path/data
#chown -R $admin "$books_path"
# Modify Nginx configuration file and copy it to Nginx conf directory #=================================================
nginx_conf=../conf/nginx.conf # SETUP SSOWAT
sed -i "s@YNH_WWW_PATH@$path@g" $nginx_conf #=================================================
sed -i "s@YNH_WWW_ALIAS@$src_path/@g" $nginx_conf
# If a dedicated php-fpm process is used:
#
# sed -i "s@YNH_WWW_APP@$app@g" $nginx_conf
sudo cp $nginx_conf /etc/nginx/conf.d/$domain.d/$app.conf
### PHP (remove if not used) ###
# If a dedicated php-fpm process is used:
# # Modify PHP-FPM pool configuration and copy it to the pool directory
# sed -i "s@YNH_WWW_APP@$app@g" ../conf/php-fpm.conf
# sed -i "s@YNH_WWW_ALIAS@$src_path/@g" ../conf/php-fpm.conf
# finalphpconf=/etc/php5/fpm/pool.d/$app.conf
# sudo cp ../conf/php-fpm.conf $finalphpconf
# sudo chown root: $finalphpconf
# sudo chmod 644 $finalphpconf
# sudo service php5-fpm restart
### PHP end ###
# If app is public, add url to SSOWat conf as skipped_uris # If app is public, add url to SSOWat conf as skipped_uris
if [[ $is_public -eq 1 ]]; then if [[ $is_public -eq 1 ]]; then
@ -55,5 +124,17 @@ if [[ $is_public -eq 1 ]]; then
ynh_app_setting_set "$app" unprotected_uris "/" ynh_app_setting_set "$app" unprotected_uris "/"
fi fi
# Reload nginx service #=================================================
sudo service nginx reload # GENERIC FINALIZATION
#=================================================
# RELOAD NGINX
#=================================================
ynh_script_progression --message="Reloading NGINX web server..." --weight=2
ynh_systemd_action --service_name=nginx --action=reload
#=================================================
# END OF SCRIPT
#=================================================
ynh_script_progression --message="Upgrade of $app completed" --last