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:
parent
7d82f846e8
commit
e156919cdb
3 changed files with 18 additions and 13 deletions
|
@ -14,7 +14,7 @@
|
||||||
"name": "julien",
|
"name": "julien",
|
||||||
"email": "julien.malik@paraiso.me"
|
"email": "julien.malik@paraiso.me"
|
||||||
},
|
},
|
||||||
"multi_instance": "false",
|
"multi_instance": "true",
|
||||||
"services": [
|
"services": [
|
||||||
"nginx",
|
"nginx",
|
||||||
"php5-fpm"
|
"php5-fpm"
|
||||||
|
|
|
@ -8,8 +8,10 @@ domain=$1
|
||||||
path=$2
|
path=$2
|
||||||
is_public=$3
|
is_public=$3
|
||||||
|
|
||||||
|
app=$YNH_APP_INSTANCE_NAME
|
||||||
|
|
||||||
# Check domain/path availability
|
# Check domain/path availability
|
||||||
sudo yunohost app checkurl $domain$path -a zerobin
|
sudo yunohost app checkurl $domain$path -a $app
|
||||||
if [[ ! $? -eq 0 ]]; then
|
if [[ ! $? -eq 0 ]]; then
|
||||||
exit 1
|
exit 1
|
||||||
fi
|
fi
|
||||||
|
@ -20,7 +22,7 @@ if [[ ! "$path" == "/" ]]; then
|
||||||
fi
|
fi
|
||||||
|
|
||||||
# Copy files to the right place
|
# Copy files to the right place
|
||||||
final_path=/var/www/zerobin
|
final_path=/var/www/$app
|
||||||
sudo mkdir -p $final_path
|
sudo mkdir -p $final_path
|
||||||
extract_source $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
|
# 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
|
||||||
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 cp ../conf/nginx.conf $nginxconf
|
||||||
sudo chown root: $nginxconf
|
sudo chown root: $nginxconf
|
||||||
sudo chmod 600 $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" ];
|
if [ "$is_public" = "Yes" ];
|
||||||
then
|
then
|
||||||
sudo yunohost app setting zerobin unprotected_uris -v "/"
|
sudo yunohost app setting $app unprotected_uris -v "/"
|
||||||
fi
|
fi
|
||||||
|
|
||||||
sudo service nginx reload
|
sudo service nginx reload
|
||||||
|
|
|
@ -3,9 +3,12 @@
|
||||||
source /usr/share/yunohost/helpers
|
source /usr/share/yunohost/helpers
|
||||||
source ./_common
|
source ./_common
|
||||||
|
|
||||||
domain=$(sudo yunohost app setting zerobin domain)
|
app=$YNH_APP_INSTANCE_NAME
|
||||||
path=$(sudo yunohost app setting zerobin path)
|
|
||||||
is_public=$(sudo yunohost app setting zerobin is_public)
|
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
|
# Remove trailing "/" for next commands
|
||||||
if [[ ! "$path" == "/" ]]; then
|
if [[ ! "$path" == "/" ]]; then
|
||||||
|
@ -13,7 +16,7 @@ if [[ ! "$path" == "/" ]]; then
|
||||||
fi
|
fi
|
||||||
|
|
||||||
# Init final_path, if ever it got deleted somehow
|
# Init final_path, if ever it got deleted somehow
|
||||||
final_path=/var/www/zerobin
|
final_path=/var/www/$app
|
||||||
sudo mkdir -p $final_path
|
sudo mkdir -p $final_path
|
||||||
|
|
||||||
# Clean up
|
# Clean up
|
||||||
|
@ -35,15 +38,15 @@ sudo chmod 700 $final_path/{data,tmp}
|
||||||
# Modify Nginx configuration file and copy it to Nginx conf directory
|
# 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
|
||||||
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 cp ../conf/nginx.conf $nginxconf
|
||||||
sudo chown root: $nginxconf
|
sudo chown root: $nginxconf
|
||||||
sudo chmod 600 $nginxconf
|
sudo chmod 600 $nginxconf
|
||||||
|
|
||||||
if [ "$is_public" = "Yes" ];
|
if [ "$is_public" = "Yes" ];
|
||||||
then
|
then
|
||||||
sudo yunohost app setting zerobin skipped_uris -d
|
sudo yunohost app setting $app skipped_uris -d
|
||||||
sudo yunohost app setting zerobin unprotected_uris -v "/"
|
sudo yunohost app setting $app unprotected_uris -v "/"
|
||||||
fi
|
fi
|
||||||
|
|
||||||
sudo service nginx reload
|
sudo service nginx reload
|
||||||
|
|
Loading…
Reference in a new issue