1
0
Fork 0
mirror of https://github.com/YunoHost-Apps/bozon_ynh.git synced 2024-09-03 18:16:09 +02:00

move data folders

This commit is contained in:
ewilly 2016-04-05 20:03:26 +02:00
parent dea03fc81c
commit 91e055ffe3
5 changed files with 46 additions and 46 deletions

View file

@ -7,15 +7,16 @@ set -e
app=bozon app=bozon
parent_path=/var/www parent_path=/var/www
final_path=$parent_path/$app final_path=$parent_path/$app
data_path=/home/yunohost.app/$app
#retrieve arguments #retrieve arguments
save_path=$1 save_path=$1
domain=$(sudo yunohost app setting $app domain) domain=$(sudo yunohost app setting $app domain)
# Backup sources & data # backup sources & data
sudo cp -R $final_path $save_path/$app sudo cp -R $final_path/. $save_path/www/
sudo cp -R $data_path/. $save_path/datas/
# Copy Nginx and YunoHost parameters to make the script "standalone" # backup Nginx and YunoHost parameters
sudo cp -a /etc/yunohost/apps/$app/. $save_path/yunohost sudo cp -a /etc/yunohost/apps/$app/. $save_path/yunohost/
sudo cp -a /etc/nginx/conf.d/$domain.d/$app.conf $save_path/nginx.conf sudo cp -a /etc/nginx/conf.d/$domain.d/$app.conf $save_path/nginx.conf

View file

@ -3,7 +3,7 @@
# causes the shell to exit if any subcommand or pipeline returns a non-zero status # causes the shell to exit if any subcommand or pipeline returns a non-zero status
set -e set -e
#retrieve arguments # retrieve arguments
domain=$1 domain=$1
path=$2 path=$2
admin=$3 admin=$3
@ -14,74 +14,77 @@ default_lang=$5
app=bozon app=bozon
parent_path=/var/www parent_path=/var/www
final_path=$parent_path/$app final_path=$parent_path/$app
data_path=/home/yunohost.app/$app
# Remove trailing slash # remove trailing slash
[ "$path" != "/" ] && path=${path%/} [ "$path" != "/" ] && path=${path%/}
# Check domain/path availability # check domain/path availability
sudo yunohost app checkurl $domain$path -a $app sudo yunohost app checkurl $domain$path -a $app
if [[ ! $? -eq 0 ]]; then if [[ ! $? -eq 0 ]]; then
exit 1 exit 1
fi fi
# Check user # check user
sudo yunohost user list --json | grep -q "\"username\": \"$admin\"" sudo yunohost user list --json | grep -q "\"username\": \"$admin\""
if [[ ! $? -eq 0 ]]; then if [[ ! $? -eq 0 ]]; then
echo "Wrong user" echo "Wrong user"
exit 1 exit 1
fi fi
# Save app settings # save app settings
sudo yunohost app setting $app admin -v "$admin" sudo yunohost app setting $app admin -v "$admin"
sudo yunohost app setting $app is_public -v "$is_public" sudo yunohost app setting $app is_public -v "$is_public"
sudo yunohost app setting $app domain -v "$domain" sudo yunohost app setting $app domain -v "$domain"
sudo yunohost app setting $app path -v "$path" sudo yunohost app setting $app path -v "$path"
# Download bozon # download bozon
sudo wget https://github.com/broncowdd/BoZoN/archive/master.zip -O $parent_path/master.zip sudo wget https://github.com/broncowdd/BoZoN/archive/master.zip -O $parent_path/master.zip
sudo unzip $parent_path/master.zip -d $parent_path/ sudo unzip $parent_path/master.zip -d $parent_path/
sudo rm $parent_path/master.zip sudo rm $parent_path/master.zip
sudo mv $parent_path/BoZoN-master $parent_path/$app sudo mv $parent_path/BoZoN-master $parent_path/$app
# Copy files to final folder and set permissions # copy files to final folder and set permissions
sudo find $final_path -type f -name ".htaccess" | xargs sudo rm sudo find $final_path -type f -name ".htaccess" | xargs sudo rm
sudo chown -R root: $final_path sudo chown -R root: $final_path
sudo find $final_path -type f | xargs sudo chmod 644 sudo find $final_path -type f | xargs sudo chmod 644
sudo find $final_path -type d | xargs sudo chmod 755 sudo find $final_path -type d | xargs sudo chmod 755
# Configure config file # configure config file
sudo sed -i "s@'en'@'$default_lang'@g" $final_path/config.php sudo sed -i "s@'en'@'$default_lang'@g" $final_path/config.php
# Create data folders # create data folders
sudo mkdir -p $final_path/private sudo mkdir -p $final_path/private
sudo mkdir -p $final_path/uploads sudo mkdir -p $data_path/uploads
sudo mkdir -p $final_path/thumbs sudo ln -s $data_path/uploads $final_path/uploads
sudo mkdir -p $data_path/thumbs
sudo ln -s $data_path/thumbs $final_path/thumbs
sudo chown -R www-data: $final_path/private sudo chown -R www-data: $final_path/private
sudo chown -R www-data: $final_path/uploads sudo chown -R www-data: $data_path/uploads
sudo chown -R www-data: $final_path/thumbs sudo chown -R www-data: $data_path/thumbs
# Configure nginx settings # configure nginx settings
folder_path=${path%/} folder_path=${path%/}
sudo sed -i "s@YNH_EXAMPLE_PATH@$path@g" ../conf/nginx.conf sudo sed -i "s@YNH_EXAMPLE_PATH@$path@g" ../conf/nginx.conf
# If path is only / (without subfolder), add trailing slash to alias # if path is only / (without subfolder), add trailing slash to alias
alias_path=$final_path alias_path=$final_path
[ "$path" == '/' ] && alias_path=$alias_path'/' [ "$path" == '/' ] && alias_path=$alias_path'/'
sudo sed -i "s@YNH_EXAMPLE_ALIAS@$alias_path@g" ../conf/nginx.conf sudo sed -i "s@YNH_EXAMPLE_ALIAS@$alias_path@g" ../conf/nginx.conf
sudo sed -i "s@YNH_EXAMPLE_FOLDER@$folder_path@g" ../conf/nginx.conf sudo sed -i "s@YNH_EXAMPLE_FOLDER@$folder_path@g" ../conf/nginx.conf
sudo cp ../conf/nginx.conf /etc/nginx/conf.d/$domain.d/$app.conf sudo cp ../conf/nginx.conf /etc/nginx/conf.d/$domain.d/$app.conf
# If app is private, remove url to SSOWat conf from skipped_uris # if app is private, remove url to SSOWat conf from skipped_uris
if [ "$is_public" = "No" ]; if [ "$is_public" = "No" ];
then then
# Redirect to SSOwat login in # redirect to SSOwat login in
sudo yunohost app setting $app unprotected_uris -d sudo yunohost app setting $app unprotected_uris -d
else else
sudo yunohost app setting $app unprotected_uris -v "/" sudo yunohost app setting $app unprotected_uris -v "/"
fi fi
# Adding admin to the allowed users # adding admin to the allowed users
sudo yunohost app addaccess $app -u $admin sudo yunohost app addaccess $app -u $admin
# Restart services # restart services
sudo service nginx reload sudo service nginx reload
sudo yunohost app ssowatconf sudo yunohost app ssowatconf

View file

@ -8,3 +8,4 @@ domain=$(sudo yunohost app setting $app domain)
sudo rm -rf /var/www/$app sudo rm -rf /var/www/$app
sudo rm -f /etc/nginx/conf.d/$domain.d/$app.conf sudo rm -f /etc/nginx/conf.d/$domain.d/$app.conf
sudo rm -rf /home/yunohost.app/$app

View file

@ -7,21 +7,24 @@ set -e
app=bozon app=bozon
parent_path=/var/www parent_path=/var/www
final_path=$parent_path/$app final_path=$parent_path/$app
data_path=/home/yunohost.app/$app
#retrieve arguments # retrieve arguments
save_path=$1 save_path=$1
domain=$(sudo yunohost app setting $app domain) domain=$(sudo yunohost app setting $app domain)
# move the backup # restore sources & data
sudo mv $save_path/$app $final_path sudo mv $save_path/www/. $final_path/
sudo mv $save_path/datas/. $data_path/
# restore permissions # restore permissions
sudo chown -R root: $final_path sudo chown -R root: $final_path
sudo find $final_path -type f | xargs sudo chmod 644 sudo find $final_path -type f | xargs sudo chmod 644
sudo find $final_path -type d | xargs sudo chmod 755 sudo find $final_path -type d | xargs sudo chmod 755
sudo chown -R www-data: $final_path/private sudo chown -R www-data: $final_path/private
sudo chown -R www-data: $final_path/uploads sudo chown -R www-data: $data_path/uploads
sudo chown -R www-data: $final_path/thumbs sudo chown -R www-data: $data_path/thumbs
sudo cp -a $save_path/yunohost /etc/yunohost/apps/$app/. # restore Nginx and YunoHost parameters
sudo cp -a $save_path/yunohost/. /etc/yunohost/apps/$app/
sudo cp -a $save_path/nginx.conf /etc/nginx/conf.d/$domain.d/$app.conf sudo cp -a $save_path/nginx.conf /etc/nginx/conf.d/$domain.d/$app.conf

View file

@ -6,25 +6,17 @@ set -e
app=bozon app=bozon
parent_path=/var/www parent_path=/var/www
final_path=$parent_path/$app final_path=$parent_path/$app
data_path=/home/yunohost.app/$app
#retrieve arguments # retrieve arguments
path=$(sudo yunohost app setting $app path) path=$(sudo yunohost app setting $app path)
# Download bozon # download bozon
cd $parent_path sudo wget https://github.com/broncowdd/BoZoN/archive/master.zip -O $parent_path/master.zip
sudo wget https://github.com/broncowdd/BoZoN/archive/master.zip sudo unzip $parent_path/master.zip -d $parent_path/
sudo unzip master.zip sudo rm $parent_path/master.zip
sudo rm master.zip sudo rsync -avz --exclude="config.php" --exclude=".htaccess" $parent_path/BoZoN-master/* $parent_path/$app/
sudo mv BoZoN-master $app sudo rm -R $parent_path/BoZoN-master
# Copy files to final folder and set permissions
sudo find $final_path -type f -name ".htaccess" | xargs sudo rm
sudo chown -R root: $final_path
sudo find $final_path -type f | xargs sudo chmod 644
sudo find $final_path -type d | xargs sudo chmod 755
sudo chown -R www-data: $final_path/private
sudo chown -R www-data: $final_path/uploads
sudo chown -R www-data: $final_path/thumbs
# Restart services # Restart services
sudo service nginx reload sudo service nginx reload