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

Update install

This commit is contained in:
frju365 2017-03-08 23:32:10 +01:00 committed by GitHub
parent 3c024b243f
commit 44055144f8

View file

@ -1,55 +1,88 @@
#!/bin/bash #!/bin/bash
set -e #=================================================
# GENERIC STARTING
#=================================================
# IMPORT GENERIC HELPERS
#=================================================
source ./_common.sh source .fonctions
source /usr/share/yunohost/helpers
app="jappix" #=================================================
# MANAGE FAILURE OF THE SCRIPT
#=================================================
# Retrieve arguments ynh_check_error # Active trap pour arrêter le script si une erreur est détectée.
domain=$1
path=${2%/}
name=$3
language=$4
#=================================================
# RETRIEVE ARGUMENTS FROM THE MANIFEST
#=================================================
domain=$YNH_APP_ARG_DOMAIN
path=$YNH_APP_ARG_PATH
name=$YNH_APP_ARG_NAME
language=$YNH_APP_ARG_LANGUAGE
app=$YNH_APP_INSTANCE_NAME
#=================================================
# Check domain/path availability # Check domain/path availability
sudo yunohost app checkurl "${domain}${path}" -a "$app" \ #=================================================
|| exit 1
# Retrieve sources CHECK_PATH # Vérifie et corrige la syntaxe du path.
wget -q -O jappix.tar.gz "$JAPPIX_SOURCE_URL" CHECK_DOMAINPATH
CHECK_FINALPATH # Vérifie que le dossier de destination n'est pas déjà utilisé.
#=================================================
# STORE SETTINGS FROM MANIFEST
#=================================================
ynh_app_setting_set $app name $name
ynh_app_setting_set $app language $language
ynh_app_setting_set $app domain $domain
ynh_app_setting_set $app final_path $final_path
#=================================================
# Copy files to the right place # Copy files to the right place
final_path="/var/www/${app}" #=================================================
SETUP_SOURCE # Télécharge la source, décompresse et copie dans $final_path
sudo mkdir -p "${final_path}/store/conf" sudo mkdir -p "${final_path}/store/conf"
sudo tar -C "$final_path" -xf jappix.tar.gz --strip-components 1
sudo cp ../conf/*.xml "${final_path}/store/conf/" sudo cp ../conf/*.xml "${final_path}/store/conf/"
#=================================================
# Set permissions to jappix directory # Set permissions to jappix directory
#=================================================
sudo chown -R www-data: "$final_path" sudo chown -R www-data: "$final_path"
#=================================================
# Set and copy NGINX configuraion # Set and copy NGINX configuraion
sudo sed -i "s@PATHTOCHANGE2@${path}@g" ../conf/nginx.conf #=================================================
path=${path:-/}
sudo sed -i "s@PATHTOCHANGE@${path}@g" ../conf/nginx.conf sudo sed -i "s@PATHTOCHANGE@${path}@g" ../conf/nginx.conf
sudo sed -i "s@ALIASTOCHANGE@${final_path}/@g" ../conf/nginx.conf sudo sed -i "s@ALIASTOCHANGE@${final_path}/@g" ../conf/nginx.conf
sudo cp ../conf/nginx.conf "/etc/nginx/conf.d/${domain}.d/${app}.conf" sudo cp ../conf/nginx.conf "/etc/nginx/conf.d/${domain}.d/${app}.conf"
#=================================================
# Validate language # Validate language
[[ -a "${final_path}/i18n/${language}" ]] \ #=================================================
[[ -e "${final_path}/i18n/${language}" ]] \
|| language="en" || language="en"
# Store app settings #=================================================
sudo yunohost app setting "$app" name -v "$name"
sudo yunohost app setting "$app" language -v "$language"
# Set Jappix configuration # Set Jappix configuration
sudo sed -i "s@PATHTOCHANGE@${path}@g" "${final_path}/store/conf/main.xml" #=================================================
sudo sed -i "s@PATHTOCHANGE@${path}@g" "${final_path}/store/conf/hosts.xml" sudo sed -i "s@PATHTOCHANGE@${path}@g" "${final_path}/store/conf/hosts.xml"
sudo sed -i "s@DOMAINTOCHANGE@${domain}@g" "${final_path}/store/conf/main.xml"
sudo sed -i "s@CHANGELANG@${language}@g" "${final_path}/store/conf/main.xml" sudo sed -i "s@CHANGELANG@${language}@g" "${final_path}/store/conf/main.xml"
sudo sed -i "s@CHANGENAME@${name}@g" "${final_path}/store/conf/main.xml" sudo sed -i "s@CHANGENAME@${name}@g" "${final_path}/store/conf/main.xml"
sudo sed -i "s@DOMAINTOCHANGE@${domain}@g" "${final_path}/store/conf/hosts.xml" sudo sed -i "s@DOMAINTOCHANGE@${domain}@g" "${final_path}/store/conf/hosts.xml"
#=================================================
# Reload services # Reload services
#=================================================
sudo service nginx reload sudo service nginx reload