mirror of
https://github.com/YunoHost-Apps/lutim_ynh.git
synced 2024-09-03 19:36:24 +02:00
commit
629d279c7b
23 changed files with 747 additions and 437 deletions
14
CHANGELOG.md
14
CHANGELOG.md
|
@ -4,6 +4,20 @@ Changelog
|
||||||
## Unreleased
|
## Unreleased
|
||||||
- Nothing for now...
|
- Nothing for now...
|
||||||
|
|
||||||
|
## [0.11.6~ynh4](https://github.com/YunoHost-Apps/lutim_ynh/pull/46) - 2020-04-25
|
||||||
|
|
||||||
|
#### Added
|
||||||
|
- [Add new badges](https://github.com/YunoHost-Apps/lutim_ynh/pull/46/commits/4e28257f0550378297789c77a5354b004100f5ae)
|
||||||
|
* [New reset actions](https://github.com/YunoHost-Apps/lutim_ynh/pull/46/commits/e1c90a7c1b2c0c66c4d7bfc8a8e2a221d5c817ab)
|
||||||
|
|
||||||
|
#### Fixed
|
||||||
|
- [Fix potential error on install](https://github.com/YunoHost-Apps/lutim_ynh/pull/46/commits/e481e03e0511787f297e10f85d6a54b3fedb5470)
|
||||||
|
|
||||||
|
#### Changed
|
||||||
|
- [Indentation](https://github.com/YunoHost-Apps/lutim_ynh/pull/46/commits/a934b7369842dfbdc45e7c1dfdf3483276d4c755)
|
||||||
|
- [Misc upgrade](https://github.com/YunoHost-Apps/lutim_ynh/pull/46/commits/750ea401950f4e8b3facfa7caa5bc2388b6a4272)
|
||||||
|
|
||||||
|
|
||||||
## [0.11.6~ynh3](https://github.com/YunoHost-Apps/lutim_ynh/pull/45) - 2020-03-12
|
## [0.11.6~ynh3](https://github.com/YunoHost-Apps/lutim_ynh/pull/45) - 2020-03-12
|
||||||
|
|
||||||
#### Changed
|
#### Changed
|
||||||
|
|
|
@ -1,6 +1,6 @@
|
||||||
# Lutim for YunoHost
|
# Lutim for YunoHost
|
||||||
|
|
||||||
[](https://dash.yunohost.org/appci/app/lutim)
|
[](https://dash.yunohost.org/appci/app/lutim)  [](https://github.com/YunoHost/Apps/#what-to-do-if-i-cant-maintain-my-app-anymore-)
|
||||||
[](https://install-app.yunohost.org/?app=lutim)
|
[](https://install-app.yunohost.org/?app=lutim)
|
||||||
|
|
||||||
*[Lire ce readme en français.](./README_fr.md)*
|
*[Lire ce readme en français.](./README_fr.md)*
|
||||||
|
@ -41,7 +41,7 @@ Not relevant.
|
||||||
|
|
||||||
* x86-64b - [](https://ci-apps.yunohost.org/ci/apps/lutim/)
|
* x86-64b - [](https://ci-apps.yunohost.org/ci/apps/lutim/)
|
||||||
* ARMv8-A - [](https://ci-apps-arm.yunohost.org/ci/apps/lutim/)
|
* ARMv8-A - [](https://ci-apps-arm.yunohost.org/ci/apps/lutim/)
|
||||||
* Jessie x86-64b - [](https://ci-stretch.nohost.me/ci/apps/lutim/)
|
* Buster x86-64b - [](https://ci-buster.nohost.me/ci/apps/lutim/)
|
||||||
|
|
||||||
## Limitations
|
## Limitations
|
||||||
|
|
||||||
|
@ -63,7 +63,7 @@ Please do your pull request to the [testing branch](https://github.com/YunoHost-
|
||||||
|
|
||||||
To try the testing branch, please proceed like that.
|
To try the testing branch, please proceed like that.
|
||||||
```
|
```
|
||||||
sudo yunohost app install https://github.com/YunoHost-Apps/lutim_ynh/tree/testing --debug
|
sudo yunohost app install https://github.com/YunoHost-Apps/lutim_ynh/tree/testing --force --debug
|
||||||
or
|
or
|
||||||
sudo yunohost app upgrade lutim -u https://github.com/YunoHost-Apps/lutim_ynh/tree/testing --debug
|
sudo yunohost app upgrade lutim -u https://github.com/YunoHost-Apps/lutim_ynh/tree/testing --debug
|
||||||
```
|
```
|
||||||
|
|
|
@ -1,6 +1,6 @@
|
||||||
# Lutim pour YunoHost
|
# Lutim pour YunoHost
|
||||||
|
|
||||||
[](https://dash.yunohost.org/appci/app/lutim)
|
[](https://dash.yunohost.org/appci/app/lutim)  [](https://github.com/YunoHost/Apps/#what-to-do-if-i-cant-maintain-my-app-anymore-)
|
||||||
[](https://install-app.yunohost.org/?app=lutim)
|
[](https://install-app.yunohost.org/?app=lutim)
|
||||||
|
|
||||||
*[Read this readme in english.](./README.md)*
|
*[Read this readme in english.](./README.md)*
|
||||||
|
@ -41,7 +41,7 @@ Non applicable.
|
||||||
|
|
||||||
* x86-64b - [](https://ci-apps.yunohost.org/ci/apps/lutim/)
|
* x86-64b - [](https://ci-apps.yunohost.org/ci/apps/lutim/)
|
||||||
* ARMv8-A - [](https://ci-apps-arm.yunohost.org/ci/apps/lutim/)
|
* ARMv8-A - [](https://ci-apps-arm.yunohost.org/ci/apps/lutim/)
|
||||||
* Jessie x86-64b - [](https://ci-stretch.nohost.me/ci/apps/lutim/)
|
* Buster x86-64b - [](https://ci-buster.nohost.me/ci/apps/lutim/)
|
||||||
|
|
||||||
## Limitations
|
## Limitations
|
||||||
|
|
||||||
|
@ -63,7 +63,7 @@ Merci de faire vos pull request sur la [branche testing](https://github.com/Yuno
|
||||||
|
|
||||||
Pour tester la branche testing, merci de procéder ainsi.
|
Pour tester la branche testing, merci de procéder ainsi.
|
||||||
```
|
```
|
||||||
sudo yunohost app install https://github.com/YunoHost-Apps/lutim_ynh/tree/testing --debug
|
sudo yunohost app install https://github.com/YunoHost-Apps/lutim_ynh/tree/testing --force --debug
|
||||||
ou
|
ou
|
||||||
sudo yunohost app upgrade lutim -u https://github.com/YunoHost-Apps/lutim_ynh/tree/testing --debug
|
sudo yunohost app upgrade lutim -u https://github.com/YunoHost-Apps/lutim_ynh/tree/testing --debug
|
||||||
```
|
```
|
||||||
|
|
37
actions.toml
37
actions.toml
|
@ -22,14 +22,31 @@ command = "/bin/bash scripts/actions/reset_default_config \"lutim.conf\""
|
||||||
accepted_return_codes = [0]
|
accepted_return_codes = [0]
|
||||||
description = "Reset the config file lutim.conf."
|
description = "Reset the config file lutim.conf."
|
||||||
|
|
||||||
[public_private]
|
|
||||||
name = "Move to public or private"
|
|
||||||
command = "/bin/bash scripts/actions/public_private"
|
|
||||||
accepted_return_codes = [0]
|
|
||||||
description = "Change the public access of the app."
|
|
||||||
|
|
||||||
[public_private.arguments]
|
[reset_default_nginx]
|
||||||
[public_private.arguments.is_public]
|
name = "Reset the nginx config for this app."
|
||||||
type = "boolean"
|
command = "/bin/bash scripts/actions/reset_default_system nginx"
|
||||||
ask = "Is it a public app ?"
|
# user = "root" # optional
|
||||||
default = true
|
# cwd = "/" # optional
|
||||||
|
# accepted_return_codes = [0, 1, 2, 3] # optional
|
||||||
|
accepted_return_codes = [0]
|
||||||
|
description = "Reset the nginx config for this app."
|
||||||
|
|
||||||
|
[reset_default_systemd]
|
||||||
|
name = "Reset the systemd config for this app."
|
||||||
|
command = "/bin/bash scripts/actions/reset_default_system systemd"
|
||||||
|
# user = "root" # optional
|
||||||
|
# cwd = "/" # optional
|
||||||
|
# accepted_return_codes = [0, 1, 2, 3] # optional
|
||||||
|
accepted_return_codes = [0]
|
||||||
|
description = "Reset the systemd config for this app."
|
||||||
|
|
||||||
|
|
||||||
|
[reset_default_app]
|
||||||
|
name = "Reset the app with a default configuration."
|
||||||
|
command = "/bin/bash scripts/actions/reset_default_app"
|
||||||
|
# user = "root" # optional
|
||||||
|
# cwd = "/" # optional
|
||||||
|
# accepted_return_codes = [0, 1, 2, 3] # optional
|
||||||
|
accepted_return_codes = [0]
|
||||||
|
description = "Reset the app to its default configuration to try to fix potential issues.<br>This action won't remove any data added to the app.<br>However, if you have modified any configuration, it will be overwritten."
|
||||||
|
|
|
@ -4,6 +4,15 @@
|
||||||
path="/path" (PATH)
|
path="/path" (PATH)
|
||||||
is_public=1 (PUBLIC|public=1|private=0)
|
is_public=1 (PUBLIC|public=1|private=0)
|
||||||
always_encrypt=1
|
always_encrypt=1
|
||||||
|
; Actions
|
||||||
|
; Config_panel
|
||||||
|
main.configuration.always_encrypt=0|1
|
||||||
|
main.configuration.antiflood=10
|
||||||
|
main.configuration.delay=None|Day|Week|Month|Year
|
||||||
|
main.overwrite_files.overwrite_settings=0|1
|
||||||
|
main.overwrite_files.overwrite_nginx=0|1
|
||||||
|
main.overwrite_files.overwrite_systemd=0|1
|
||||||
|
main.global_config.email_type=0|1
|
||||||
; Checks
|
; Checks
|
||||||
pkg_linter=1
|
pkg_linter=1
|
||||||
setup_sub_dir=1
|
setup_sub_dir=1
|
||||||
|
@ -17,12 +26,13 @@
|
||||||
multi_instance=0
|
multi_instance=0
|
||||||
port_already_use=1 (8095)
|
port_already_use=1 (8095)
|
||||||
change_url=1
|
change_url=1
|
||||||
|
actions=1
|
||||||
|
config_panel=1
|
||||||
;;; Levels
|
;;; Levels
|
||||||
# Level 5: https://github.com/YunoHost/package_linter/issues/36
|
Level 5=auto
|
||||||
Level 5=1
|
|
||||||
;;; Options
|
;;; Options
|
||||||
Email=
|
Email=
|
||||||
Notification=down
|
Notification=change
|
||||||
;;; Upgrade options
|
;;; Upgrade options
|
||||||
; commit=4c29aa94f9d9048411c6e165e122e03574fb9b8d
|
; commit=4c29aa94f9d9048411c6e165e122e03574fb9b8d
|
||||||
name=08 Sep 2017 4c29aa94f9d9048411c6e165e122e03574fb9b8d
|
name=08 Sep 2017 4c29aa94f9d9048411c6e165e122e03574fb9b8d
|
||||||
|
|
|
@ -24,14 +24,6 @@ name = "Lutim configuration"
|
||||||
default = "Year"
|
default = "Year"
|
||||||
help = "Users won't be able to ask Lutim to download images more than one per anti_flood_delay seconds."
|
help = "Users won't be able to ask Lutim to download images more than one per anti_flood_delay seconds."
|
||||||
|
|
||||||
[main.is_public]
|
|
||||||
name = "Public access"
|
|
||||||
|
|
||||||
[main.is_public.is_public]
|
|
||||||
ask = "Is it a public website?"
|
|
||||||
type = "boolean"
|
|
||||||
default = true
|
|
||||||
|
|
||||||
[main.overwrite_files]
|
[main.overwrite_files]
|
||||||
name = "Overwriting config files"
|
name = "Overwriting config files"
|
||||||
|
|
||||||
|
|
26
hooks/post_app_addaccess
Normal file
26
hooks/post_app_addaccess
Normal file
|
@ -0,0 +1,26 @@
|
||||||
|
#!/bin/bash
|
||||||
|
|
||||||
|
# Source app helpers
|
||||||
|
source /usr/share/yunohost/helpers
|
||||||
|
|
||||||
|
app=$1
|
||||||
|
added_users=$2
|
||||||
|
permission=$3
|
||||||
|
added_groups=$4
|
||||||
|
|
||||||
|
if [ "$app" == __APP__ ]; then
|
||||||
|
if [ "$permission" = "upload images" ]; then # The fake permission "upload images" is modifed.
|
||||||
|
if [ "$added_groups" = "visitors" ]; then # As is it a fake permission we can only grant/remove the "visitors" group.
|
||||||
|
|
||||||
|
# We remove the regex, no more protection is needed.
|
||||||
|
ynh_app_setting_delete --app=$app --key=protected_regex
|
||||||
|
|
||||||
|
# Sync the is_public variable according to the permission
|
||||||
|
ynh_app_setting_set --app=$app --key=is_public --value=1
|
||||||
|
|
||||||
|
yunohost app ssowatconf
|
||||||
|
else
|
||||||
|
ynh_print_warn --message="This app doesn't support this authorisation, you can only add or remove visitors group."
|
||||||
|
fi
|
||||||
|
fi
|
||||||
|
fi
|
34
hooks/post_app_removeaccess
Normal file
34
hooks/post_app_removeaccess
Normal file
|
@ -0,0 +1,34 @@
|
||||||
|
#!/bin/bash
|
||||||
|
|
||||||
|
# Source app helpers
|
||||||
|
source /usr/share/yunohost/helpers
|
||||||
|
|
||||||
|
app=$1
|
||||||
|
removed_users=$2
|
||||||
|
permission=$3
|
||||||
|
removed_groups=$4
|
||||||
|
|
||||||
|
if [ "$app" == __APP__ ]; then
|
||||||
|
if [ "$permission" = "upload images" ]; then # The fake permission "upload images" is modifed.
|
||||||
|
if [ "$removed_groups" = "visitors" ]; then # As is it a fake permission we can only grant/remove the "visitors" group.
|
||||||
|
domain=$(ynh_app_setting_get --app=$app --key=domain)
|
||||||
|
path_url=$(ynh_app_setting_get --app=$app --key=path)
|
||||||
|
|
||||||
|
# If the app is private, viewing images stays publicly accessible.
|
||||||
|
if [ "$path_url" == "/" ]; then
|
||||||
|
# If the path is /, clear it to prevent any error with the regex.
|
||||||
|
path_url=""
|
||||||
|
fi
|
||||||
|
# Modify the domain to be used in a regex
|
||||||
|
domain_regex=$(echo "$domain" | sed 's@-@.@g')
|
||||||
|
ynh_app_setting_set --app=$app --key=protected_regex --value="$domain_regex$path_url/stats/?$","$domain_regex$path_url/manifest.webapp/?$","$domain_regex$path_url/?$","$domain_regex$path_url/[d-m]/.*$"
|
||||||
|
|
||||||
|
# Sync the is_public variable according to the permission
|
||||||
|
ynh_app_setting_set --app=$app --key=is_public --value=0
|
||||||
|
|
||||||
|
yunohost app ssowatconf
|
||||||
|
else
|
||||||
|
ynh_print_warn --message="This app doesn't support this authorisation, you can only add or remove visitors group."
|
||||||
|
fi
|
||||||
|
fi
|
||||||
|
fi
|
|
@ -6,7 +6,7 @@
|
||||||
"en": "Self hosting images and sharing anonymous application",
|
"en": "Self hosting images and sharing anonymous application",
|
||||||
"fr": "Application d'hébergement et de partage d'images anonyme"
|
"fr": "Application d'hébergement et de partage d'images anonyme"
|
||||||
},
|
},
|
||||||
"version": "0.11.6~ynh3",
|
"version": "0.11.6~ynh4",
|
||||||
"url": "https://lut.im",
|
"url": "https://lut.im",
|
||||||
"license": "AGPL-3.0",
|
"license": "AGPL-3.0",
|
||||||
"maintainer": {
|
"maintainer": {
|
||||||
|
@ -14,7 +14,7 @@
|
||||||
"email": "maniackc_dev@crudelis.fr"
|
"email": "maniackc_dev@crudelis.fr"
|
||||||
},
|
},
|
||||||
"requirements": {
|
"requirements": {
|
||||||
"yunohost": ">= 3.5"
|
"yunohost": ">= 3.7"
|
||||||
},
|
},
|
||||||
"multi_instance": false,
|
"multi_instance": false,
|
||||||
"services": [
|
"services": [
|
||||||
|
@ -48,7 +48,10 @@
|
||||||
"en": "Uploading images is it public?",
|
"en": "Uploading images is it public?",
|
||||||
"fr": "L'upload des images est-il public ?"
|
"fr": "L'upload des images est-il public ?"
|
||||||
},
|
},
|
||||||
"default": false
|
"default": false,
|
||||||
|
"help": {
|
||||||
|
"en": "If you set Lutim as public, everyone will be able to upload images and share them.<br>But even if not public, everyone can see an image from a link shared with your Lutim."
|
||||||
|
}
|
||||||
},
|
},
|
||||||
{
|
{
|
||||||
"name": "always_encrypt",
|
"name": "always_encrypt",
|
||||||
|
|
|
@ -9,11 +9,18 @@
|
||||||
source scripts/_common.sh
|
source scripts/_common.sh
|
||||||
source /usr/share/yunohost/helpers
|
source /usr/share/yunohost/helpers
|
||||||
|
|
||||||
|
#=================================================
|
||||||
|
# MANAGE SCRIPT FAILURE
|
||||||
|
#=================================================
|
||||||
|
|
||||||
|
# Exit if an error occurs during the execution of the script
|
||||||
|
ynh_abort_if_errors
|
||||||
|
|
||||||
#=================================================
|
#=================================================
|
||||||
# RETRIEVE ARGUMENTS
|
# RETRIEVE ARGUMENTS
|
||||||
#=================================================
|
#=================================================
|
||||||
|
|
||||||
app=${YNH_APP_INSTANCE_NAME:-$YNH_APP_ID}
|
app=$YNH_APP_INSTANCE_NAME
|
||||||
|
|
||||||
final_path=$(ynh_app_setting_get --app=$app --key=final_path)
|
final_path=$(ynh_app_setting_get --app=$app --key=final_path)
|
||||||
|
|
||||||
|
|
|
@ -9,11 +9,18 @@
|
||||||
source scripts/_common.sh
|
source scripts/_common.sh
|
||||||
source /usr/share/yunohost/helpers
|
source /usr/share/yunohost/helpers
|
||||||
|
|
||||||
|
#=================================================
|
||||||
|
# MANAGE SCRIPT FAILURE
|
||||||
|
#=================================================
|
||||||
|
|
||||||
|
# Exit if an error occurs during the execution of the script
|
||||||
|
ynh_abort_if_errors
|
||||||
|
|
||||||
#=================================================
|
#=================================================
|
||||||
# RETRIEVE ARGUMENTS
|
# RETRIEVE ARGUMENTS
|
||||||
#=================================================
|
#=================================================
|
||||||
|
|
||||||
app=${YNH_APP_INSTANCE_NAME:-$YNH_APP_ID}
|
app=$YNH_APP_INSTANCE_NAME
|
||||||
|
|
||||||
final_path=$(ynh_app_setting_get --app=$app --key=final_path)
|
final_path=$(ynh_app_setting_get --app=$app --key=final_path)
|
||||||
|
|
||||||
|
|
|
@ -9,11 +9,18 @@
|
||||||
source scripts/_common.sh
|
source scripts/_common.sh
|
||||||
source /usr/share/yunohost/helpers
|
source /usr/share/yunohost/helpers
|
||||||
|
|
||||||
|
#=================================================
|
||||||
|
# MANAGE SCRIPT FAILURE
|
||||||
|
#=================================================
|
||||||
|
|
||||||
|
# Exit if an error occurs during the execution of the script
|
||||||
|
ynh_abort_if_errors
|
||||||
|
|
||||||
#=================================================
|
#=================================================
|
||||||
# RETRIEVE ARGUMENTS
|
# RETRIEVE ARGUMENTS
|
||||||
#=================================================
|
#=================================================
|
||||||
|
|
||||||
app=${YNH_APP_INSTANCE_NAME:-$YNH_APP_ID}
|
app=$YNH_APP_INSTANCE_NAME
|
||||||
|
|
||||||
final_path=$(ynh_app_setting_get --app=$app --key=final_path)
|
final_path=$(ynh_app_setting_get --app=$app --key=final_path)
|
||||||
|
|
||||||
|
|
|
@ -1,83 +0,0 @@
|
||||||
#!/bin/bash
|
|
||||||
|
|
||||||
#=================================================
|
|
||||||
# GENERIC STARTING
|
|
||||||
#=================================================
|
|
||||||
# IMPORT GENERIC HELPERS
|
|
||||||
#=================================================
|
|
||||||
|
|
||||||
source scripts/_common.sh
|
|
||||||
source /usr/share/yunohost/helpers
|
|
||||||
|
|
||||||
#=================================================
|
|
||||||
# RETRIEVE ARGUMENTS
|
|
||||||
#=================================================
|
|
||||||
|
|
||||||
# Get is_public
|
|
||||||
is_public=${YNH_ACTION_IS_PUBLIC}
|
|
||||||
|
|
||||||
app=${YNH_APP_INSTANCE_NAME:-$YNH_APP_ID}
|
|
||||||
domain=$(ynh_app_setting_get --app=$app --key=domain)
|
|
||||||
path_url=$(ynh_app_setting_get --app=$app --key=path)
|
|
||||||
|
|
||||||
#=================================================
|
|
||||||
# CHECK IF ARGUMENTS ARE CORRECT
|
|
||||||
#=================================================
|
|
||||||
|
|
||||||
#=================================================
|
|
||||||
# CHECK IF AN ACTION HAS TO BE DONE
|
|
||||||
#=================================================
|
|
||||||
|
|
||||||
is_public_old=$(ynh_app_setting_get --app=$app --key=is_public)
|
|
||||||
|
|
||||||
if [ $is_public -eq $is_public_old ]
|
|
||||||
then
|
|
||||||
ynh_die --message="is_public is already set as $is_public." --ret_code=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="Moving the application to $public_private..." --weight=3
|
|
||||||
|
|
||||||
if [ $is_public -eq 0 ]
|
|
||||||
then
|
|
||||||
# If the app is private, viewing images stays publicly accessible.
|
|
||||||
if [ "$path_url" == "/" ]; then
|
|
||||||
# If the path is /, clear it to prevent any error with the regex.
|
|
||||||
path_url=""
|
|
||||||
fi
|
|
||||||
# Modify the domain to be used in a regex
|
|
||||||
domain_regex=$(echo "$domain" | sed 's@-@.@g')
|
|
||||||
ynh_app_setting_set --app=$app --key=protected_regex --value="$domain_regex$path_url/stats/?$","$domain_regex$path_url/manifest.webapp/?$","$domain_regex$path_url/?$","$domain_regex$path_url/[d-m]/.*$"
|
|
||||||
else
|
|
||||||
ynh_app_setting_delete --app=$app --key=protected_regex
|
|
||||||
fi
|
|
||||||
|
|
||||||
ynh_script_progression --message="Upgrading SSOwat configuration..."
|
|
||||||
# Regen ssowat configuration
|
|
||||||
yunohost app ssowatconf
|
|
||||||
|
|
||||||
# Update the config of the app
|
|
||||||
ynh_app_setting_set --app=$app --key=is_public --value=$is_public
|
|
||||||
|
|
||||||
#=================================================
|
|
||||||
# RELOAD NGINX
|
|
||||||
#=================================================
|
|
||||||
ynh_script_progression --message="Reloading nginx web server..."
|
|
||||||
|
|
||||||
ynh_systemd_action --service_name=nginx --action=reload
|
|
||||||
|
|
||||||
#=================================================
|
|
||||||
# END OF SCRIPT
|
|
||||||
#=================================================
|
|
||||||
|
|
||||||
ynh_script_progression --message="Execution completed" --last
|
|
158
scripts/actions/reset_default_app
Executable file
158
scripts/actions/reset_default_app
Executable file
|
@ -0,0 +1,158 @@
|
||||||
|
#!/bin/bash
|
||||||
|
|
||||||
|
#=================================================
|
||||||
|
# GENERIC STARTING
|
||||||
|
#=================================================
|
||||||
|
# IMPORT GENERIC HELPERS
|
||||||
|
#=================================================
|
||||||
|
|
||||||
|
# Load common variables for all scripts.
|
||||||
|
source scripts/_variables
|
||||||
|
|
||||||
|
source scripts/_common.sh
|
||||||
|
source /usr/share/yunohost/helpers
|
||||||
|
|
||||||
|
#=================================================
|
||||||
|
# MANAGE SCRIPT FAILURE
|
||||||
|
#=================================================
|
||||||
|
|
||||||
|
ynh_clean_setup () {
|
||||||
|
# Clean installation remaining that are not handle by the remove script.
|
||||||
|
ynh_clean_check_starting
|
||||||
|
}
|
||||||
|
# Exit if an error occurs during the execution of the script
|
||||||
|
ynh_abort_if_errors
|
||||||
|
|
||||||
|
#=================================================
|
||||||
|
# RETRIEVE ARGUMENTS
|
||||||
|
#=================================================
|
||||||
|
|
||||||
|
app=$YNH_APP_INSTANCE_NAME
|
||||||
|
|
||||||
|
domain=$(ynh_app_setting_get --app=$app --key=domain)
|
||||||
|
path_url=$(ynh_app_setting_get --app=$app --key=path)
|
||||||
|
is_public=$(ynh_app_setting_get --app=$app --key=is_public)
|
||||||
|
port=$(ynh_app_setting_get --app=$app --key=port)
|
||||||
|
always_encrypt=$(ynh_app_setting_get --app=$app --key=always_encrypt)
|
||||||
|
final_path=$(ynh_app_setting_get --app=$app --key=final_path)
|
||||||
|
secret=$(ynh_app_setting_get --app=$app --key=secret)
|
||||||
|
|
||||||
|
#=================================================
|
||||||
|
# STORE SETTINGS FROM MANIFEST
|
||||||
|
#=================================================
|
||||||
|
|
||||||
|
ynh_app_setting_set --app=$app --key=overwrite_settings --value=1
|
||||||
|
ynh_app_setting_set --app=$app --key=overwrite_nginx --value=1
|
||||||
|
ynh_app_setting_set --app=$app --key=overwrite_systemd --value=1
|
||||||
|
ynh_app_setting_set --app=$app --key=admin_mail_html --value=1
|
||||||
|
|
||||||
|
#=================================================
|
||||||
|
# SPECIFIC ACTION
|
||||||
|
#=================================================
|
||||||
|
# ACTIVATE MAINTENANCE MODE
|
||||||
|
#=================================================
|
||||||
|
ynh_script_progression --message="Activating maintenance mode..."
|
||||||
|
|
||||||
|
ynh_maintenance_mode_ON
|
||||||
|
|
||||||
|
#=================================================
|
||||||
|
# STOP LUTIM
|
||||||
|
#=================================================
|
||||||
|
|
||||||
|
ynh_systemd_action --action=stop
|
||||||
|
|
||||||
|
#=================================================
|
||||||
|
# DOWNLOAD, CHECK AND UNPACK SOURCE
|
||||||
|
#=================================================
|
||||||
|
|
||||||
|
ynh_script_progression --message="Resetting source files..." --weight=2
|
||||||
|
|
||||||
|
# Download, check integrity, uncompress and patch the source from app.src
|
||||||
|
(cd scripts; YNH_CWD=$PWD ynh_setup_source --dest_dir="$final_path")
|
||||||
|
|
||||||
|
#=================================================
|
||||||
|
# NGINX CONFIGURATION
|
||||||
|
#=================================================
|
||||||
|
|
||||||
|
ynh_script_progression --message="Resetting nginx web server configuration..." --weight=4
|
||||||
|
|
||||||
|
# Create a dedicated nginx config
|
||||||
|
yunohost app action run $app reset_default_nginx
|
||||||
|
|
||||||
|
#=================================================
|
||||||
|
# CREATE DEDICATED USER
|
||||||
|
#=================================================
|
||||||
|
ynh_script_progression --message="Making sure dedicated system user exists..."
|
||||||
|
|
||||||
|
# Create a dedicated user (if not existing)
|
||||||
|
ynh_system_user_create --username=$app
|
||||||
|
|
||||||
|
#=================================================
|
||||||
|
# RECONFIGURE APP
|
||||||
|
#=================================================
|
||||||
|
|
||||||
|
ynh_script_progression --message="Reconfiguring Lutim..." --weight=2
|
||||||
|
|
||||||
|
# Configure Lutim
|
||||||
|
# Verify the checksum of a file, stored by `ynh_store_file_checksum` in the install script.
|
||||||
|
ynh_backup_if_checksum_is_different --file="$final_path/lutim.conf"
|
||||||
|
(cd scripts; cp ../conf/lutim.conf.template "$final_path/lutim.conf")
|
||||||
|
ynh_replace_string --match_string="__DOMAIN__" --replace_string="$domain" --target_file="$final_path/lutim.conf"
|
||||||
|
ynh_replace_string --match_string="__PATH__" --replace_string="$path_url" --target_file="$final_path/lutim.conf"
|
||||||
|
ynh_replace_string --match_string="__PORT__" --replace_string="$port" --target_file="$final_path/lutim.conf"
|
||||||
|
ynh_replace_string --match_string="__ENCRYPT__" --replace_string="$always_encrypt" --target_file="$final_path/lutim.conf"
|
||||||
|
ynh_replace_string --match_string="__SECRET__" --replace_string="$secret" --target_file="$final_path/lutim.conf"
|
||||||
|
# Set the number of process for Lutim to twice the number of CPU core.
|
||||||
|
ynh_replace_string --match_string="__WORKERS__" --replace_string="$(( $(nproc) * 2 ))" --target_file="$final_path/lutim.conf"
|
||||||
|
# Recalculate and store the checksum of the file for the next upgrade.
|
||||||
|
ynh_store_file_checksum --file="$final_path/lutim.conf"
|
||||||
|
|
||||||
|
#=================================================
|
||||||
|
# SETUP CRON
|
||||||
|
#=================================================
|
||||||
|
|
||||||
|
(cd scripts; cp ../conf/cron_lutim /etc/cron.d/$app)
|
||||||
|
ynh_replace_string --match_string="__FINALPATH__" --replace_string="$final_path/" --target_file=/etc/cron.d/$app
|
||||||
|
ynh_replace_string --match_string="__APP__" --replace_string="$app" --target_file=/etc/cron.d/$app
|
||||||
|
|
||||||
|
#=================================================
|
||||||
|
# SECURING FILES AND DIRECTORIES
|
||||||
|
#=================================================
|
||||||
|
|
||||||
|
# Set permissions on app files
|
||||||
|
chown -R $app: $final_path
|
||||||
|
|
||||||
|
#=================================================
|
||||||
|
# SETUP SYSTEMD
|
||||||
|
#=================================================
|
||||||
|
|
||||||
|
ynh_script_progression --message="Resetting systemd configuration..."
|
||||||
|
yunohost app action run $app reset_default_systemd
|
||||||
|
|
||||||
|
#=================================================
|
||||||
|
# SETUP LOGROTATE
|
||||||
|
#=================================================
|
||||||
|
ynh_script_progression --message="Resetting logrotate configuration..."
|
||||||
|
|
||||||
|
ynh_use_logrotate --non-append
|
||||||
|
chown $app -R /var/log/$app
|
||||||
|
|
||||||
|
#=================================================
|
||||||
|
# RELOAD NGINX
|
||||||
|
#=================================================
|
||||||
|
ynh_script_progression --message="Reloading nginx web server..."
|
||||||
|
|
||||||
|
ynh_systemd_action --service_name=nginx --action=reload
|
||||||
|
|
||||||
|
#=================================================
|
||||||
|
# DEACTIVE MAINTENANCE MODE
|
||||||
|
#=================================================
|
||||||
|
ynh_script_progression --message="Disabling maintenance mode..."
|
||||||
|
|
||||||
|
ynh_maintenance_mode_OFF
|
||||||
|
|
||||||
|
#=================================================
|
||||||
|
# END OF SCRIPT
|
||||||
|
#=================================================
|
||||||
|
|
||||||
|
ynh_script_progression --message="Execution completed" --last
|
|
@ -9,11 +9,23 @@
|
||||||
source scripts/_common.sh
|
source scripts/_common.sh
|
||||||
source /usr/share/yunohost/helpers
|
source /usr/share/yunohost/helpers
|
||||||
|
|
||||||
|
#=================================================
|
||||||
|
# MANAGE SCRIPT FAILURE
|
||||||
|
#=================================================
|
||||||
|
|
||||||
|
ynh_clean_setup () {
|
||||||
|
# Clean installation remaining that are not handle by the remove script.
|
||||||
|
ynh_clean_check_starting
|
||||||
|
}
|
||||||
|
# Exit if an error occurs during the execution of the script
|
||||||
|
ynh_abort_if_errors
|
||||||
|
|
||||||
#=================================================
|
#=================================================
|
||||||
# RETRIEVE ARGUMENTS
|
# RETRIEVE ARGUMENTS
|
||||||
#=================================================
|
#=================================================
|
||||||
|
|
||||||
app=${YNH_APP_INSTANCE_NAME:-$YNH_APP_ID}
|
app=$YNH_APP_INSTANCE_NAME
|
||||||
|
|
||||||
final_path=$(ynh_app_setting_get --app=$app --key=final_path)
|
final_path=$(ynh_app_setting_get --app=$app --key=final_path)
|
||||||
domain=$(ynh_app_setting_get --app=$app --key=domain)
|
domain=$(ynh_app_setting_get --app=$app --key=domain)
|
||||||
path_url=$(ynh_app_setting_get --app=$app --key=path)
|
path_url=$(ynh_app_setting_get --app=$app --key=path)
|
||||||
|
|
67
scripts/actions/reset_default_system
Executable file
67
scripts/actions/reset_default_system
Executable file
|
@ -0,0 +1,67 @@
|
||||||
|
#!/bin/bash
|
||||||
|
|
||||||
|
#=================================================
|
||||||
|
# GENERIC STARTING
|
||||||
|
#=================================================
|
||||||
|
# IMPORT GENERIC HELPERS
|
||||||
|
#=================================================
|
||||||
|
|
||||||
|
source scripts/_common.sh
|
||||||
|
source /usr/share/yunohost/helpers
|
||||||
|
|
||||||
|
#=================================================
|
||||||
|
# MANAGE SCRIPT FAILURE
|
||||||
|
#=================================================
|
||||||
|
|
||||||
|
ynh_clean_setup () {
|
||||||
|
# Clean installation remaining that are not handle by the remove script.
|
||||||
|
ynh_clean_check_starting
|
||||||
|
}
|
||||||
|
# Exit if an error occurs during the execution of the script
|
||||||
|
ynh_abort_if_errors
|
||||||
|
|
||||||
|
#=================================================
|
||||||
|
# RETRIEVE ARGUMENTS
|
||||||
|
#=================================================
|
||||||
|
|
||||||
|
app=$YNH_APP_INSTANCE_NAME
|
||||||
|
|
||||||
|
type=$1
|
||||||
|
|
||||||
|
domain=$(ynh_app_setting_get --app=$app --key=domain)
|
||||||
|
path_url=$(ynh_app_setting_get --app=$app --key=path)
|
||||||
|
final_path=$(ynh_app_setting_get --app=$app --key=final_path)
|
||||||
|
port=$(ynh_app_setting_get --app=$app --key=port)
|
||||||
|
|
||||||
|
#=================================================
|
||||||
|
# SPECIFIC ACTION
|
||||||
|
#=================================================
|
||||||
|
# RESET THE CONFIG FILE
|
||||||
|
#=================================================
|
||||||
|
|
||||||
|
if [ $type == nginx ]; then
|
||||||
|
name=Nginx
|
||||||
|
elif [ $type == systemd ]; then
|
||||||
|
name=systemd
|
||||||
|
else
|
||||||
|
ynh_die --message="The type $type is not recognized"
|
||||||
|
fi
|
||||||
|
|
||||||
|
ynh_script_progression --message="Resetting the specific configuration of $name for the app $app..." --weight=3
|
||||||
|
|
||||||
|
if [ $type == nginx ]
|
||||||
|
then
|
||||||
|
(cd scripts; ynh_add_nginx_config)
|
||||||
|
|
||||||
|
elif [ $type == systemd ]
|
||||||
|
then
|
||||||
|
ynh_systemd_action --action=stop
|
||||||
|
(cd scripts; ynh_add_systemd_config)
|
||||||
|
ynh_systemd_action --action=restart --line_match="Manager.*started" --log_path="/var/log/$app/production.log" --timeout="300"
|
||||||
|
fi
|
||||||
|
|
||||||
|
#=================================================
|
||||||
|
# END OF SCRIPT
|
||||||
|
#=================================================
|
||||||
|
|
||||||
|
ynh_script_progression --message="Execution completed" --last
|
|
@ -38,6 +38,8 @@ ynh_script_progression --message="Backing up the app before changing its url (ma
|
||||||
# Backup the current version of the app
|
# Backup the current version of the app
|
||||||
ynh_backup_before_upgrade
|
ynh_backup_before_upgrade
|
||||||
ynh_clean_setup () {
|
ynh_clean_setup () {
|
||||||
|
ynh_clean_check_starting
|
||||||
|
|
||||||
# Remove the new domain config file, the remove script won't do it as it doesn't know yet its location.
|
# Remove the new domain config file, the remove script won't do it as it doesn't know yet its location.
|
||||||
ynh_secure_remove --file="/etc/nginx/conf.d/$new_domain.d/$app.conf"
|
ynh_secure_remove --file="/etc/nginx/conf.d/$new_domain.d/$app.conf"
|
||||||
|
|
||||||
|
@ -72,17 +74,6 @@ then
|
||||||
change_path=1
|
change_path=1
|
||||||
fi
|
fi
|
||||||
|
|
||||||
#=================================================
|
|
||||||
# MANAGE FAILURE OF THE SCRIPT
|
|
||||||
#=================================================
|
|
||||||
|
|
||||||
ynh_clean_setup () {
|
|
||||||
# Clean installation remaining that are not handle by the remove script.
|
|
||||||
ynh_clean_check_starting
|
|
||||||
}
|
|
||||||
# Exit if an error occurs during the execution of the script
|
|
||||||
ynh_abort_if_errors
|
|
||||||
|
|
||||||
#=================================================
|
#=================================================
|
||||||
# STANDARD MODIFICATIONS
|
# STANDARD MODIFICATIONS
|
||||||
#=================================================
|
#=================================================
|
||||||
|
@ -122,7 +113,7 @@ fi
|
||||||
#=================================================
|
#=================================================
|
||||||
ynh_script_progression --message="Reconfiguring SSOwat..."
|
ynh_script_progression --message="Reconfiguring SSOwat..."
|
||||||
|
|
||||||
if [ $is_public -eq 0 ]
|
if [ $is_public -eq 0 ] # Only user with a yunohost account can upload an image
|
||||||
then
|
then
|
||||||
# If the app is private, viewing images stays publicly accessible.
|
# If the app is private, viewing images stays publicly accessible.
|
||||||
if [ "$new_path" == "/" ]; then
|
if [ "$new_path" == "/" ]; then
|
||||||
|
|
|
@ -13,7 +13,7 @@ source /usr/share/yunohost/helpers
|
||||||
# RETRIEVE ARGUMENTS
|
# RETRIEVE ARGUMENTS
|
||||||
#=================================================
|
#=================================================
|
||||||
|
|
||||||
app=${YNH_APP_INSTANCE_NAME:-$YNH_APP_ID}
|
app=$YNH_APP_INSTANCE_NAME
|
||||||
|
|
||||||
final_path=$(ynh_app_setting_get --app=$app --key=final_path)
|
final_path=$(ynh_app_setting_get --app=$app --key=final_path)
|
||||||
|
|
||||||
|
@ -43,9 +43,11 @@ get_config_value() {
|
||||||
# always_encrypt
|
# always_encrypt
|
||||||
old_always_encrypt="$(get_config_value always_encrypt)"
|
old_always_encrypt="$(get_config_value always_encrypt)"
|
||||||
always_encrypt="${YNH_CONFIG_MAIN_CONFIGURATION_ALWAYS_ENCRYPT:-$old_always_encrypt}"
|
always_encrypt="${YNH_CONFIG_MAIN_CONFIGURATION_ALWAYS_ENCRYPT:-$old_always_encrypt}"
|
||||||
|
|
||||||
# antiflood
|
# antiflood
|
||||||
old_antiflood="$(get_config_value anti_flood_delay)"
|
old_antiflood="$(get_config_value anti_flood_delay)"
|
||||||
antiflood="${YNH_CONFIG_MAIN_CONFIGURATION_ANTIFLOOD:-$old_antiflood}"
|
antiflood="${YNH_CONFIG_MAIN_CONFIGURATION_ANTIFLOOD:-$old_antiflood}"
|
||||||
|
|
||||||
# delay
|
# delay
|
||||||
old_delay="$(get_config_value default_delay)"
|
old_delay="$(get_config_value default_delay)"
|
||||||
if [ $old_delay -eq 0 ]; then
|
if [ $old_delay -eq 0 ]; then
|
||||||
|
@ -61,10 +63,6 @@ else
|
||||||
fi
|
fi
|
||||||
delay="${YNH_CONFIG_MAIN_CONFIGURATION_DELAY:-$old_delay}"
|
delay="${YNH_CONFIG_MAIN_CONFIGURATION_DELAY:-$old_delay}"
|
||||||
|
|
||||||
# is_public
|
|
||||||
old_is_public="$(ynh_app_setting_get --app=$app --key=is_public)"
|
|
||||||
is_public="${YNH_CONFIG_MAIN_IS_PUBLIC_IS_PUBLIC:-$old_is_public}"
|
|
||||||
|
|
||||||
# Overwrite settings.json file
|
# Overwrite settings.json file
|
||||||
old_overwrite_settings="$(ynh_app_setting_get --app=$app --key=overwrite_settings)"
|
old_overwrite_settings="$(ynh_app_setting_get --app=$app --key=overwrite_settings)"
|
||||||
overwrite_settings="${YNH_CONFIG_MAIN_OVERWRITE_FILES_OVERWRITE_SETTINGS:-$old_overwrite_settings}"
|
overwrite_settings="${YNH_CONFIG_MAIN_OVERWRITE_FILES_OVERWRITE_SETTINGS:-$old_overwrite_settings}"
|
||||||
|
@ -93,8 +91,6 @@ show_config() {
|
||||||
ynh_return "YNH_CONFIG_MAIN_CONFIGURATION_ANTIFLOOD=$antiflood"
|
ynh_return "YNH_CONFIG_MAIN_CONFIGURATION_ANTIFLOOD=$antiflood"
|
||||||
ynh_return "YNH_CONFIG_MAIN_CONFIGURATION_DELAY=$delay"
|
ynh_return "YNH_CONFIG_MAIN_CONFIGURATION_DELAY=$delay"
|
||||||
|
|
||||||
ynh_return "YNH_CONFIG_MAIN_IS_PUBLIC_IS_PUBLIC=$is_public"
|
|
||||||
|
|
||||||
ynh_return "YNH_CONFIG_MAIN_OVERWRITE_FILES_OVERWRITE_SETTINGS=$overwrite_settings"
|
ynh_return "YNH_CONFIG_MAIN_OVERWRITE_FILES_OVERWRITE_SETTINGS=$overwrite_settings"
|
||||||
ynh_return "YNH_CONFIG_MAIN_OVERWRITE_FILES_OVERWRITE_NGINX=$overwrite_nginx"
|
ynh_return "YNH_CONFIG_MAIN_OVERWRITE_FILES_OVERWRITE_NGINX=$overwrite_nginx"
|
||||||
ynh_return "YNH_CONFIG_MAIN_OVERWRITE_FILES_OVERWRITE_SYSTEMD=$overwrite_systemd"
|
ynh_return "YNH_CONFIG_MAIN_OVERWRITE_FILES_OVERWRITE_SYSTEMD=$overwrite_systemd"
|
||||||
|
@ -107,6 +103,11 @@ show_config() {
|
||||||
#=================================================
|
#=================================================
|
||||||
|
|
||||||
apply_config() {
|
apply_config() {
|
||||||
|
|
||||||
|
#=================================================
|
||||||
|
# MODIFY LUTIM CONFIGURATION
|
||||||
|
#=================================================
|
||||||
|
|
||||||
restart_lutim=0
|
restart_lutim=0
|
||||||
|
|
||||||
# Change configuration if needed
|
# Change configuration if needed
|
||||||
|
@ -154,13 +155,9 @@ apply_config() {
|
||||||
ynh_systemd_action --action=restart --line_match="Manager.*started" --log_path="/var/log/$app/production.log" --timeout="120"
|
ynh_systemd_action --action=restart --line_match="Manager.*started" --log_path="/var/log/$app/production.log" --timeout="120"
|
||||||
fi
|
fi
|
||||||
|
|
||||||
# Change public accessibility
|
#=================================================
|
||||||
if [ "$is_public" = "true" ]
|
# MODIFY OVERWRITTING SETTINGS
|
||||||
then
|
#=================================================
|
||||||
yunohost app action run $app public_private --args is_public=1
|
|
||||||
else
|
|
||||||
yunohost app action run $app public_private --args is_public=0
|
|
||||||
fi
|
|
||||||
|
|
||||||
# Set overwrite_settings
|
# Set overwrite_settings
|
||||||
ynh_app_setting_set --app=$app --key=overwrite_settings --value="$overwrite_settings"
|
ynh_app_setting_set --app=$app --key=overwrite_settings --value="$overwrite_settings"
|
||||||
|
@ -169,6 +166,10 @@ apply_config() {
|
||||||
# Set overwrite_systemd
|
# Set overwrite_systemd
|
||||||
ynh_app_setting_set --app=$app --key=overwrite_systemd --value="$overwrite_systemd"
|
ynh_app_setting_set --app=$app --key=overwrite_systemd --value="$overwrite_systemd"
|
||||||
|
|
||||||
|
#=================================================
|
||||||
|
# MODIFY EMAIL SETTING
|
||||||
|
#=================================================
|
||||||
|
|
||||||
# Set admin_mail_html
|
# Set admin_mail_html
|
||||||
ynh_app_setting_set --app=$app --key=admin_mail_html --value="$admin_mail_html"
|
ynh_app_setting_set --app=$app --key=admin_mail_html --value="$admin_mail_html"
|
||||||
}
|
}
|
||||||
|
|
|
@ -6,11 +6,12 @@
|
||||||
# IMPORT GENERIC HELPERS
|
# IMPORT GENERIC HELPERS
|
||||||
#=================================================
|
#=================================================
|
||||||
|
|
||||||
source _common.sh
|
|
||||||
source /usr/share/yunohost/helpers
|
|
||||||
# Load common variables for all scripts.
|
# Load common variables for all scripts.
|
||||||
source _variables
|
source _variables
|
||||||
|
|
||||||
|
source _common.sh
|
||||||
|
source /usr/share/yunohost/helpers
|
||||||
|
|
||||||
#=================================================
|
#=================================================
|
||||||
# MANAGE FAILURE OF THE SCRIPT
|
# MANAGE FAILURE OF THE SCRIPT
|
||||||
#=================================================
|
#=================================================
|
||||||
|
@ -121,6 +122,13 @@ ynh_replace_string --match_string="__WORKERS__" --replace_string="$(( $(nproc) *
|
||||||
# Calculate and store the config file checksum into the app settings
|
# Calculate and store the config file checksum into the app settings
|
||||||
ynh_store_file_checksum --file="$final_path/lutim.conf"
|
ynh_store_file_checksum --file="$final_path/lutim.conf"
|
||||||
|
|
||||||
|
#=================================================
|
||||||
|
# SETUP HOOKS FILE
|
||||||
|
#=================================================
|
||||||
|
|
||||||
|
ynh_replace_string --match_string="__APP__" --replace_string="$app" --target_file="../hooks/post_app_addaccess"
|
||||||
|
ynh_replace_string --match_string="__APP__" --replace_string="$app" --target_file="../hooks/post_app_removeaccess"
|
||||||
|
|
||||||
#=================================================
|
#=================================================
|
||||||
# SETUP SYSTEMD
|
# SETUP SYSTEMD
|
||||||
#=================================================
|
#=================================================
|
||||||
|
@ -192,7 +200,13 @@ yunohost service add $app --log $final_path/log/production.log
|
||||||
#=================================================
|
#=================================================
|
||||||
ynh_script_progression --message="Configuring SSOwat..."
|
ynh_script_progression --message="Configuring SSOwat..."
|
||||||
|
|
||||||
ynh_app_setting_set --app=$app --key=unprotected_uris --value="/"
|
ynh_permission_update --permission="main" --add="visitors"
|
||||||
|
|
||||||
|
# This is a fake permission without any URL.
|
||||||
|
# The purpose of this permission is only to trigger hooks post_app_add/removeaccess when it's modified.
|
||||||
|
# We can't use a real permission for now because the actual permision system doesn't support regex.
|
||||||
|
ynh_permission_create --permission="upload images" --allowed="visitors"
|
||||||
|
|
||||||
if [ $is_public -eq 0 ]
|
if [ $is_public -eq 0 ]
|
||||||
then
|
then
|
||||||
# If the app is private, viewing images stays publicly accessible.
|
# If the app is private, viewing images stays publicly accessible.
|
||||||
|
@ -203,6 +217,9 @@ then
|
||||||
# Modify the domain to be used in a regex
|
# Modify the domain to be used in a regex
|
||||||
domain_regex=$(echo "$domain" | sed 's@-@.@g')
|
domain_regex=$(echo "$domain" | sed 's@-@.@g')
|
||||||
ynh_app_setting_set --app=$app --key=protected_regex --value="$domain_regex$path_url/stats/?$","$domain_regex$path_url/manifest.webapp/?$","$domain_regex$path_url/?$","$domain_regex$path_url/[d-m]/.*$"
|
ynh_app_setting_set --app=$app --key=protected_regex --value="$domain_regex$path_url/stats/?$","$domain_regex$path_url/manifest.webapp/?$","$domain_regex$path_url/?$","$domain_regex$path_url/[d-m]/.*$"
|
||||||
|
|
||||||
|
# If the app is not public, then the "visitors" group doesn't have this permission
|
||||||
|
ynh_permission_update --permission="upload images" --remove="visitors"
|
||||||
fi
|
fi
|
||||||
|
|
||||||
#=================================================
|
#=================================================
|
||||||
|
@ -219,10 +236,14 @@ ynh_script_progression --message="Restarting Lutim..." --weight=6
|
||||||
|
|
||||||
# Wait for lutim to be fully started
|
# Wait for lutim to be fully started
|
||||||
ynh_systemd_action --action=restart --line_match="Manager.*started" --log_path="/var/log/$app/production.log" --timeout="120"
|
ynh_systemd_action --action=restart --line_match="Manager.*started" --log_path="/var/log/$app/production.log" --timeout="120"
|
||||||
|
ynh_systemd_action --action=stop
|
||||||
|
|
||||||
# Set right permissions on new files created at first start
|
# Set right permissions on new files created at first start
|
||||||
chown -R $app: $final_path
|
chown -R $app: $final_path
|
||||||
|
|
||||||
|
# Wait for lutim to be fully started
|
||||||
|
ynh_systemd_action --action=restart --line_match="Manager.*started" --log_path="/var/log/$app/production.log" --timeout="120"
|
||||||
|
|
||||||
#=================================================
|
#=================================================
|
||||||
# SEND A README FOR THE ADMIN
|
# SEND A README FOR THE ADMIN
|
||||||
#=================================================
|
#=================================================
|
||||||
|
@ -243,4 +264,4 @@ ynh_send_readme_to_admin --app_message="mail_to_send" --recipients="root" --type
|
||||||
# END OF SCRIPT
|
# END OF SCRIPT
|
||||||
#=================================================
|
#=================================================
|
||||||
|
|
||||||
ynh_script_progression --message="Installation of $app completed" --time --last
|
ynh_script_progression --message="Installation of $app completed" --last
|
||||||
|
|
|
@ -94,4 +94,4 @@ ynh_system_user_delete --username=$app
|
||||||
# END OF SCRIPT
|
# END OF SCRIPT
|
||||||
#=================================================
|
#=================================================
|
||||||
|
|
||||||
ynh_script_progression --message="Removal of $app completed" --time --last
|
ynh_script_progression --message="Removal of $app completed" --last
|
||||||
|
|
|
@ -6,11 +6,12 @@
|
||||||
# IMPORT GENERIC HELPERS
|
# IMPORT GENERIC HELPERS
|
||||||
#=================================================
|
#=================================================
|
||||||
|
|
||||||
source ../settings/scripts/_common.sh
|
|
||||||
source /usr/share/yunohost/helpers
|
|
||||||
# Load common variables for all scripts.
|
# Load common variables for all scripts.
|
||||||
source ../settings/scripts/_variables
|
source ../settings/scripts/_variables
|
||||||
|
|
||||||
|
source ../settings/scripts/_common.sh
|
||||||
|
source /usr/share/yunohost/helpers
|
||||||
|
|
||||||
#=================================================
|
#=================================================
|
||||||
# MANAGE SCRIPT FAILURE
|
# MANAGE SCRIPT FAILURE
|
||||||
#=================================================
|
#=================================================
|
||||||
|
|
|
@ -6,11 +6,12 @@
|
||||||
# IMPORT GENERIC HELPERS
|
# IMPORT GENERIC HELPERS
|
||||||
#=================================================
|
#=================================================
|
||||||
|
|
||||||
source _common.sh
|
|
||||||
source /usr/share/yunohost/helpers
|
|
||||||
# Load common variables for all scripts.
|
# Load common variables for all scripts.
|
||||||
source _variables
|
source _variables
|
||||||
|
|
||||||
|
source _common.sh
|
||||||
|
source /usr/share/yunohost/helpers
|
||||||
|
|
||||||
#=================================================
|
#=================================================
|
||||||
# LOAD SETTINGS
|
# LOAD SETTINGS
|
||||||
#=================================================
|
#=================================================
|
||||||
|
@ -55,6 +56,37 @@ elif [ "$is_public" = "No" ]; then
|
||||||
is_public=0
|
is_public=0
|
||||||
fi
|
fi
|
||||||
|
|
||||||
|
skipped_uris=$(ynh_app_setting_get --app=$app --key=skipped_uris)
|
||||||
|
|
||||||
|
# Unused with the permission system
|
||||||
|
if [ ! -z "$skipped_uris" ]; then
|
||||||
|
ynh_app_setting_delete --app=$app --key=skipped_uris
|
||||||
|
fi
|
||||||
|
|
||||||
|
# Create the permission "upload images" only if it doesn't exist.
|
||||||
|
if ! ynh_permission_exists --permission="upload images"
|
||||||
|
then
|
||||||
|
# This is a fake permission without any URL.
|
||||||
|
# The purpose of this permission is only to trigger hooks post_app_add/removeaccess when it's modified.
|
||||||
|
# We can't use a real permission for now because the actual permision system doesn't support regex.
|
||||||
|
ynh_permission_create --permission="upload images" --allowed="visitors"
|
||||||
|
|
||||||
|
if [ $is_public -eq 0 ]
|
||||||
|
then
|
||||||
|
# If the app is private, viewing images stays publicly accessible.
|
||||||
|
if [ "$path_url" == "/" ]; then
|
||||||
|
# If the path is /, clear it to prevent any error with the regex.
|
||||||
|
path_url=""
|
||||||
|
fi
|
||||||
|
# Modify the domain to be used in a regex
|
||||||
|
domain_regex=$(echo "$domain" | sed 's@-@.@g')
|
||||||
|
ynh_app_setting_set --app=$app --key=protected_regex --value="$domain_regex$path_url/stats/?$","$domain_regex$path_url/manifest.webapp/?$","$domain_regex$path_url/?$","$domain_regex$path_url/[d-m]/.*$"
|
||||||
|
|
||||||
|
# If the app is not public, then the "visitors" group doesn't have this permission
|
||||||
|
ynh_permission_update --permission="upload images" --remove="visitors"
|
||||||
|
fi
|
||||||
|
fi
|
||||||
|
|
||||||
# if final_path isn't set, which can happens with old scripts, set final_path.
|
# if final_path isn't set, which can happens with old scripts, set final_path.
|
||||||
if [ -z "$final_path" ]; then
|
if [ -z "$final_path" ]; then
|
||||||
final_path=/var/www/$app
|
final_path=/var/www/$app
|
||||||
|
@ -178,7 +210,7 @@ ynh_system_user_create --username=$app
|
||||||
#=================================================
|
#=================================================
|
||||||
# SETUP LUTIM
|
# SETUP LUTIM
|
||||||
#=================================================
|
#=================================================
|
||||||
ynh_script_progression --message="Reconfigure Lutim"
|
ynh_script_progression --message="Reconfiguring Lutim..."
|
||||||
|
|
||||||
# Overwrite the settings config file only if it's allowed
|
# Overwrite the settings config file only if it's allowed
|
||||||
if [ $overwrite_settings -eq 1 ]
|
if [ $overwrite_settings -eq 1 ]
|
||||||
|
@ -210,6 +242,13 @@ then
|
||||||
fi
|
fi
|
||||||
fi
|
fi
|
||||||
|
|
||||||
|
#=================================================
|
||||||
|
# SETUP HOOKS FILE
|
||||||
|
#=================================================
|
||||||
|
|
||||||
|
ynh_replace_string --match_string="__APP__" --replace_string="$app" --target_file="../hooks/post_app_addaccess"
|
||||||
|
ynh_replace_string --match_string="__APP__" --replace_string="$app" --target_file="../hooks/post_app_removeaccess"
|
||||||
|
|
||||||
#=================================================
|
#=================================================
|
||||||
# SETUP SYSTEMD
|
# SETUP SYSTEMD
|
||||||
#=================================================
|
#=================================================
|
||||||
|
@ -257,20 +296,6 @@ ynh_script_progression --message="Upgrading logrotate configuration..."
|
||||||
ynh_use_logrotate --non-append
|
ynh_use_logrotate --non-append
|
||||||
chown $app -R /var/log/$app
|
chown $app -R /var/log/$app
|
||||||
|
|
||||||
#=================================================
|
|
||||||
# SETUP SSOWAT
|
|
||||||
#=================================================
|
|
||||||
ynh_script_progression --message="Upgrading SSOwat configuration..."
|
|
||||||
|
|
||||||
ynh_app_setting_set --app=$app --key=unprotected_uris --value="/"
|
|
||||||
if [ $is_public -eq 0 ]
|
|
||||||
then
|
|
||||||
# If the app is private, viewing images stays publicly accessible.
|
|
||||||
# Modify the domain to be used in a regex
|
|
||||||
domain_regex=$(echo "$domain" | sed 's@-@.@g')
|
|
||||||
ynh_app_setting_set --app=$app --key=protected_regex --value="$domain_regex$path_url/stats/?$","$domain_regex$path_url/manifest.webapp/?$","$domain_regex$path_url/?$","$domain_regex$path_url/[d-m]/.*$"
|
|
||||||
fi
|
|
||||||
|
|
||||||
#=================================================
|
#=================================================
|
||||||
# RELOAD NGINX
|
# RELOAD NGINX
|
||||||
#=================================================
|
#=================================================
|
||||||
|
|
Loading…
Add table
Reference in a new issue