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
|
||||
|
||||
source ./_common
|
||||
source .fonctions
|
||||
set -eu
|
||||
source /usr/share/yunohost/helpers
|
||||
#=================================================
|
||||
# GENERIC STARTING
|
||||
#=================================================
|
||||
# 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
|
||||
|
||||
# Retrieve arguments
|
||||
domain=$YNH_APP_ARG_DOMAIN
|
||||
path=$YNH_APP_ARG_PATH
|
||||
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_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.
|
||||
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é.
|
||||
|
||||
# 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
|
||||
#=================================================
|
||||
ynh_package_install_from_equivs ../conf/abantecart-deps.control \
|
||||
|| ynh_die "Unable to install dependencies"
|
||||
|
||||
#=================================================
|
||||
# Check password strength
|
||||
#=================================================
|
||||
|
||||
[[ ${#admin_pass} -gt 5 ]] || ynh_die \
|
||||
"The password is too weak, it must be longer than 5 characters"
|
||||
|
||||
# Save app settings
|
||||
#=================================================
|
||||
# STORE SETTINGS FROM MANIFEST
|
||||
#=================================================
|
||||
|
||||
user="$app"
|
||||
ynh_app_setting_set "$app" is_public "$is_public"
|
||||
ynh_app_setting_set "$app" admin_pass "$admin_pass"
|
||||
ynh_app_setting_set "$app" admin_name "$admin_name"
|
||||
ynh_app_setting_set "$app" admin_email "$admin_email"
|
||||
|
||||
#=================================================
|
||||
# Initialize database as needed
|
||||
#=================================================
|
||||
|
||||
db_name=$app
|
||||
db_user=$app
|
||||
|
@ -51,28 +74,32 @@ db_pass=$(ynh_string_random)
|
|||
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_pass "$db_pass"
|
||||
ynh_app_setting_set "$app" db_user "$db_user"
|
||||
|
||||
# Remove trailing "/" for next commands
|
||||
if [[ ! "$path" == "/" ]]; then
|
||||
path=${path%/}
|
||||
fi
|
||||
#=================================================
|
||||
# DOWNLOAD, CHECK AND UNPACK SOURCE
|
||||
#=================================================
|
||||
|
||||
# Copy files to the right place
|
||||
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
|
||||
sudo md5sum -c ../sources/source_md5 --status || (echo "Corrupt source" >&2 && false)
|
||||
sudo tar xvf ${SFILE}.tar.gz -C ../sources/
|
||||
sudo cp -a ../sources/abantecart-src-master/. $final_path
|
||||
|
||||
#=================================================
|
||||
# SPECIFIC SETUP
|
||||
#=================================================
|
||||
# Cleaning
|
||||
#=================================================
|
||||
|
||||
sudo rm -rf $final_path/tests
|
||||
sudo rm -rf $final_path/install.txt
|
||||
sudo mv $final_path/public_html/* $final_path/
|
||||
sudo rm -rf $final_path/public_html
|
||||
|
||||
#=================================================
|
||||
# CLI installation
|
||||
#=================================================
|
||||
|
||||
pushd $final_path/install/
|
||||
sudo php cli_install.php install \
|
||||
--db_host=localhost \
|
||||
|
@ -89,15 +116,23 @@ sudo php cli_install.php install \
|
|||
--admin_path=admin
|
||||
popd
|
||||
|
||||
#=================================================
|
||||
# Cleaning
|
||||
#=================================================
|
||||
|
||||
sudo rm -rf /var/www/$app/install/
|
||||
|
||||
#=================================================
|
||||
# Set permissions
|
||||
#=================================================
|
||||
|
||||
# file owned by www-data before checking permissions
|
||||
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_ALIAS@$final_path/@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 chmod 644 $nginxconf
|
||||
|
||||
#=================================================
|
||||
# PHP-FPM CONFIGURATION
|
||||
#=================================================
|
||||
|
||||
sudo sed -i "s@NAMETOCHANGE@$app@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
|
||||
|
@ -113,13 +152,24 @@ sudo cp ../conf/php-fpm.conf $finalphpconf
|
|||
sudo chown root:root $finalphpconf
|
||||
sudo chmod 644 $finalphpconf
|
||||
|
||||
#=================================================
|
||||
# SETUP SSOWAT
|
||||
#=================================================
|
||||
|
||||
ynh_app_setting_set "$app" is_public "$is_public"
|
||||
if [ "$is_public" = "Yes" ];
|
||||
# Make app private if necessary
|
||||
ynh_app_setting_set $app is_public "$is_public"
|
||||
if [ $is_public -eq 0 ];
|
||||
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
|
||||
|
||||
#=================================================
|
||||
# RELOAD NGINX
|
||||
#=================================================
|
||||
|
||||
sudo service php5-fpm reload
|
||||
sudo service nginx reload
|
||||
sudo yunohost app ssowatconf
|
||||
|
|
Loading…
Reference in a new issue