mirror of
https://github.com/YunoHost-Apps/jirafeau_ynh.git
synced 2024-09-03 19:35:53 +02:00
[enh] Update scripts with env var (install, upgrade, remove).
This commit is contained in:
parent
ece4623927
commit
824dfa748b
3 changed files with 75 additions and 32 deletions
|
@ -1,14 +1,29 @@
|
||||||
#!/bin/bash
|
#!/bin/bash
|
||||||
|
|
||||||
|
# causes the shell to exit if any subcommand or pipeline returns a non-zero status
|
||||||
|
set -e
|
||||||
|
|
||||||
|
# This is a multi-instance app, meaning it can be installed several times independently
|
||||||
|
# The id of the app as stated in the manifest is available as $YNH_APP_ID
|
||||||
|
# The instance number is available as $YNH_APP_INSTANCE_NUMBER (equals "1", "2", ...)
|
||||||
|
# The app instance name is available as $YNH_APP_INSTANCE_NAME
|
||||||
|
# - the first time the app is installed, YNH_APP_INSTANCE_NAME = ynhexample
|
||||||
|
# - the second time the app is installed, YNH_APP_INSTANCE_NAME = ynhexample__2
|
||||||
|
# - ynhexample__{N} for the subsequent installations, with N=3,4, ...
|
||||||
|
# The app instance name is probably what you are interested the most, since this is
|
||||||
|
# guaranteed to be unique. This is a good unique identifier to define installation path,
|
||||||
|
# db names, ...
|
||||||
|
app=$YNH_APP_INSTANCE_NAME
|
||||||
|
|
||||||
# Retrieve arguments
|
# Retrieve arguments
|
||||||
domain=$1
|
domain=$YNH_APP_ARG_DOMAIN
|
||||||
path=$2
|
path=$YNH_APP_ARG_PATH
|
||||||
admin_user=$3
|
admin_user=$YNH_APP_ARG_ADMIN_USER
|
||||||
upload_password=$4
|
upload_password=$YNH_APP_ARG_UPLOAD_PASSWORD
|
||||||
is_public=$5
|
is_public=$YNH_APP_ARG_IS_PUBLIC
|
||||||
|
|
||||||
# Check domain/path availability
|
# Check domain/path availability
|
||||||
sudo yunohost app checkurl $domain$path -a jirafeau
|
sudo yunohost app checkurl $domain$path -a $app
|
||||||
if [[ ! $? -eq 0 ]]; then
|
if [[ ! $? -eq 0 ]]; then
|
||||||
exit 1
|
exit 1
|
||||||
fi
|
fi
|
||||||
|
@ -24,21 +39,21 @@ if [[ ! $? -eq 0 ]]; then
|
||||||
fi
|
fi
|
||||||
|
|
||||||
# Save specific settings
|
# Save specific settings
|
||||||
sudo yunohost app setting jirafeau admin_user -v $admin_user
|
sudo yunohost app setting $app admin_user -v $admin_user
|
||||||
sudo yunohost app setting jirafeau is_public -v $is_public
|
sudo yunohost app setting $app is_public -v $is_public
|
||||||
|
|
||||||
# Set and save upload password, allowing an empty one
|
# Set and save upload password, allowing an empty one
|
||||||
if [[ -z "$upload_password" ]]; then
|
if [[ -z "$upload_password" ]]; then
|
||||||
sed -i "s@YNH_UPLOAD_PASSWORD@@g" ../conf/config.local.php
|
sed -i "s@YNH_UPLOAD_PASSWORD@@g" ../conf/config.local.php
|
||||||
sudo yunohost app setting jirafeau upload_password -v ''
|
sudo yunohost app setting $app upload_password -v ''
|
||||||
else
|
else
|
||||||
sed -i "s@YNH_UPLOAD_PASSWORD@'$upload_password'@g" ../conf/config.local.php
|
sed -i "s@YNH_UPLOAD_PASSWORD@'$upload_password'@g" ../conf/config.local.php
|
||||||
sudo yunohost app setting jirafeau upload_password -v "$upload_password"
|
sudo yunohost app setting $app upload_password -v "$upload_password"
|
||||||
fi
|
fi
|
||||||
|
|
||||||
# Copy files to the right place
|
# Copy files to the right place
|
||||||
final_path=/var/www/jirafeau
|
final_path=/var/www/$app
|
||||||
var_root=/home/yunohost.app/jirafeau
|
var_root=/home/yunohost.app/$app
|
||||||
sudo mkdir -p $final_path
|
sudo mkdir -p $final_path
|
||||||
sudo cp -r ../sources/* $final_path
|
sudo cp -r ../sources/* $final_path
|
||||||
sed -i "s@YNH_DOMAIN@$domain@g" ../conf/config.local.php
|
sed -i "s@YNH_DOMAIN@$domain@g" ../conf/config.local.php
|
||||||
|
@ -65,20 +80,20 @@ if [[ "$path" == "" ]]; then
|
||||||
else
|
else
|
||||||
sed -i "s@YNH_WWW_LOCATION@$path@g" ../conf/nginx.conf
|
sed -i "s@YNH_WWW_LOCATION@$path@g" ../conf/nginx.conf
|
||||||
fi
|
fi
|
||||||
nginxconf=/etc/nginx/conf.d/$domain.d/jirafeau.conf
|
nginxconf=/etc/nginx/conf.d/$domain.d/$app.conf
|
||||||
sudo cp ../conf/nginx.conf $nginxconf
|
sudo cp ../conf/nginx.conf $nginxconf
|
||||||
sudo chown root: $nginxconf
|
sudo chown root: $nginxconf
|
||||||
sudo chmod 600 $nginxconf
|
sudo chmod 600 $nginxconf
|
||||||
|
|
||||||
sed -i "s@NAMETOCHANGE@jirafeau@g" ../conf/php-fpm.conf
|
sed -i "s@NAMETOCHANGE@$app@g" ../conf/php-fpm.conf
|
||||||
finalphpconf=/etc/php5/fpm/pool.d/jirafeau.conf
|
finalphpconf=/etc/php5/fpm/pool.d/$app.conf
|
||||||
sudo cp ../conf/php-fpm.conf $finalphpconf
|
sudo cp ../conf/php-fpm.conf $finalphpconf
|
||||||
sudo chown root: $finalphpconf
|
sudo chown root: $finalphpconf
|
||||||
sudo chmod 644 $finalphpconf
|
sudo chmod 644 $finalphpconf
|
||||||
|
|
||||||
if [ "$is_public" = "Yes" ];
|
if [ "$is_public" = "Yes" ];
|
||||||
then
|
then
|
||||||
sudo yunohost app setting jirafeau unprotected_uris -v "/"
|
sudo yunohost app setting $app unprotected_uris -v "/"
|
||||||
fi
|
fi
|
||||||
|
|
||||||
sudo service php5-fpm restart
|
sudo service php5-fpm restart
|
||||||
|
|
|
@ -1,11 +1,23 @@
|
||||||
#!/bin/bash
|
#!/bin/bash
|
||||||
|
|
||||||
domain=$(sudo yunohost app setting jirafeau domain)
|
# This is a multi-instance app, meaning it can be installed several times independently
|
||||||
|
# The id of the app as stated in the manifest is available as $YNH_APP_ID
|
||||||
|
# The instance number is available as $YNH_APP_INSTANCE_NUMBER (equals "1", "2", ...)
|
||||||
|
# The app instance name is available as $YNH_APP_INSTANCE_NAME
|
||||||
|
# - the first time the app is installed, YNH_APP_INSTANCE_NAME = ynhexample
|
||||||
|
# - the second time the app is installed, YNH_APP_INSTANCE_NAME = ynhexample__2
|
||||||
|
# - ynhexample__{N} for the subsequent installations, with N=3,4, ...
|
||||||
|
# The app instance name is probably what you are interested the most, since this is
|
||||||
|
# guaranteed to be unique. This is a good unique identifier to define installation path,
|
||||||
|
# db names, ...
|
||||||
|
app=$YNH_APP_INSTANCE_NAME
|
||||||
|
|
||||||
sudo rm -rf /home/yunohost.app/jirafeau
|
domain=$(sudo yunohost app setting $app domain)
|
||||||
sudo rm -rf /var/www/jirafeau
|
|
||||||
sudo rm -f /etc/nginx/conf.d/$domain.d/jirafeau.conf
|
sudo rm -rf /home/yunohost.app/$app
|
||||||
sudo rm -f /etc/php5/fpm/pool.d/jirafeau.conf
|
sudo rm -rf /var/www/$app
|
||||||
|
sudo rm -f /etc/nginx/conf.d/$domain.d/$app.conf
|
||||||
|
sudo rm -f /etc/php5/fpm/pool.d/$app.conf
|
||||||
|
|
||||||
sudo service php5-fpm restart
|
sudo service php5-fpm restart
|
||||||
sudo service nginx reload
|
sudo service nginx reload
|
||||||
|
|
|
@ -1,10 +1,26 @@
|
||||||
#!/bin/bash
|
#!/bin/bash
|
||||||
|
|
||||||
domain=$(sudo yunohost app setting jirafeau domain)
|
# causes the shell to exit if any subcommand or pipeline returns a non-zero status
|
||||||
path=$(sudo yunohost app setting jirafeau path)
|
set -e
|
||||||
admin_user=$(sudo yunohost app setting jirafeau admin_user)
|
|
||||||
upload_password=$(sudo yunohost app setting jirafeau upload_password)
|
# This is a multi-instance app, meaning it can be installed several times independently
|
||||||
is_public=$(sudo yunohost app setting jirafeau is_public)
|
# The id of the app as stated in the manifest is available as $YNH_APP_ID
|
||||||
|
# The instance number is available as $YNH_APP_INSTANCE_NUMBER (equals "1", "2", ...)
|
||||||
|
# The app instance name is available as $YNH_APP_INSTANCE_NAME
|
||||||
|
# - the first time the app is installed, YNH_APP_INSTANCE_NAME = ynhexample
|
||||||
|
# - the second time the app is installed, YNH_APP_INSTANCE_NAME = ynhexample__2
|
||||||
|
# - ynhexample__{N} for the subsequent installations, with N=3,4, ...
|
||||||
|
# The app instance name is probably what you are interested the most, since this is
|
||||||
|
# guaranteed to be unique. This is a good unique identifier to define installation path,
|
||||||
|
# db names, ...
|
||||||
|
app=$YNH_APP_INSTANCE_NAME
|
||||||
|
|
||||||
|
# Retrieve arguments
|
||||||
|
domain=$YNH_APP_ARG_DOMAIN
|
||||||
|
path=$YNH_APP_ARG_PATH
|
||||||
|
admin_user=$YNH_APP_ARG_ADMIN_USER
|
||||||
|
upload_password=$YNH_APP_ARG_UPLOAD_PASSWORD
|
||||||
|
is_public=$YNH_APP_ARG_IS_PUBLIC
|
||||||
|
|
||||||
# Remove trailing "/" for next commands
|
# Remove trailing "/" for next commands
|
||||||
path=${path%/}
|
path=${path%/}
|
||||||
|
@ -17,8 +33,8 @@ else
|
||||||
fi
|
fi
|
||||||
|
|
||||||
# Copy files to the right place
|
# Copy files to the right place
|
||||||
final_path=/var/www/jirafeau
|
final_path=/var/www/$app
|
||||||
var_root=/home/yunohost.app/jirafeau
|
var_root=/home/yunohost.app/$app
|
||||||
sudo mkdir -p $final_path
|
sudo mkdir -p $final_path
|
||||||
sudo rm -rf $final_path/*
|
sudo rm -rf $final_path/*
|
||||||
sudo cp -r ../sources/* $final_path
|
sudo cp -r ../sources/* $final_path
|
||||||
|
@ -46,20 +62,20 @@ else
|
||||||
fi
|
fi
|
||||||
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
|
||||||
nginxconf=/etc/nginx/conf.d/$domain.d/jirafeau.conf
|
nginxconf=/etc/nginx/conf.d/$domain.d/$app.conf
|
||||||
sudo cp ../conf/nginx.conf $nginxconf
|
sudo cp ../conf/nginx.conf $nginxconf
|
||||||
sudo chown root: $nginxconf
|
sudo chown root: $nginxconf
|
||||||
sudo chmod 600 $nginxconf
|
sudo chmod 600 $nginxconf
|
||||||
|
|
||||||
sed -i "s@NAMETOCHANGE@jirafeau@g" ../conf/php-fpm.conf
|
sed -i "s@NAMETOCHANGE@$app@g" ../conf/php-fpm.conf
|
||||||
finalphpconf=/etc/php5/fpm/pool.d/jirafeau.conf
|
finalphpconf=/etc/php5/fpm/pool.d/$app.conf
|
||||||
sudo cp ../conf/php-fpm.conf $finalphpconf
|
sudo cp ../conf/php-fpm.conf $finalphpconf
|
||||||
sudo chown root: $finalphpconf
|
sudo chown root: $finalphpconf
|
||||||
sudo chmod 644 $finalphpconf
|
sudo chmod 644 $finalphpconf
|
||||||
|
|
||||||
if [ "$is_public" = "Yes" ];
|
if [ "$is_public" = "Yes" ];
|
||||||
then
|
then
|
||||||
sudo yunohost app setting jirafeau unprotected_uris -v "/"
|
sudo yunohost app setting $app unprotected_uris -v "/"
|
||||||
fi
|
fi
|
||||||
|
|
||||||
sudo service php5-fpm restart
|
sudo service php5-fpm restart
|
||||||
|
|
Loading…
Reference in a new issue