mirror of
https://github.com/YunoHost-Apps/hubzilla_ynh.git
synced 2024-09-03 19:26:21 +02:00
Cleaning of Upgrade script
This commit is contained in:
parent
28f50b6e67
commit
4ffa2e3393
1 changed files with 64 additions and 18 deletions
|
@ -1,32 +1,78 @@
|
|||
#!/bin/bash
|
||||
app=hubzilla
|
||||
|
||||
# Retrieve arguments
|
||||
domain=$(sudo yunohost app setting $app domain)
|
||||
path=$(sudo yunohost app setting $app path)
|
||||
admin=$(sudo yunohost app setting $app admin)
|
||||
source .fonctions # Charge les fonctions génériques habituellement utilisées dans le script
|
||||
|
||||
# Remove trailing "/" for next commands
|
||||
path=${path%/}
|
||||
# Récupère les infos de l'application.
|
||||
app=$YNH_APP_INSTANCE_NAME
|
||||
|
||||
# Copy source files
|
||||
final_path=/var/www/$app
|
||||
sudo mkdir -p $final_path
|
||||
sudo rsync -va ../sources/ $final_path/
|
||||
# Source app helpers
|
||||
source /usr/share/yunohost/helpers
|
||||
|
||||
domain=$(ynh_app_setting_get $app domain)
|
||||
path=$(ynh_app_setting_get $app path)
|
||||
admin=$(ynh_app_setting_get $app admin)
|
||||
final_path=$(ynh_app_setting_get $app final_path)
|
||||
db_pwd=$(ynh_app_setting_get $app db_pwd)
|
||||
db_user=$(ynh_app_setting_get $app db_user)
|
||||
email=$(ynh_app_setting_get $app email)
|
||||
upload=$(ynh_app_setting_get $app upload)
|
||||
|
||||
CHECK_PATH # Vérifie et corrige la syntaxe du path.
|
||||
|
||||
# We download the sources and check the md5sum
|
||||
# 1 - hubzilla
|
||||
hubzilla_file=`sudo cat ../sources/hubzilla/source_file`;
|
||||
sudo wget -nv -i ../sources/hubzilla/source_url -O $hubzilla_file
|
||||
sudo md5sum -c ../sources/hubzilla/source_md5 --status || (echo "Corrupt source" >&2 && false)
|
||||
sudo unzip ${hubzilla_file} -d $final_path
|
||||
# 2 - Addons
|
||||
addons_file=`sudo cat ../sources/hubzilla-addons/source_file`;
|
||||
sudo wget -nv -i ../sources/hubzilla-addons/source_url -O $addons_file
|
||||
sudo md5sum -c ../sources/hubzilla-addons/source_md5 --status || (echo "Corrupt source" >&2 && false)
|
||||
sudo unzip ${addons_file} -d $final_path/addon
|
||||
# 3 - some extra folders
|
||||
sudo mkdir -p "${final_path}/store/[data]/smarty3"
|
||||
sudo chmod -R 777 $final_path/store
|
||||
|
||||
# Copy the template install/htconfig.sample.php to .htconfig.php
|
||||
sudo cp $final_path/install/htconfig.sample.php $final_path/.htconfig.php
|
||||
|
||||
# Use sed to add the database information to .htconfig.php
|
||||
sudo sed -i "s/your.mysqlhost.com/localhost/g" $final_path/.htconfig.php
|
||||
sudo sed -i "s/mysqlpassword/$db_pwd/g" $final_path/.htconfig.php
|
||||
sudo sed -i "s/mysqlusername/$db_user/g" $final_path/.htconfig.php
|
||||
sudo sed -i "s/mysqldatabasename/$db_user/g" $final_path/.htconfig.php
|
||||
sudo sed -i "s/mysite.example/$domain/g" $final_path/.htconfig.php
|
||||
sudo sed -i "s/if the auto install failed, put a unique random string here/$(ynh_string_random)$(ynh_string_random)$(ynh_string_random)/g" $final_path/.htconfig.php
|
||||
sudo sed -i "s/ADMIN_EMAIL_REPLACE/$email/g" $final_path/.htconfig.php
|
||||
|
||||
# Set www-data to owner
|
||||
sudo chown -R www-data: $final_path
|
||||
sudo chown -R www-data:www-data $final_path
|
||||
|
||||
# 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 cp ../conf/nginx.conf /etc/nginx/conf.d/$domain.d/$app.conf
|
||||
sed -i "s@YNH_WWW_ALIAS@$final_path@g" ../conf/nginx.conf
|
||||
nginxconf=/etc/nginx/conf.d/$domain.d/$app.conf
|
||||
sudo cp ../conf/nginx.conf $nginxconf
|
||||
sudo chown root: $nginxconf
|
||||
sudo chmod 600 $nginxconf
|
||||
|
||||
# If app is public, add url to SSOWat conf as skipped_uris
|
||||
sudo yunohost app setting $app skipped_uris -v "/"
|
||||
# Modify php.ini to allow exec() function and increase the upload size limits
|
||||
#sudo sed -i 's/,pcntl_exec//g' /etc/php5/fpm/php.ini
|
||||
sed -i "s@UPLOADTOCHANGE@$upload@g" ../conf/php-fpm.conf
|
||||
phpfpmconf=/etc/php5/fpm/pool.d/$app.conf
|
||||
sudo cp ../conf/php-fpm.conf $phpfpmconf
|
||||
sudo chown root: $phpfpmconf
|
||||
|
||||
# Set up poller
|
||||
sed -i "s@YNH_WWW_PATH@$final_path@g" ../conf/poller-cron
|
||||
sudo cp ../conf/poller-cron /etc/cron.d/$app
|
||||
|
||||
# Restart services
|
||||
sudo service nginx reload
|
||||
# Enable api for client and make app public
|
||||
ynh_app_setting_set $app skipped_uris "/"
|
||||
|
||||
# Reload services
|
||||
sudo service php5-fpm restart || true
|
||||
sudo service nginx reload || true
|
||||
sudo yunohost app ssowatconf
|
||||
|
||||
|
|
Loading…
Add table
Reference in a new issue