1
0
Fork 0
mirror of https://github.com/YunoHost-Apps/ampache_ynh.git synced 2024-09-03 18:15:55 +02:00

add comment blocks #21

This commit is contained in:
aymhce 2017-09-25 21:53:41 +02:00
parent 1a14eb7fc8
commit a8c53c080e
5 changed files with 191 additions and 9 deletions

View file

@ -2,18 +2,41 @@
set -eu
#=================================================
# IMPORT GENERIC HELPERS
#=================================================
. /usr/share/yunohost/helpers
#=================================================
# MANAGE SCRIPT FAILURE
#=================================================
ynh_abort_if_errors
app=$YNH_APP_INSTANCE_NAME
#=================================================
# LOAD SETTINGS
#=================================================
app=$YNH_APP_INSTANCE_NAME
domain=$(ynh_app_setting_get "$app" domain)
path=$(ynh_app_setting_get "$app" path)
admin=$(ynh_app_setting_get "$app" admin)
#=================================================
# BACKUP THE APP MAIN DIR
#=================================================
ynh_backup "/var/www/$app" "sources" 1
#=================================================
# BACKUP THE NGINX CONFIGURATION
#=================================================
ynh_backup "/etc/nginx/conf.d/$domain.d/$app.conf" "conf/nginx.conf"
#=================================================
# BACKUP THE MYSQL DATABASE
#=================================================
ynh_mysql_dump_db "$app" > db.sql
#ynh_backup "db.sql" "db.sql"

View file

@ -2,32 +2,60 @@
set -eu
#=================================================
# RETRIEVE ARGUMENTS FROM THE MANIFEST
#=================================================
# Retrieve arguments
app=$YNH_APP_INSTANCE_NAME
domain=$YNH_APP_ARG_DOMAIN
path=$YNH_APP_ARG_PATH
admin_ampache=$YNH_APP_ARG_ADMIN
#=================================================
# IMPORT GENERIC HELPERS
#=================================================
# Source helpers
. /usr/share/yunohost/helpers
. _common
#=================================================
# MANAGE SCRIPT FAILURE
#=================================================
ynh_abort_if_errors
#=================================================
# CHECK IF THE APP CAN BE INSTALLED WITH THESE ARGS
#=================================================
# Check if admin exists
sudo yunohost user list --json | grep -qi "\"username\": \"$admin_ampache\"" || ynh_die "wrong admin username"
ynh_app_setting_set $app admin $admin_ampache
# Check domain/path availability
path=$(ynh_normalize_url_path $path)
ynh_webpath_available $domain $path
ynh_webpath_register $app $domain $path
#=================================================
# STORE SETTINGS FROM MANIFEST
#=================================================
ynh_app_setting_set $app admin $admin_ampache
#=================================================
# DOWNLOAD, CHECK AND UNPACK SOURCE
#=================================================
# get sources and copy files to the right place
ampache_ynh_getsources
sudo cp ../conf/admin.sql /tmp/
#=================================================
# CREATE A MYSQL DATABASE
#=================================================
# Generate random password
db_pwd=$(dd if=/dev/urandom bs=1 count=200 2> /dev/null | tr -c -d '[A-Za-z0-9]' | sed -n 's/\(.\{24\}\).*/\1/p')
@ -36,6 +64,10 @@ ynh_app_setting_set $app mysqlpwd $db_pwd
ynh_mysql_setup_db "$app" "$app" "$db_pwd"
ynh_mysql_connect_as "$app" "$db_pwd" "$app" < "$final_path/sql/ampache.sql"
#=================================================
# MODIFY A CONFIG FILE
#=================================================
# Change variables in Ampache configuration
ampache_ynh_prepareconfig
@ -43,24 +75,47 @@ sudo sed -i "s/yunoadmin/$admin_ampache/g" /tmp/admin.sql
random_key=db_pwd=$(dd if=/dev/urandom bs=1 count=200 2> /dev/null | tr -c -d '[A-Za-z0-9]' | sed -n 's/\(.\{24\}\).*/\1/p')
sudo sed -i "s@RANDOMKEYTOCHANGE@$random_key@g" $final_path/config/ampache.cfg.php
#=================================================
# NGINX CONFIGURATION
#=================================================
# Modify Nginx configuration file and copy it to Nginx conf directory
ampache_ynh_preparenginx
#=================================================
# INSTALL DEPENDENCIES
#=================================================
# Install dependency
sudo apt-get update
sudo apt-get install libav-tools -y
#=================================================
# SPECIFIC SETUP
#=================================================
# Ampache installation
ampache_ynh_install
#=================================================
# RELOAD NGINX
#=================================================
# Reload Nginx and regenerate SSOwat conf
ampache_ynh_reloadservices
#=================================================
# SETUP APPLICATION WITH CURL
#=================================================
# Pre config ampache
ampache_ynh_doconfig
ynh_mysql_connect_as "$app" "$db_pwd" "$app" < /tmp/admin.sql
#=================================================
# CLEANING
#=================================================
# Clean install
sudo rm -rf ../ampache-$version
sudo rm /tmp/admin.sql

View file

@ -2,17 +2,42 @@
set -u
#=================================================
# IMPORT GENERIC HELPERS
#=================================================
. /usr/share/yunohost/helpers
#=================================================
# LOAD SETTINGS
#=================================================
app=$YNH_APP_INSTANCE_NAME
domain=$(ynh_app_setting_get $app domain)
#=================================================
# REMOVE THE MYSQL DATABASE
#=================================================
ynh_mysql_drop_db $app
ynh_mysql_drop_user $app
#=================================================
# REMOVE APP MAIN DIR
#=================================================
# Remove sources
sudo rm -rf /var/www/$app
#=================================================
# REMOVE NGINX CONFIGURATION
#=================================================
# Remove Nginx configuration and reload Nginx conf
sudo rm -f /etc/nginx/conf.d/$domain.d/$app.conf
#=================================================
# RELOAD NGINX
#=================================================
sudo service nginx reload

View file

@ -2,33 +2,71 @@
set -eu
#=================================================
# IMPORT GENERIC HELPERS
#=================================================
. /usr/share/yunohost/helpers
#=================================================
# MANAGE SCRIPT FAILURE
#=================================================
ynh_abort_if_errors
app=$YNH_APP_INSTANCE_NAME
#=================================================
# LOAD SETTINGS
#=================================================
app=$YNH_APP_INSTANCE_NAME
domain=$(ynh_app_setting_get "$app" domain)
path=$(ynh_app_setting_get "$app" path)
admin=$(ynh_app_setting_get "$app" admin)
#=================================================
# CHECK IF THE APP CAN BE RESTORED
#=================================================
# Check domain/path availability
test ! -d /var/www/$app \
|| ynh_die "There is already a directory: /var/www/$app "
#=================================================
# CHECK THE PATH
#=================================================
path=$(ynh_normalize_url_path $path)
#ynh_webpath_available $domain $path
#ynh_webpath_register $app $domain $path
#=================================================
# REINSTALL DEPENDENCIES
#=================================================
# Install dependency
sudo apt-get update
sudo apt-get install libav-tools -y
#=================================================
# RESTORE THE APP MAIN DIR
#=================================================
sudo cp -a ./sources "/var/www/$app"
#=================================================
# RESTORE THE NGINX CONFIGURATION
#=================================================
sudo cp -a ./conf/nginx.conf "/etc/nginx/conf.d/$domain.d/$app.conf"
#=================================================
# RESTORE THE MYSQL DATABASE
#=================================================
db_pwd=$(ynh_app_setting_get $app mysqlpwd)
ynh_mysql_setup_db $app $app $db_pwd
ynh_mysql_connect_as $app $db_pwd $app < ./db.sql
#=================================================
# RELOAD NGINX
#=================================================
sudo service nginx reload

View file

@ -2,10 +2,23 @@
set -eu
#=================================================
# IMPORT GENERIC HELPERS
#=================================================
. /usr/share/yunohost/helpers
. _common
#=================================================
# MANAGE SCRIPT FAILURE
#=================================================
ynh_abort_if_errors
#=================================================
# LOAD SETTINGS
#=================================================
# Retrieve arguments
app=$YNH_APP_INSTANCE_NAME
domain=$(ynh_app_setting_get $app domain)
@ -13,25 +26,53 @@ path=$(ynh_app_setting_get $app path)
db_pwd=$(ynh_app_setting_get $app mysqlpwd)
admin_ampache=$(ynh_app_setting_get $app admin)
#=================================================
# CHECK THE PATH
#=================================================
path=$(ynh_normalize_url_path $path)
#=================================================
# DOWNLOAD, CHECK AND UNPACK SOURCE
#=================================================
# Get sources and copy files to the right place
ampache_ynh_getsources
# Change variables in Ampache configuration
ampache_ynh_prepareconfig
#=================================================
# NGINX CONFIGURATION
#=================================================
# Modify Nginx configuration file and copy it to Nginx conf directory
ampache_ynh_preparenginx
#=================================================
# SPECIFIC SETUP
#=================================================
# Ampache installation
ampache_ynh_install
#=================================================
# RELOAD NGINX
#=================================================
# Reload Nginx and regenerate SSOwat conf
ampache_ynh_reloadservices
#=================================================
# SETUP APPLICATION WITH CURL
#=================================================
# Pre config ampache
ampache_ynh_doconfig
#=================================================
# CLEANING
#=================================================
# Clean install
sudo rm -rf ../ampache-$version