1
0
Fork 0
mirror of https://github.com/YunoHost-Apps/privatebin_ynh.git synced 2024-09-03 20:15:56 +02:00

Make it multiinstance

This commit is contained in:
Julien Malik 2016-08-24 19:43:33 +02:00
parent 7d82f846e8
commit e156919cdb
3 changed files with 18 additions and 13 deletions

View file

@ -14,7 +14,7 @@
"name": "julien",
"email": "julien.malik@paraiso.me"
},
"multi_instance": "false",
"multi_instance": "true",
"services": [
"nginx",
"php5-fpm"

View file

@ -8,8 +8,10 @@ domain=$1
path=$2
is_public=$3
app=$YNH_APP_INSTANCE_NAME
# Check domain/path availability
sudo yunohost app checkurl $domain$path -a zerobin
sudo yunohost app checkurl $domain$path -a $app
if [[ ! $? -eq 0 ]]; then
exit 1
fi
@ -20,7 +22,7 @@ if [[ ! "$path" == "/" ]]; then
fi
# Copy files to the right place
final_path=/var/www/zerobin
final_path=/var/www/$app
sudo mkdir -p $final_path
extract_source $final_path
@ -37,15 +39,15 @@ sudo chmod 700 $final_path/{data,tmp}
# 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
nginxconf=/etc/nginx/conf.d/$domain.d/zerobin.conf
nginxconf=/etc/nginx/conf.d/$domain.d/$app.conf
sudo cp ../conf/nginx.conf $nginxconf
sudo chown root: $nginxconf
sudo chmod 600 $nginxconf
sudo yunohost app setting zerobin is_public -v "$is_public"
sudo yunohost app setting $app is_public -v "$is_public"
if [ "$is_public" = "Yes" ];
then
sudo yunohost app setting zerobin unprotected_uris -v "/"
sudo yunohost app setting $app unprotected_uris -v "/"
fi
sudo service nginx reload

View file

@ -3,9 +3,12 @@
source /usr/share/yunohost/helpers
source ./_common
domain=$(sudo yunohost app setting zerobin domain)
path=$(sudo yunohost app setting zerobin path)
is_public=$(sudo yunohost app setting zerobin is_public)
app=$YNH_APP_INSTANCE_NAME
domain=$(sudo yunohost app setting $app domain)
path=$(sudo yunohost app setting $app path)
is_public=$(sudo yunohost app setting $app is_public)
# Remove trailing "/" for next commands
if [[ ! "$path" == "/" ]]; then
@ -13,7 +16,7 @@ if [[ ! "$path" == "/" ]]; then
fi
# Init final_path, if ever it got deleted somehow
final_path=/var/www/zerobin
final_path=/var/www/$app
sudo mkdir -p $final_path
# Clean up
@ -35,15 +38,15 @@ sudo chmod 700 $final_path/{data,tmp}
# 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
nginxconf=/etc/nginx/conf.d/$domain.d/zerobin.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 [ "$is_public" = "Yes" ];
then
sudo yunohost app setting zerobin skipped_uris -d
sudo yunohost app setting zerobin unprotected_uris -v "/"
sudo yunohost app setting $app skipped_uris -d
sudo yunohost app setting $app unprotected_uris -v "/"
fi
sudo service nginx reload