diff --git a/manifest.json b/manifest.json index d9a04a2..e529598 100644 --- a/manifest.json +++ b/manifest.json @@ -2,6 +2,9 @@ "name": "Tiny Tiny RSS", "id": "ttrss", "packaging_format": 1, + "requirements": { + "yunohost": ">> 2.3.12.1" + }, "description": { "en": "A PHP and Ajax feed reader", "fr": "Un lecteur de flux en PHP et Ajax" diff --git a/scripts/install b/scripts/install index 0bb02cc..51a1765 100644 --- a/scripts/install +++ b/scripts/install @@ -3,9 +3,10 @@ # Retrieve arguments domain=$1 path=$2 +app=${!#} # Check domain/path availability -sudo yunohost app checkurl $domain$path -a ttrss +sudo yunohost app checkurl $domain$path -a $app if [[ ! $? -eq 0 ]]; then exit 1 fi @@ -15,14 +16,14 @@ deskey=$(dd if=/dev/urandom bs=1 count=200 2> /dev/null | tr -c -d 'A-Za-z0-9' | 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') # Use 'ttrss' as database name and user -db_user=ttrss +db_user=$app # Initialize database and store mysql password for upgrade sudo yunohost app initdb $db_user -p $db_pwd -s $(readlink -e ../source/schema/TTRSS_schema_mysql.sql) -sudo yunohost app setting ttrss mysqlpwd -v $db_pwd +sudo yunohost app setting $app mysqlpwd -v $db_pwd # Copy files to the right place -final_path=/var/www/ttrss +final_path=/var/www/$app sudo mkdir -p $final_path sudo cp -r ../source/* $final_path sudo cp ../conf/config.php $final_path/ @@ -37,8 +38,8 @@ sudo sed -i "s/yunopass/$db_pwd/g" $final_path/config.php sudo sed -i "s/yunobase/$db_user/g" $final_path/config.php sudo sed -i "s,yunopath,https://$domain$path,g" $final_path/config.php echo "*/30 * * * * www-data cd $final_path && /usr/bin/php $final_path/update.php --feeds >/dev/null 2>&1" > /tmp/cronttrss -sudo mv /tmp/cronttrss /etc/cron.d/ttrss -sudo chown root /etc/cron.d/ttrss +sudo mv /tmp/cronttrss /etc/cron.d/$app +sudo chown root /etc/cron.d/$app sudo apt-get install php5-cli -y #add folder @@ -66,9 +67,9 @@ sudo chown -R www-data: $final_path # Modify Nginx configuration file and copy it to Nginx conf directory sudo sed -i "s@PATHTOCHANGE@$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/ttrss.conf +sudo cp ../conf/nginx.conf /etc/nginx/conf.d/$domain.d/$app.conf # Reload Nginx and regenerate SSOwat conf sudo service nginx reload -sudo yunohost app setting ttrss skipped_uris -v "/public.php,/api" +sudo yunohost app setting $app skipped_uris -v "/public.php,/api" sudo yunohost app ssowatconf diff --git a/scripts/remove b/scripts/remove index f645c5c..8dab262 100644 --- a/scripts/remove +++ b/scripts/remove @@ -1,11 +1,14 @@ #!/bin/bash +set -e -db_user=ttrss -db_name=ttrss +app=${!#} + +db_user=$app +db_name=$app root_pwd=$(sudo cat /etc/yunohost/mysql) -domain=$(sudo yunohost app setting ttrss domain) +domain=$(sudo yunohost app setting $app domain) mysql -u root -p$root_pwd -e "DROP DATABASE $db_name ; DROP USER $db_user@localhost ;" -sudo rm -rf /var/www/ttrss -sudo rm -f /etc/nginx/conf.d/$domain.d/ttrss.conf -sudo rm -f /etc/cron.d/ttrss +sudo rm -rf /var/www/$app +sudo rm -f /etc/nginx/conf.d/$domain.d/$app.conf +sudo rm -f /etc/cron.d/$app diff --git a/scripts/restore b/scripts/restore index 025dd8e..ca1b8a0 100644 --- a/scripts/restore +++ b/scripts/restore @@ -64,5 +64,5 @@ sudo chown root /etc/cron.d/$app sudo service nginx reload # Set ssowat config -sudo yunohost app setting ttrss skipped_uris -v "/public.php,/api" +sudo yunohost app setting $app skipped_uris -v "/public.php,/api" sudo yunohost app ssowatconf diff --git a/scripts/upgrade b/scripts/upgrade index 3dd4cd1..cd5f10d 100644 --- a/scripts/upgrade +++ b/scripts/upgrade @@ -1,12 +1,15 @@ #!/bin/bash +set -e -domain=$(sudo yunohost app setting ttrss domain) -path=$(sudo yunohost app setting ttrss path) +app=${!#} -db_user=ttrss -db_pwd=$(sudo yunohost app setting ttrss mysqlpwd) +domain=$(sudo yunohost app setting $app domain) +path=$(sudo yunohost app setting $app path) -final_path=/var/www/ttrss +db_user=$app +db_pwd=$(sudo yunohost app setting $app mysqlpwd) + +final_path=/var/www/$app sudo mkdir -p $final_path sudo cp -a ../source/* $final_path @@ -26,11 +29,11 @@ sudo chown -R www-data: $final_path # Modify Nginx configuration file and copy it to Nginx conf directory sudo sed -i "s@PATHTOCHANGE@$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/ttrss.conf +sudo cp ../conf/nginx.conf /etc/nginx/conf.d/$domain.d/$app.conf sudo service nginx reload sudo yunohost app ssowatconf -sudo yunohost app setting ttrss skipped_uris -v "/public.php,/api" +sudo yunohost app setting $app skipped_uris -v "/public.php,/api" # Update database schema sudo su - www-data -c "$final_path/update.php --update-schema"