mirror of
https://github.com/YunoHost-Apps/freshrss_ynh.git
synced 2024-09-03 18:36:33 +02:00
Utilisation des hooks
Utilisation des hooks pour l’ajout et la suppression de l’accès à l’application
This commit is contained in:
parent
b27b437203
commit
e499c43abc
2 changed files with 80 additions and 0 deletions
40
hooks/post_app_addaccess
Executable file
40
hooks/post_app_addaccess
Executable file
|
@ -0,0 +1,40 @@
|
|||
#!/bin/bash
|
||||
|
||||
app=$1
|
||||
new_users=$2
|
||||
|
||||
|
||||
if [[ "freshrss" = "$app" ]];
|
||||
then
|
||||
db_user=freshrss
|
||||
db_name=freshrss
|
||||
db_pwd=$(sudo yunohost app setting freshrss mysqlpwd)
|
||||
|
||||
#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
|
||||
|
||||
for myuser in $(echo "$new_users" | sed "s/,/ /g")
|
||||
do
|
||||
#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 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
|
||||
fi
|
40
hooks/post_app_removeaccess
Executable file
40
hooks/post_app_removeaccess
Executable file
|
@ -0,0 +1,40 @@
|
|||
#!/bin/bash
|
||||
|
||||
app=$1
|
||||
new_users=$2
|
||||
|
||||
|
||||
if [[ "freshrss" = "$app" ]];
|
||||
then
|
||||
db_user=freshrss
|
||||
db_name=freshrss
|
||||
db_pwd=$(sudo yunohost app setting freshrss mysqlpwd)
|
||||
|
||||
#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
|
||||
|
||||
for myuser in $(echo "$new_users" | sed "s/,/ /g")
|
||||
do
|
||||
#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 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
|
||||
fi
|
Loading…
Reference in a new issue