mirror of
https://github.com/YunoHost-Apps/abantecart_ynh.git
synced 2024-09-03 18:06:16 +02:00
Update install
This commit is contained in:
parent
7e341c55df
commit
885e82d7d4
1 changed files with 79 additions and 29 deletions
108
scripts/install
108
scripts/install
|
@ -1,14 +1,27 @@
|
||||||
#!/bin/bash
|
#!/bin/bash
|
||||||
|
|
||||||
source ./_common
|
#=================================================
|
||||||
source .fonctions
|
# GENERIC STARTING
|
||||||
set -eu
|
#=================================================
|
||||||
source /usr/share/yunohost/helpers
|
# IMPORT GENERIC HELPERS
|
||||||
|
#=================================================
|
||||||
|
|
||||||
|
source .fonctions
|
||||||
|
source /usr/share/yunohost/helpers
|
||||||
|
set -eu
|
||||||
|
|
||||||
|
#=================================================
|
||||||
|
# MANAGE FAILURE OF THE SCRIPT
|
||||||
|
#=================================================
|
||||||
|
|
||||||
|
ynh_check_error # Active trap pour arrêter le script si une erreur est détectée.
|
||||||
|
|
||||||
|
#=================================================
|
||||||
|
# RETRIEVE ARGUMENTS FROM THE MANIFEST
|
||||||
|
#=================================================
|
||||||
|
|
||||||
# Retrieve app id
|
|
||||||
app=$YNH_APP_INSTANCE_NAME
|
app=$YNH_APP_INSTANCE_NAME
|
||||||
|
|
||||||
# Retrieve arguments
|
|
||||||
domain=$YNH_APP_ARG_DOMAIN
|
domain=$YNH_APP_ARG_DOMAIN
|
||||||
path=$YNH_APP_ARG_PATH
|
path=$YNH_APP_ARG_PATH
|
||||||
is_public=$YNH_APP_ARG_IS_PUBLIC
|
is_public=$YNH_APP_ARG_IS_PUBLIC
|
||||||
|
@ -16,6 +29,10 @@ admin_name=$YNH_APP_ARG_ADMIN_NAME
|
||||||
admin_pass=$YNH_APP_ARG_ADMIN_PASS
|
admin_pass=$YNH_APP_ARG_ADMIN_PASS
|
||||||
admin_email=$YNH_APP_ARG_ADMIN_EMAIL
|
admin_email=$YNH_APP_ARG_ADMIN_EMAIL
|
||||||
|
|
||||||
|
#=================================================
|
||||||
|
# CHECK IF THE APP CAN BE INSTALLED WITH THIS ARGS
|
||||||
|
#=================================================
|
||||||
|
|
||||||
# Vérifie que les variables ne sont pas vides.
|
# Vérifie que les variables ne sont pas vides.
|
||||||
CHECK_VAR "$app" "app name not set"
|
CHECK_VAR "$app" "app name not set"
|
||||||
|
|
||||||
|
@ -24,26 +41,32 @@ CHECK_DOMAINPATH # Vérifie la disponibilité du path et du domaine.
|
||||||
|
|
||||||
CHECK_FINALPATH # Vérifie que le dossier de destination n'est pas déjà utilisé.
|
CHECK_FINALPATH # Vérifie que le dossier de destination n'est pas déjà utilisé.
|
||||||
|
|
||||||
# Install dependency to convert tracks to a readable format for the browser
|
#=================================================
|
||||||
# sudo apt-get update
|
|
||||||
# sudo apt-get -y -qq install php5-mysql
|
|
||||||
|
|
||||||
# Install dependencies using Helpers
|
# Install dependencies using Helpers
|
||||||
|
#=================================================
|
||||||
ynh_package_install_from_equivs ../conf/abantecart-deps.control \
|
ynh_package_install_from_equivs ../conf/abantecart-deps.control \
|
||||||
|| ynh_die "Unable to install dependencies"
|
|| ynh_die "Unable to install dependencies"
|
||||||
|
|
||||||
|
#=================================================
|
||||||
# Check password strength
|
# Check password strength
|
||||||
|
#=================================================
|
||||||
|
|
||||||
[[ ${#admin_pass} -gt 5 ]] || ynh_die \
|
[[ ${#admin_pass} -gt 5 ]] || ynh_die \
|
||||||
"The password is too weak, it must be longer than 5 characters"
|
"The password is too weak, it must be longer than 5 characters"
|
||||||
|
|
||||||
# Save app settings
|
#=================================================
|
||||||
|
# STORE SETTINGS FROM MANIFEST
|
||||||
|
#=================================================
|
||||||
|
|
||||||
user="$app"
|
user="$app"
|
||||||
ynh_app_setting_set "$app" is_public "$is_public"
|
ynh_app_setting_set "$app" is_public "$is_public"
|
||||||
ynh_app_setting_set "$app" admin_pass "$admin_pass"
|
ynh_app_setting_set "$app" admin_pass "$admin_pass"
|
||||||
ynh_app_setting_set "$app" admin_name "$admin_name"
|
ynh_app_setting_set "$app" admin_name "$admin_name"
|
||||||
ynh_app_setting_set "$app" admin_email "$admin_email"
|
ynh_app_setting_set "$app" admin_email "$admin_email"
|
||||||
|
|
||||||
|
#=================================================
|
||||||
# Initialize database as needed
|
# Initialize database as needed
|
||||||
|
#=================================================
|
||||||
|
|
||||||
db_name=$app
|
db_name=$app
|
||||||
db_user=$app
|
db_user=$app
|
||||||
|
@ -51,28 +74,32 @@ db_pass=$(ynh_string_random)
|
||||||
ynh_mysql_create_db "$db_name" "$db_user" "$db_pass"
|
ynh_mysql_create_db "$db_name" "$db_user" "$db_pass"
|
||||||
ynh_app_setting_set "$app" db_name "$db_name"
|
ynh_app_setting_set "$app" db_name "$db_name"
|
||||||
ynh_app_setting_set "$app" db_pass "$db_pass"
|
ynh_app_setting_set "$app" db_pass "$db_pass"
|
||||||
|
ynh_app_setting_set "$app" db_user "$db_user"
|
||||||
|
|
||||||
# Remove trailing "/" for next commands
|
#=================================================
|
||||||
if [[ ! "$path" == "/" ]]; then
|
# DOWNLOAD, CHECK AND UNPACK SOURCE
|
||||||
path=${path%/}
|
#=================================================
|
||||||
fi
|
|
||||||
|
|
||||||
# Copy files to the right place
|
|
||||||
final_path=/var/www/$app
|
final_path=/var/www/$app
|
||||||
ynh_app_setting_set "$app" final_path "$final_path"
|
ynh_app_setting_set $app final_path $final_path
|
||||||
|
SETUP_SOURCE # Télécharge la source, décompresse et copie dans $final_path
|
||||||
|
|
||||||
# We download the sources and check the md5sum
|
|
||||||
SFILE=`sudo cat ../sources/source_file`;
|
#=================================================
|
||||||
sudo wget -nv -i ../sources/source_url -O ${SFILE}.tar.gz
|
# SPECIFIC SETUP
|
||||||
sudo md5sum -c ../sources/source_md5 --status || (echo "Corrupt source" >&2 && false)
|
#=================================================
|
||||||
sudo tar xvf ${SFILE}.tar.gz -C ../sources/
|
# Cleaning
|
||||||
sudo cp -a ../sources/abantecart-src-master/. $final_path
|
#=================================================
|
||||||
|
|
||||||
sudo rm -rf $final_path/tests
|
sudo rm -rf $final_path/tests
|
||||||
sudo rm -rf $final_path/install.txt
|
sudo rm -rf $final_path/install.txt
|
||||||
sudo mv $final_path/public_html/* $final_path/
|
sudo mv $final_path/public_html/* $final_path/
|
||||||
sudo rm -rf $final_path/public_html
|
sudo rm -rf $final_path/public_html
|
||||||
|
|
||||||
|
#=================================================
|
||||||
|
# CLI installation
|
||||||
|
#=================================================
|
||||||
|
|
||||||
pushd $final_path/install/
|
pushd $final_path/install/
|
||||||
sudo php cli_install.php install \
|
sudo php cli_install.php install \
|
||||||
--db_host=localhost \
|
--db_host=localhost \
|
||||||
|
@ -89,15 +116,23 @@ sudo php cli_install.php install \
|
||||||
--admin_path=admin
|
--admin_path=admin
|
||||||
popd
|
popd
|
||||||
|
|
||||||
|
#=================================================
|
||||||
|
# Cleaning
|
||||||
|
#=================================================
|
||||||
|
|
||||||
sudo rm -rf /var/www/$app/install/
|
sudo rm -rf /var/www/$app/install/
|
||||||
|
|
||||||
|
#=================================================
|
||||||
|
# Set permissions
|
||||||
|
#=================================================
|
||||||
|
|
||||||
# file owned by www-data before checking permissions
|
# file owned by www-data before checking permissions
|
||||||
sudo chown www-data:www-data $final_path -R
|
sudo chown www-data:www-data $final_path -R
|
||||||
|
|
||||||
# set database configuration
|
#=================================================
|
||||||
sed -i "s@YNH_WWW_PATH@$path@g" ../conf/nginx.conf
|
# NGINX CONFIGURATION
|
||||||
|
#=================================================
|
||||||
|
|
||||||
# Modify Nginx configuration file and copy it to Nginx conf directory
|
|
||||||
sed -i "s@YNH_WWW_PATH@$path@g" ../conf/nginx.conf
|
sed -i "s@YNH_WWW_PATH@$path@g" ../conf/nginx.conf
|
||||||
sed -i "s@YNH_WWW_ALIAS@$final_path/@g" ../conf/nginx.conf
|
sed -i "s@YNH_WWW_ALIAS@$final_path/@g" ../conf/nginx.conf
|
||||||
sudo sed -i "s@NAMETOCHANGE@$app@g" ../conf/nginx.conf
|
sudo sed -i "s@NAMETOCHANGE@$app@g" ../conf/nginx.conf
|
||||||
|
@ -106,6 +141,10 @@ sudo cp ../conf/nginx.conf $nginxconf
|
||||||
sudo chown root: $nginxconf
|
sudo chown root: $nginxconf
|
||||||
sudo chmod 644 $nginxconf
|
sudo chmod 644 $nginxconf
|
||||||
|
|
||||||
|
#=================================================
|
||||||
|
# PHP-FPM CONFIGURATION
|
||||||
|
#=================================================
|
||||||
|
|
||||||
sudo sed -i "s@NAMETOCHANGE@$app@g" ../conf/php-fpm.conf
|
sudo sed -i "s@NAMETOCHANGE@$app@g" ../conf/php-fpm.conf
|
||||||
sudo sed -i "s@FOLDERTOCHANGE@$final_path@g" ../conf/php-fpm.conf
|
sudo sed -i "s@FOLDERTOCHANGE@$final_path@g" ../conf/php-fpm.conf
|
||||||
finalphpconf=/etc/php5/fpm/pool.d/$app.conf
|
finalphpconf=/etc/php5/fpm/pool.d/$app.conf
|
||||||
|
@ -113,13 +152,24 @@ sudo cp ../conf/php-fpm.conf $finalphpconf
|
||||||
sudo chown root:root $finalphpconf
|
sudo chown root:root $finalphpconf
|
||||||
sudo chmod 644 $finalphpconf
|
sudo chmod 644 $finalphpconf
|
||||||
|
|
||||||
|
#=================================================
|
||||||
|
# SETUP SSOWAT
|
||||||
|
#=================================================
|
||||||
|
|
||||||
ynh_app_setting_set "$app" is_public "$is_public"
|
# Make app private if necessary
|
||||||
if [ "$is_public" = "Yes" ];
|
ynh_app_setting_set $app is_public "$is_public"
|
||||||
|
if [ $is_public -eq 0 ];
|
||||||
then
|
then
|
||||||
ynh_app_setting_set "$app" unprotected_uris "/"
|
# Retire l'autorisation d'accès de la page d'install.
|
||||||
|
ynh_app_setting_delete $app unprotected_uris
|
||||||
|
# Rend la page d'actualisation accessible pour le script cron.
|
||||||
|
ynh_app_setting_get $app skipped_uris "/action.php"
|
||||||
fi
|
fi
|
||||||
|
|
||||||
|
#=================================================
|
||||||
|
# RELOAD NGINX
|
||||||
|
#=================================================
|
||||||
|
|
||||||
sudo service php5-fpm reload
|
sudo service php5-fpm reload
|
||||||
sudo service nginx reload
|
sudo service nginx reload
|
||||||
sudo yunohost app ssowatconf
|
sudo yunohost app ssowatconf
|
||||||
|
|
Loading…
Add table
Reference in a new issue