mirror of
https://github.com/YunoHost-Apps/jappix_ynh.git
synced 2024-09-03 19:26:19 +02:00
[enh] Update scripts for YunoHost changes in multi-instances apps
This commit is contained in:
parent
0adbd1b203
commit
56f37e362e
6 changed files with 80 additions and 66 deletions
|
@ -11,7 +11,10 @@
|
||||||
"name": "titoko",
|
"name": "titoko",
|
||||||
"email": "titoko@titoko.fr"
|
"email": "titoko@titoko.fr"
|
||||||
},
|
},
|
||||||
"multi_instance": "true",
|
"multi_instance": true,
|
||||||
|
"requirements": {
|
||||||
|
"yunohost": ">= 2.3.14"
|
||||||
|
},
|
||||||
"services": [
|
"services": [
|
||||||
"nginx",
|
"nginx",
|
||||||
"php5-fpm",
|
"php5-fpm",
|
||||||
|
|
|
@ -1,15 +1,15 @@
|
||||||
#!/bin/bash
|
#!/bin/bash
|
||||||
app=jappix
|
|
||||||
|
|
||||||
# The parameter $1 is the backup directory location
|
app=${!#}
|
||||||
# which will be compressed afterward
|
|
||||||
backup_dir=$1/apps/$app
|
|
||||||
mkdir -p $backup_dir
|
|
||||||
|
|
||||||
# Backup sources & data
|
# Retrieve arguments
|
||||||
sudo cp -a /var/www/$app/. $backup_dir/sources
|
backup_dir=$1
|
||||||
|
|
||||||
# Copy Nginx and YunoHost parameters to make the script "standalone"
|
# Retrieve app settings
|
||||||
sudo cp -a /etc/yunohost/apps/$app/. $backup_dir/yunohost
|
domain=$(sudo yunohost app setting "$app" domain)
|
||||||
domain=$(sudo yunohost app setting $app domain)
|
|
||||||
sudo cp -a /etc/nginx/conf.d/$domain.d/$app.conf $backup_dir/nginx.conf
|
# Save sources & data
|
||||||
|
sudo cp -a "/var/www/${app}" ./sources
|
||||||
|
|
||||||
|
# Copy NGINX configuration
|
||||||
|
sudo cp -a "/etc/nginx/conf.d/${domain}.d/${app}.conf" ./nginx.conf
|
||||||
|
|
|
@ -1,7 +1,11 @@
|
||||||
#!/bin/bash
|
#!/bin/bash
|
||||||
|
|
||||||
|
set -e
|
||||||
|
|
||||||
source ./_common.sh
|
source ./_common.sh
|
||||||
|
|
||||||
|
app=${!#}
|
||||||
|
|
||||||
# Retrieve arguments
|
# Retrieve arguments
|
||||||
domain=$1
|
domain=$1
|
||||||
path=$2
|
path=$2
|
||||||
|
@ -9,7 +13,7 @@ name=$3
|
||||||
language=$4
|
language=$4
|
||||||
|
|
||||||
# Check domain/path availability
|
# Check domain/path availability
|
||||||
sudo yunohost app checkurl $domain$path -a jappix
|
sudo yunohost app checkurl "${domain}${path}" -a "$app"
|
||||||
if [[ ! $? -eq 0 ]]; then
|
if [[ ! $? -eq 0 ]]; then
|
||||||
exit 1
|
exit 1
|
||||||
fi
|
fi
|
||||||
|
@ -21,16 +25,16 @@ path=${path%/}
|
||||||
wget -nv -O jappix.tar.gz https://github.com/jappix/jappix/archive/${VERSION}.tar.gz
|
wget -nv -O jappix.tar.gz https://github.com/jappix/jappix/archive/${VERSION}.tar.gz
|
||||||
|
|
||||||
# Copy files to the right place
|
# Copy files to the right place
|
||||||
final_path=/var/www/jappix
|
final_path="/var/www/${app}"
|
||||||
sudo mkdir -p $final_path
|
sudo mkdir -p "${final_path}/store/conf"
|
||||||
sudo tar -C $final_path -xf jappix.tar.gz --strip-components 1
|
sudo tar -C "$final_path" -xf jappix.tar.gz --strip-components 1
|
||||||
sudo cp ../conf/*.xml $final_path/store/conf/
|
sudo cp ../conf/*.xml "${final_path}/store/conf/"
|
||||||
|
|
||||||
# Set permissions to jappix directory
|
# Set permissions to jappix directory
|
||||||
sudo chown -R www-data: $final_path
|
sudo chown -R www-data: "$final_path"
|
||||||
|
|
||||||
# Modify Nginx configuration file and copy it to Nginx conf directory
|
# Modify Nginx configuration file and copy it to Nginx conf directory
|
||||||
sudo sed -i "s@PATHTOCHANGE2@$path@g" ../conf/nginx.conf
|
sudo sed -i "s@PATHTOCHANGE2@${path}@g" ../conf/nginx.conf
|
||||||
|
|
||||||
if [ -z "$path" ]; then
|
if [ -z "$path" ]; then
|
||||||
path="/"
|
path="/"
|
||||||
|
@ -42,19 +46,18 @@ then
|
||||||
language="en"
|
language="en"
|
||||||
fi
|
fi
|
||||||
|
|
||||||
sudo yunohost app setting jappix name -v $name
|
sudo yunohost app setting "$app" name -v "$name"
|
||||||
sudo yunohost app setting jappix language -v $language
|
sudo yunohost app setting "$app" language -v "$language"
|
||||||
|
|
||||||
sudo sed -i "s@PATHTOCHANGE@$path@g" ../conf/nginx.conf
|
sudo sed -i "s@PATHTOCHANGE@${path}@g" ../conf/nginx.conf
|
||||||
sudo sed -i "s@ALIASTOCHANGE@$final_path/@g" ../conf/nginx.conf
|
sudo sed -i "s@ALIASTOCHANGE@${final_path}/@g" ../conf/nginx.conf
|
||||||
sudo cp ../conf/nginx.conf /etc/nginx/conf.d/$domain.d/jappix.conf
|
sudo cp ../conf/nginx.conf "/etc/nginx/conf.d/${domain}.d/${app}.conf"
|
||||||
sudo sed -i "s@PATHTOCHANGE@$path@g" $final_path/store/conf/main.xml
|
sudo sed -i "s@PATHTOCHANGE@${path}@g" "${final_path}/store/conf/main.xml"
|
||||||
sudo sed -i "s@PATHTOCHANGE@$path@g" $final_path/store/conf/hosts.xml
|
sudo sed -i "s@PATHTOCHANGE@${path}@g" "${final_path}/store/conf/hosts.xml"
|
||||||
sudo sed -i "s@DOMAINTOCHANGE@$domain@g" $final_path/store/conf/main.xml
|
sudo sed -i "s@DOMAINTOCHANGE@${domain}@g" "${final_path}/store/conf/main.xml"
|
||||||
sudo sed -i "s@CHANGELANG@$language@g" $final_path/store/conf/main.xml
|
sudo sed -i "s@CHANGELANG@${language}@g" "${final_path}/store/conf/main.xml"
|
||||||
sudo sed -i "s@CHANGENAME@$name@g" $final_path/store/conf/main.xml
|
sudo sed -i "s@CHANGENAME@${name}@g" "${final_path}/store/conf/main.xml"
|
||||||
sudo sed -i "s@DOMAINTOCHANGE@$domain@g" $final_path/store/conf/hosts.xml
|
sudo sed -i "s@DOMAINTOCHANGE@${domain}@g" "${final_path}/store/conf/hosts.xml"
|
||||||
|
|
||||||
# Reload Nginx and regenerate SSOwat conf
|
# Reload services
|
||||||
sudo service nginx reload
|
sudo service nginx reload
|
||||||
sudo yunohost app ssowatconf
|
|
||||||
|
|
|
@ -1,8 +1,13 @@
|
||||||
#!/bin/bash
|
#!/bin/bash
|
||||||
domain=$(sudo yunohost app setting jappix domain)
|
|
||||||
|
|
||||||
sudo rm -rf /var/www/jappix
|
app=${!#}
|
||||||
sudo rm -f /etc/nginx/conf.d/$domain.d/jappix.conf
|
|
||||||
|
|
||||||
|
# Retrieve arguments
|
||||||
|
domain=$(sudo yunohost app setting "$app" domain)
|
||||||
|
|
||||||
|
# Remove sources and configuration
|
||||||
|
sudo rm -rf "/var/www/${app}"
|
||||||
|
sudo rm -f "/etc/nginx/conf.d/${domain}.d/${app}.conf"
|
||||||
|
|
||||||
|
# Reload services
|
||||||
sudo service nginx reload
|
sudo service nginx reload
|
||||||
sudo yunohost app ssowatconf
|
|
||||||
|
|
|
@ -1,16 +1,18 @@
|
||||||
#!/bin/bash
|
#!/bin/bash
|
||||||
app=jappix
|
|
||||||
|
|
||||||
# The parameter $1 is the uncompressed restore directory location
|
app=${!#}
|
||||||
backup_dir=$1/apps/$app
|
|
||||||
|
# Retrieve arguments
|
||||||
|
backup_dir=$1
|
||||||
|
|
||||||
|
# Retrieve old app settings
|
||||||
|
domain=$(sudo yunohost app setting "$app" domain)
|
||||||
|
|
||||||
# Restore sources & data
|
# Restore sources & data
|
||||||
sudo cp -a $backup_dir/sources/. /var/www/$app
|
sudo cp -a ./sources "/var/www/${app}"
|
||||||
|
|
||||||
# Restore Nginx and YunoHost parameters
|
# Restore Nginx and YunoHost parameters
|
||||||
sudo cp -a $backup_dir/yunohost/. /etc/yunohost/apps/$app
|
sudo cp -a ./nginx.conf "/etc/nginx/conf.d/${domain}.d/${app}.conf"
|
||||||
domain=$(sudo yunohost app setting $app domain)
|
|
||||||
sudo cp -a $backup_dir/nginx.conf /etc/nginx/conf.d/$domain.d/$app.conf
|
|
||||||
|
|
||||||
# Restart webserver
|
# Reload services
|
||||||
sudo service nginx reload
|
sudo service nginx reload
|
||||||
|
|
|
@ -2,11 +2,13 @@
|
||||||
|
|
||||||
source ./_common.sh
|
source ./_common.sh
|
||||||
|
|
||||||
|
app=${!#}
|
||||||
|
|
||||||
# Retrieve arguments
|
# Retrieve arguments
|
||||||
domain=$(sudo yunohost app setting jappix domain)
|
domain=$(sudo yunohost app setting "$app" domain)
|
||||||
path=$(sudo yunohost app setting jappix path)
|
path=$(sudo yunohost app setting "$app" path)
|
||||||
name=$(sudo yunohost app setting jappix name)
|
name=$(sudo yunohost app setting "$app" name)
|
||||||
language=$(sudo yunohost app setting jappix language)
|
language=$(sudo yunohost app setting "$app" language)
|
||||||
|
|
||||||
if [[ "$name" = "" ]];
|
if [[ "$name" = "" ]];
|
||||||
then
|
then
|
||||||
|
@ -24,31 +26,30 @@ path=${path%/}
|
||||||
wget -nv -O jappix.tar.gz https://github.com/jappix/jappix/archive/${VERSION}.tar.gz
|
wget -nv -O jappix.tar.gz https://github.com/jappix/jappix/archive/${VERSION}.tar.gz
|
||||||
|
|
||||||
# Copy files to the right place
|
# Copy files to the right place
|
||||||
final_path=/var/www/jappix
|
final_path="/var/www/${app}"
|
||||||
sudo mkdir -p $final_path
|
sudo mkdir -p "$final_path"
|
||||||
sudo tar -C $final_path -xf jappix.tar.gz --strip-components 1
|
sudo tar -C "$final_path" -xf jappix.tar.gz --strip-components 1
|
||||||
sudo cp ../conf/*.xml $final_path/store/conf/
|
sudo cp ../conf/*.xml "${final_path}/store/conf/"
|
||||||
|
|
||||||
# Set permissions to jappix directory
|
# Set permissions to jappix directory
|
||||||
sudo chown -R www-data: $final_path
|
sudo chown -R www-data: "$final_path"
|
||||||
|
|
||||||
# Modify Nginx configuration file and copy it to Nginx conf directory
|
# Modify Nginx configuration file and copy it to Nginx conf directory
|
||||||
sudo sed -i "s@PATHTOCHANGE2@$path@g" ../conf/nginx.conf
|
sudo sed -i "s@PATHTOCHANGE2@${path}@g" ../conf/nginx.conf
|
||||||
|
|
||||||
if [ -z "$path" ]; then
|
if [ -z "$path" ]; then
|
||||||
path="/"
|
path="/"
|
||||||
fi
|
fi
|
||||||
|
|
||||||
sudo sed -i "s@PATHTOCHANGE@$path@g" ../conf/nginx.conf
|
sudo sed -i "s@PATHTOCHANGE@${path}@g" ../conf/nginx.conf
|
||||||
sudo sed -i "s@ALIASTOCHANGE@$final_path/@g" ../conf/nginx.conf
|
sudo sed -i "s@ALIASTOCHANGE@${final_path}/@g" ../conf/nginx.conf
|
||||||
sudo cp ../conf/nginx.conf /etc/nginx/conf.d/$domain.d/jappix.conf
|
sudo cp ../conf/nginx.conf "/etc/nginx/conf.d/${domain}.d/${app}.conf"
|
||||||
sudo sed -i "s@PATHTOCHANGE@$path@g" $final_path/store/conf/main.xml
|
sudo sed -i "s@PATHTOCHANGE@${path}@g" "${final_path}/store/conf/main.xml"
|
||||||
sudo sed -i "s@PATHTOCHANGE@$path@g" $final_path/store/conf/hosts.xml
|
sudo sed -i "s@PATHTOCHANGE@${path}@g" "${final_path}/store/conf/hosts.xml"
|
||||||
sudo sed -i "s@DOMAINTOCHANGE@$domain@g" $final_path/store/conf/main.xml
|
sudo sed -i "s@DOMAINTOCHANGE@${domain}@g" "${final_path}/store/conf/main.xml"
|
||||||
sudo sed -i "s@CHANGELANG@$language@g" $final_path/store/conf/main.xml
|
sudo sed -i "s@CHANGELANG@${language}@g" "${final_path}/store/conf/main.xml"
|
||||||
sudo sed -i "s@CHANGENAME@$name@g" $final_path/store/conf/main.xml
|
sudo sed -i "s@CHANGENAME@${name}@g" "${final_path}/store/conf/main.xml"
|
||||||
sudo sed -i "s@DOMAINTOCHANGE@$domain@g" $final_path/store/conf/hosts.xml
|
sudo sed -i "s@DOMAINTOCHANGE@${domain}@g" "${final_path}/store/conf/hosts.xml"
|
||||||
|
|
||||||
# Reload Nginx and regenerate SSOwat conf
|
# Reload services
|
||||||
sudo service nginx reload
|
sudo service nginx reload
|
||||||
sudo yunohost app ssowatconf
|
|
||||||
|
|
Loading…
Reference in a new issue