1
0
Fork 0
mirror of https://github.com/YunoHost-Apps/yourls_ynh.git synced 2024-09-03 20:35:59 +02:00

Upgrade script

This commit is contained in:
Steven Roose 2015-08-29 02:30:41 +02:00
parent 07f0e6e4f3
commit 9415f50f63
2 changed files with 49 additions and 0 deletions

View file

@ -17,6 +17,8 @@ if [[ ! $? -eq 0 ]]; then
echo "Error : the chosen admin user does not exist"
exit 1
fi
# Save admin user
sudo yunohost app setting yourls admin -v $admin_user
# Generate random password
db_pwd=$(dd if=/dev/urandom bs=1 count=200 2> /dev/null | tr -c -d 'A-Za-z0-9' | sed -n 's/\(.\{24\}\).*/\1/p')

47
scripts/upgrade Normal file
View file

@ -0,0 +1,47 @@
#!/bin/bash
# Retrieve arguments
domain=$(sudo yunohost app setting yourls domain)
path=$(sudo yunohost app setting yourls path)
db_user=yourls
db_pwd=$(sudo yunohost app setting yourls mysqlpwd)
admin_user=$(sudo yunohost app setting yourls admin)
# Copy files to the right place
final_path=/var/www/yourls
sudo mkdir -p $final_path
sudo cp -a ../sources/* $final_path
sudo cp ../conf/index.php $final_path/
sudo cp -r ../conf/yunohost_auth $final_path/user/plugins
# Change variable in yourls configuration
sudo cp ../conf/config.php $final_path/user/config.php
sudo sed -i "s/yunouser/$db_user/g" $final_path/user/config.php
sudo sed -i "s/yunopass/$db_pwd/g" $final_path/user/config.php
sudo sed -i "s/yunobase/$db_user/g" $final_path/user/config.php
sudo sed -i "s/yunodomain/$domain/g" $final_path/user/config.php
sudo sed -i "s/yourlsuser/$admin_user/g" $final_path/user/config.php
sudo sed -i "s@_yourlspath@$path@g" $final_path/user/config.php
# Set permissions
sudo chown -R www-data: $final_path
# Modify Nginx configuration file and copy it to Nginx conf directory
sed -i "s@LOCATIONTOCHANGE@$path@g" ../conf/nginx.conf*
sed -i "s@PATHTOCHANGE@${path%/}@g" ../conf/nginx.conf*
sed -i "s@DOMAINTOCHANGE@$domain@g" ../conf/nginx.conf*
sed -i "s@ALIASTOCHANGE@$final_path@g" ../conf/nginx.conf*
nginxconf=/etc/nginx/conf.d/$domain.d/yourls.conf
sudo cp ../conf/nginx.conf $nginxconf
sudo chown root: $nginxconf
sudo chmod 600 $nginxconf
# Reload Nginx and regenerate SSOwat conf
sudo service nginx reload
sudo yunohost app setting yourls unprotected_uris -v "/"
sudo yunohost app ssowatconf