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

Fix hooks

This commit is contained in:
plopoyop 2014-09-20 10:47:18 +02:00
parent f20e7200f0
commit b4146e5c67
2 changed files with 6 additions and 61 deletions

View file

@ -1,7 +1,7 @@
#!/bin/bash #!/bin/bash
app=$1 app=$1
new_users=$2 deleted_users=$2
if [[ "freshrss" = "$app" ]]; if [[ "freshrss" = "$app" ]];
@ -10,31 +10,10 @@ then
db_name=freshrss db_name=freshrss
db_pwd=$(sudo yunohost app setting freshrss mysqlpwd) db_pwd=$(sudo yunohost app setting freshrss mysqlpwd)
#check wallabag #for each deleted users
if [[ $(sudo yunohost app list -f wallabag | /bin/grep -q "installed: True") -eq 0 ]]; then for myuser in $(echo "$deleted_users" | sed "s/,/ /g")
echo "Detected wallabag"
wallabagPath=$(sudo yunohost app setting wallabag path)
wallabagUrl=$domain$wallabagPath
sharingWallabag="array('type' => 'wallabag','name' => 'Wallabag','url' => 'https://$wallabagUrl',),"
fi
for myuser in $(echo "$new_users" | sed "s/,/ /g")
do do
#copy sql #drop all 3 tables
sudo cp /var/www/freshrss/app/SQL/install_ynh.sql /tmp/$myuser-install.sql mysql -u root -p$root_pwd -e "DROP TABLE $myuser\_entry; DROP TABLE $myuser\_feed; DROP TABLE $myuser\_catefory;" $db_name
#change username in sql
sudo sed -i "s/YnoUser/$myuser/g" /tmp/$myuser-install.sql
#create tables
mysql -u $db_user -p$db_pwd $db_user < /tmp/$myuser-install.sql
#remove temp sql
sudo rm /tmp/$myuser-install.sql
#copy default conf
sudo cp /var/www/freshrss/data/user.php.dist /var/www/freshrss/data/$myuser\_user.php
#change username
sudo sed -i "s/YnoUser/$myuser/g" $final_path/data/$myuser\_user.php
#add wallabag sharing
sudo sed -i "s@sharingArrayYnh@$sharingWallabag@g" $final_path/data/$myuser\_user.php
done done
fi fi

View file

@ -1,34 +0,0 @@
#!/bin/bash
db_user=freshrss
db_name=freshrss
db_pwd=$(sudo yunohost app setting freshrss mysqlpwd)
myuser=$1
#check wallabag
if [[ $(sudo yunohost app list -f wallabag | /bin/grep -q "installed: True") -eq 0 ]]; then
echo "Detected wallabag"
$wallabagPath=$(sudo yunohost app setting wallabag path)
$wallabagUrl=$domain$wallabagPath
$sharingWallabag="array('type' => 'wallabag','name' => 'Wallabag','url' => 'https://$wallabagUrl',),"
fi
#copy sql
sudo cp /var/www/freshrss/app/SQL/install_ynh.sql /tmp/$myuser-install.sql
#change username in sql
sudo sed -i "s/YnoUser/$myuser/g" /tmp/$myuser-install.sql
#create tables
mysql -u $db_user -p$db_pwd $db_user < /tmp/$myuser-install.sql
#remove temp sql
sudo rm /tmp/$myuser-install.sql
#copy default conf
sudo cp /var/www/freshrss/data/user.php.dist /var/www/freshrss/data/$myuser\_user.php
#change email
#user_email=$(ldapsearch -h localhost -b uid=$myuser,ou=users,dc=yunohost,dc=org -x objectClass=mailAccount mail | grep mail: | head -n 1| sed 's/mail: //')
sudo sed -i "s/ynoUserEmail/$user_email/g" /var/www/freshrss//data/$myuser\_user.php
#change username
sudo sed -i "s/YnoUser/$myuser/g" /var/www/freshrss/data/$myuser\_user.php
sudo sed -i "s/sharingArrayYnh/$sharingWallabag/g" $final_path/data/$myuser\_user.php