mirror of
https://github.com/YunoHost-Apps/lstu_ynh.git
synced 2024-09-03 19:36:12 +02:00
[WIP] add actions
This commit is contained in:
parent
3aed535189
commit
3f6129248d
8 changed files with 207 additions and 18 deletions
75
actions.json
Normal file
75
actions.json
Normal file
|
@ -0,0 +1,75 @@
|
|||
[
|
||||
{
|
||||
"id": "public_private",
|
||||
"name": "Move to public or private",
|
||||
"command": "/bin/bash scripts/actions/public_private",
|
||||
"user": "root",
|
||||
"accepted_return_codes": [
|
||||
0
|
||||
],
|
||||
"description": {
|
||||
"en": "Change the public access of the app."
|
||||
},
|
||||
"arguments": [
|
||||
{
|
||||
"name": "is_public",
|
||||
"type": "boolean",
|
||||
"ask": {
|
||||
"en": "Is it a public app ?"
|
||||
},
|
||||
"default": true
|
||||
}
|
||||
]
|
||||
},
|
||||
{
|
||||
"id": "change_password",
|
||||
"name": "Change the admin password",
|
||||
"command": "/bin/bash scripts/actions/change_password",
|
||||
"user": "root",
|
||||
"accepted_return_codes": [
|
||||
0
|
||||
],
|
||||
"description": {
|
||||
"en": "Change the admin password of the app.",
|
||||
"fr": "Change le mot de passe administrateur de l'app."
|
||||
},
|
||||
"arguments": [
|
||||
{
|
||||
"name": "password",
|
||||
"type": "password",
|
||||
"ask": {
|
||||
"en": "New password",
|
||||
"fr": "Nouveau mot de passe"
|
||||
}
|
||||
}
|
||||
]
|
||||
},
|
||||
{
|
||||
"id": "change_theme",
|
||||
"name": "Change the theme",
|
||||
"command": "/bin/bash scripts/actions/change_theme",
|
||||
"user": "root",
|
||||
"accepted_return_codes": [
|
||||
0
|
||||
],
|
||||
"description": {
|
||||
"en": "Change the theme of the app.",
|
||||
"fr": "Change le thème de l'app."
|
||||
},
|
||||
"arguments": [
|
||||
{
|
||||
"name": "theme",
|
||||
"type": "string",
|
||||
"ask": {
|
||||
"en": "Choose a theme",
|
||||
"fr": "Choisissez un theme"
|
||||
},
|
||||
"choices": [
|
||||
"default",
|
||||
"milligram"
|
||||
],
|
||||
"default": "milligram"
|
||||
}
|
||||
]
|
||||
}
|
||||
]
|
|
@ -185,7 +185,7 @@
|
|||
# bind_pwd => '', # search bind password
|
||||
user_attr => 'uid', # user attribute (uid, mail, sAMAccountName, etc.)
|
||||
# user_filter => '(!(uid=ldap_user))', # user filter (to exclude some users, etc.)
|
||||
},
|
||||
}, #end of ldap conf
|
||||
|
||||
# set `htpasswd` if you want to use an htpasswd file instead of ldap
|
||||
# create the file with `htpasswd -c lstu.passwd user`, update it with `htpasswd lstu.passwd user2`
|
||||
|
|
|
@ -3,9 +3,6 @@ location __PATH__ {
|
|||
rewrite ^ https://$server_name$request_uri? permanent;
|
||||
}
|
||||
|
||||
#--PRIVATE--# Include SSOWAT user panel.
|
||||
#--PRIVATE--include conf.d/yunohost_panel.conf.inc;
|
||||
|
||||
access_log /var/log/nginx/lstu.access.log;
|
||||
error_log /var/log/nginx/lstu.error.log;
|
||||
|
||||
|
@ -19,4 +16,7 @@ location __PATH__ {
|
|||
|
||||
# We expect the downsteam servers to redirect to the right hostname, so don't do any rewrite$
|
||||
proxy_redirect off;
|
||||
|
||||
# Include SSOWAT user panel.
|
||||
include conf.d/yunohost_panel.conf.inc;
|
||||
}
|
||||
|
|
|
@ -1,5 +1,9 @@
|
|||
#!/bin/bash
|
||||
|
||||
set_config_file() {
|
||||
|
||||
}
|
||||
|
||||
# Start (or other actions) a service, print a log in case of failure and optionnaly wait until the service is completely started
|
||||
#
|
||||
# usage: ynh_systemd_action [-n service_name] [-a action] [ [-l "line to match"] [-p log_path] [-t timeout] [-e length] ]
|
||||
|
|
94
scripts/actions/public_private
Executable file
94
scripts/actions/public_private
Executable file
|
@ -0,0 +1,94 @@
|
|||
#!/bin/bash
|
||||
|
||||
#=================================================
|
||||
# GENERIC STARTING
|
||||
#=================================================
|
||||
# IMPORT GENERIC HELPERS
|
||||
#=================================================
|
||||
|
||||
source scripts/_common.sh
|
||||
source /usr/share/yunohost/helpers
|
||||
|
||||
#=================================================
|
||||
# RETRIEVE ARGUMENTS
|
||||
#=================================================
|
||||
ynh_script_progression --message="Retrieve arguments from the manifest"
|
||||
|
||||
# Get is_public
|
||||
is_public=${YNH_ACTION_IS_PUBLIC}
|
||||
|
||||
app=${YNH_APP_INSTANCE_NAME:-$YNH_APP_ID}
|
||||
|
||||
final_path=$(ynh_app_setting_get $app final_path)
|
||||
|
||||
#=================================================
|
||||
# CHECK IF ARGUMENTS ARE CORRECT
|
||||
#=================================================
|
||||
|
||||
#=================================================
|
||||
# CHECK IF AN ACTION HAS TO BE DONE
|
||||
#=================================================
|
||||
|
||||
is_public_old=$(ynh_app_setting_get $app is_public)
|
||||
|
||||
if [ $is_public -eq $is_public_old ]
|
||||
then
|
||||
ynh_die "is_public is already set as $is_public." 0
|
||||
fi
|
||||
|
||||
#=================================================
|
||||
# SPECIFIC ACTION
|
||||
#=================================================
|
||||
# MOVE TO PUBLIC OR PRIVATE
|
||||
#=================================================
|
||||
if [ $is_public -eq 0 ]; then
|
||||
public_private="private"
|
||||
else
|
||||
public_private="public"
|
||||
fi
|
||||
ynh_script_progression --message="Move the application to $public_private" --weight=3
|
||||
|
||||
ynh_app_setting_set $app skipped_uris "/"
|
||||
if [ $is_public -eq 0 ];
|
||||
then # If the app is private, only the shortened URLs are publics
|
||||
if [ "$path_url" == "/" ]; then
|
||||
path_url=""
|
||||
fi
|
||||
ynh_app_setting_set $app protected_regex "$domain$path_url/login$","$domain$path_url/logout$","$domain$path_url/api$","$domain$path_url/extensions$","$domain$path_url/stats$","$domain$path_url/d/.*$","$domain$path_url/a$","$domain$path_url/$"
|
||||
|
||||
ynh_replace_string "#ldap => {" "ldap => {" "${final_path}/lstu.conf"
|
||||
ynh_replace_string "#uri => 'ldap://localhost:389'," "uri => 'ldap://localhost:389'," "${final_path}/lstu.conf"
|
||||
ynh_replace_string "#user_tree => 'dc=yunohost,dc=org'," "user_tree => 'dc=yunohost,dc=org'," "${final_path}/lstu.conf"
|
||||
ynh_replace_string "#bind_dn => 'ou=users,dc=yunohost,dc=org'," "bind_dn => 'ou=users,dc=yunohost,dc=org'," "${final_path}/lstu.conf"
|
||||
ynh_replace_string "#user_attr => 'uid'," "user_attr => 'uid'," "${final_path}/lstu.conf"
|
||||
ynh_replace_string "#}, #end of ldap conf" "}, #end of ldap conf" "${final_path}/lstu.conf"
|
||||
else
|
||||
ynh_app_setting_delete $app protected_regex
|
||||
|
||||
ynh_replace_string "ldap => {" "#ldap => {" "${final_path}/lstu.conf"
|
||||
ynh_replace_string "uri => 'ldap://localhost:389'," "#uri => 'ldap://localhost:389'," "${final_path}/lstu.conf"
|
||||
ynh_replace_string "user_tree => 'dc=yunohost,dc=org'," "#user_tree => 'dc=yunohost,dc=org'," "${final_path}/lstu.conf"
|
||||
ynh_replace_string "bind_dn => 'ou=users,dc=yunohost,dc=org'," "#bind_dn => 'ou=users,dc=yunohost,dc=org'," "${final_path}/lstu.conf"
|
||||
ynh_replace_string "user_attr => 'uid'," "#user_attr => 'uid'," "${final_path}/lstu.conf"
|
||||
ynh_replace_string "}, #end of ldap conf" "#}, #end of ldap conf" "${final_path}/lstu.conf"
|
||||
fi
|
||||
|
||||
ynh_script_progression --message="Reconfigure SSOwat"
|
||||
# Regen ssowat configuration
|
||||
yunohost app ssowatconf
|
||||
|
||||
# Update the config of the app
|
||||
ynh_app_setting_set $app is_public $is_public
|
||||
|
||||
#=================================================
|
||||
# RELOAD NGINX
|
||||
#=================================================
|
||||
ynh_script_progression --message="Reload $app"
|
||||
|
||||
ynh_systemd_action -n $app -a reload -l "Reloaded Shortened URLs service." -p "systemd"
|
||||
|
||||
#=================================================
|
||||
# END OF SCRIPT
|
||||
#=================================================
|
||||
|
||||
ynh_script_progression --message="Execution completed" --last
|
|
@ -172,8 +172,22 @@ then # If the app is private, only the shortened URLs are publics
|
|||
path_url=""
|
||||
fi
|
||||
ynh_app_setting_set $app protected_regex "$domain$path_url/login$","$domain$path_url/logout$","$domain$path_url/api$","$domain$path_url/extensions$","$domain$path_url/stats$","$domain$path_url/d/.*$","$domain$path_url/a$","$domain$path_url/$"
|
||||
|
||||
ynh_replace_string "#ldap => {" "ldap => {" "${final_path}/lstu.conf"
|
||||
ynh_replace_string "#uri => 'ldap://localhost:389'," "uri => 'ldap://localhost:389'," "${final_path}/lstu.conf"
|
||||
ynh_replace_string "#user_tree => 'dc=yunohost,dc=org'," "user_tree => 'dc=yunohost,dc=org'," "${final_path}/lstu.conf"
|
||||
ynh_replace_string "#bind_dn => 'ou=users,dc=yunohost,dc=org'," "bind_dn => 'ou=users,dc=yunohost,dc=org'," "${final_path}/lstu.conf"
|
||||
ynh_replace_string "#user_attr => 'uid'," "user_attr => 'uid'," "${final_path}/lstu.conf"
|
||||
ynh_replace_string "#}, #end of ldap conf" "}, #end of ldap conf" "${final_path}/lstu.conf"
|
||||
else
|
||||
ynh_replace_string "#--PRIVATE--" "" "/etc/nginx/conf.d/$domain.d/$app.conf"
|
||||
ynh_app_setting_delete $app protected_regex
|
||||
|
||||
ynh_replace_string "ldap => {" "#ldap => {" "${final_path}/lstu.conf"
|
||||
ynh_replace_string "uri => 'ldap://localhost:389'," "#uri => 'ldap://localhost:389'," "${final_path}/lstu.conf"
|
||||
ynh_replace_string "user_tree => 'dc=yunohost,dc=org'," "#user_tree => 'dc=yunohost,dc=org'," "${final_path}/lstu.conf"
|
||||
ynh_replace_string "bind_dn => 'ou=users,dc=yunohost,dc=org'," "#bind_dn => 'ou=users,dc=yunohost,dc=org'," "${final_path}/lstu.conf"
|
||||
ynh_replace_string "user_attr => 'uid'," "#user_attr => 'uid'," "${final_path}/lstu.conf"
|
||||
ynh_replace_string "}, #end of ldap conf" "#}, #end of ldap conf" "${final_path}/lstu.conf"
|
||||
fi
|
||||
|
||||
#=================================================
|
||||
|
|
|
@ -176,8 +176,22 @@ then # If the app is private, only the shortened URLs are publics
|
|||
path_url=""
|
||||
fi
|
||||
ynh_app_setting_set $app protected_regex "$domain$path_url/login$","$domain$path_url/logout$","$domain$path_url/api$","$domain$path_url/extensions$","$domain$path_url/stats$","$domain$path_url/d/.*$","$domain$path_url/a$","$domain$path_url/$"
|
||||
|
||||
ynh_replace_string "#ldap => {" "ldap => {" "${final_path}/lstu.conf"
|
||||
ynh_replace_string "#uri => 'ldap://localhost:389'," "uri => 'ldap://localhost:389'," "${final_path}/lstu.conf"
|
||||
ynh_replace_string "#user_tree => 'dc=yunohost,dc=org'," "user_tree => 'dc=yunohost,dc=org'," "${final_path}/lstu.conf"
|
||||
ynh_replace_string "#bind_dn => 'ou=users,dc=yunohost,dc=org'," "bind_dn => 'ou=users,dc=yunohost,dc=org'," "${final_path}/lstu.conf"
|
||||
ynh_replace_string "#user_attr => 'uid'," "user_attr => 'uid'," "${final_path}/lstu.conf"
|
||||
ynh_replace_string "#}, #end of ldap conf" "}, #end of ldap conf" "${final_path}/lstu.conf"
|
||||
else
|
||||
ynh_replace_string "#--PRIVATE--" "" "/etc/nginx/conf.d/$domain.d/$app.conf"
|
||||
ynh_app_setting_delete $app protected_regex
|
||||
|
||||
ynh_replace_string "ldap => {" "#ldap => {" "${final_path}/lstu.conf"
|
||||
ynh_replace_string "uri => 'ldap://localhost:389'," "#uri => 'ldap://localhost:389'," "${final_path}/lstu.conf"
|
||||
ynh_replace_string "user_tree => 'dc=yunohost,dc=org'," "#user_tree => 'dc=yunohost,dc=org'," "${final_path}/lstu.conf"
|
||||
ynh_replace_string "bind_dn => 'ou=users,dc=yunohost,dc=org'," "#bind_dn => 'ou=users,dc=yunohost,dc=org'," "${final_path}/lstu.conf"
|
||||
ynh_replace_string "user_attr => 'uid'," "#user_attr => 'uid'," "${final_path}/lstu.conf"
|
||||
ynh_replace_string "}, #end of ldap conf" "#}, #end of ldap conf" "${final_path}/lstu.conf"
|
||||
fi
|
||||
|
||||
#=================================================
|
||||
|
|
|
@ -1,12 +0,0 @@
|
|||
#!/usr/bin/env perl
|
||||
|
||||
use strict;
|
||||
use warnings;
|
||||
|
||||
use FindBin;
|
||||
BEGIN { unshift @INC, "$FindBin::Bin/../lib" }
|
||||
BEGIN { unshift @INC, "$FindBin::Bin/../local/lib/perl5" }
|
||||
|
||||
# Start command line interface for application
|
||||
require Mojolicious::Commands;
|
||||
Mojolicious::Commands->start_app('Mounter');
|
Loading…
Reference in a new issue