diff --git a/hooks/post_user_create b/hooks/post_user_create index 782d74b..40b0216 100644 --- a/hooks/post_user_create +++ b/hooks/post_user_create @@ -1,6 +1,7 @@ #!/bin/bash -app="wallabag2" +app="__APP__" +user="__APP__" # Retrieve arguments username=$1 @@ -14,5 +15,5 @@ user_pass=$(ynh_string_random) # Create the new user in Wallabag (cd "/var/www/$app" && \ - sudo sudo -u "www-data" php "bin/console" --no-interaction --env=prod \ + sudo -u "$user" php "bin/console" --no-interaction --env=prod \ fos:user:create "$username" "$user_email" "$user_pass") diff --git a/hooks/post_user_delete b/hooks/post_user_delete index 7420339..6a39516 100644 --- a/hooks/post_user_delete +++ b/hooks/post_user_delete @@ -1,6 +1,7 @@ #!/bin/bash -app="wallabag2" +app="__APP__" +user="__APP__" # Retrieve arguments username=$1 @@ -8,5 +9,5 @@ purge=$2 # Deactivate the user from Wallabg (cd "/var/www/$app" && \ - sudo sudo -u "www-data" php "bin/console" --no-interaction --env=prod \ + sudo -u "$user" php "bin/console" --no-interaction --env=prod \ fos:user:deactivate "$username") diff --git a/scripts/install b/scripts/install index 0a58263..1005880 100644 --- a/scripts/install +++ b/scripts/install @@ -167,6 +167,13 @@ chmod 600 $wb_conf chown -R $app: $final_path chmod 755 $final_path +#================================================= +# SETUP HOOKS +#================================================= + +ynh_replace_string --match_string="__APP__" --replace_string="$app" --target_file="../hooks/post_user_create" +ynh_replace_string --match_string="__APP__" --replace_string="$app" --target_file="../hooks/post_user_delete" + #================================================= # SETUP SSOWAT #================================================= diff --git a/scripts/upgrade b/scripts/upgrade index 13fcb68..812e649 100644 --- a/scripts/upgrade +++ b/scripts/upgrade @@ -187,6 +187,13 @@ chmod 600 $wb_conf chown -R $app: $final_path chmod 755 $final_path +#================================================= +# SETUP HOOKS +#================================================= + +ynh_replace_string --match_string="__APP__" --replace_string="$app" --target_file="../hooks/post_user_create" +ynh_replace_string --match_string="__APP__" --replace_string="$app" --target_file="../hooks/post_user_delete" + #================================================= # SETUP SSOWAT #=================================================