mirror of
https://github.com/YunoHost-Apps/lutim_ynh.git
synced 2024-09-03 19:36:24 +02:00
commit
a019dac8de
17 changed files with 94 additions and 720 deletions
|
@ -1,6 +1,7 @@
|
|||
# All available README files by language
|
||||
|
||||
- [Read the README in English](README.md)
|
||||
- [Irakurri README euskaraz](README_eu.md)
|
||||
- [Lire le README en français](README_fr.md)
|
||||
- [Le o README en galego](README_gl.md)
|
||||
- [Leggi il “README” in italiano](README_it.md)
|
||||
- [阅读中文(简体)的 README](README_zh_Hans.md)
|
||||
|
|
|
@ -9,7 +9,7 @@ It shall NOT be edited by hand.
|
|||
|
||||
[![Install Lutim with YunoHost](https://install-app.yunohost.org/install-with-yunohost.svg)](https://install-app.yunohost.org/?app=lutim)
|
||||
|
||||
*[Read this README is other languages.](./ALL_README.md)*
|
||||
*[Read this README in other languages.](./ALL_README.md)*
|
||||
|
||||
> *This package allows you to install Lutim quickly and simply on a YunoHost server.*
|
||||
> *If you don't have YunoHost, please consult [the guide](https://yunohost.org/install) to learn how to install it.*
|
||||
|
|
45
README_eu.md
Normal file
45
README_eu.md
Normal file
|
@ -0,0 +1,45 @@
|
|||
<!--
|
||||
Ohart ongi: README hau automatikoki sortu da <https://github.com/YunoHost/apps/tree/master/tools/readme_generator>ri esker
|
||||
EZ editatu eskuz.
|
||||
-->
|
||||
|
||||
# Lutim YunoHost-erako
|
||||
|
||||
[![Integrazio maila](https://dash.yunohost.org/integration/lutim.svg)](https://dash.yunohost.org/appci/app/lutim) ![Funtzionamendu egoera](https://ci-apps.yunohost.org/ci/badges/lutim.status.svg) ![Mantentze egoera](https://ci-apps.yunohost.org/ci/badges/lutim.maintain.svg)
|
||||
|
||||
[![Instalatu Lutim YunoHost-ekin](https://install-app.yunohost.org/install-with-yunohost.svg)](https://install-app.yunohost.org/?app=lutim)
|
||||
|
||||
*[Irakurri README hau beste hizkuntzatan.](./ALL_README.md)*
|
||||
|
||||
> *Pakete honek Lutim YunoHost zerbitzari batean azkar eta zailtasunik gabe instalatzea ahalbidetzen dizu.*
|
||||
> *YunoHost ez baduzu, kontsultatu [gida](https://yunohost.org/install) nola instalatu ikasteko.*
|
||||
|
||||
## Aurreikuspena
|
||||
|
||||
Lutim stores images and allows you to see them, download them or share them on social networks.
|
||||
Images are indefinitely stored unless you request that they will be deleted at first view or after 24 hours / one week / one month / one year.
|
||||
|
||||
**Paketatutako bertsioa:** 0.12.1~ynh5
|
||||
|
||||
**Demoa:** <https://lut.im/>
|
||||
## Dokumentazioa eta baliabideak
|
||||
|
||||
- Aplikazioaren webgune ofiziala: <https://lut.im>
|
||||
- Erabiltzaileen dokumentazio ofiziala: <https://framagit.org/luc/lutim/wikis/home>
|
||||
- Jatorrizko aplikazioaren kode-gordailua: <https://framagit.org/fiat-tux/hat-softwares/lutim>
|
||||
- YunoHost Denda: <https://apps.yunohost.org/app/lutim>
|
||||
- Eman errore baten berri: <https://github.com/YunoHost-Apps/lutim_ynh/issues>
|
||||
|
||||
## Garatzaileentzako informazioa
|
||||
|
||||
Bidali `pull request`a [`testing` abarrera](https://github.com/YunoHost-Apps/lutim_ynh/tree/testing).
|
||||
|
||||
`testing` abarra probatzeko, ondorengoa egin:
|
||||
|
||||
```bash
|
||||
sudo yunohost app install https://github.com/YunoHost-Apps/lutim_ynh/tree/testing --debug
|
||||
edo
|
||||
sudo yunohost app upgrade lutim -u https://github.com/YunoHost-Apps/lutim_ynh/tree/testing --debug
|
||||
```
|
||||
|
||||
**Informazio gehiago aplikazioaren paketatzeari buruz:** <https://yunohost.org/packaging_apps>
|
45
README_zh_Hans.md
Normal file
45
README_zh_Hans.md
Normal file
|
@ -0,0 +1,45 @@
|
|||
<!--
|
||||
注意:此 README 由 <https://github.com/YunoHost/apps/tree/master/tools/readme_generator> 自动生成
|
||||
请勿手动编辑。
|
||||
-->
|
||||
|
||||
# YunoHost 的 Lutim
|
||||
|
||||
[![集成程度](https://dash.yunohost.org/integration/lutim.svg)](https://dash.yunohost.org/appci/app/lutim) ![工作状态](https://ci-apps.yunohost.org/ci/badges/lutim.status.svg) ![维护状态](https://ci-apps.yunohost.org/ci/badges/lutim.maintain.svg)
|
||||
|
||||
[![使用 YunoHost 安装 Lutim](https://install-app.yunohost.org/install-with-yunohost.svg)](https://install-app.yunohost.org/?app=lutim)
|
||||
|
||||
*[阅读此 README 的其它语言版本。](./ALL_README.md)*
|
||||
|
||||
> *通过此软件包,您可以在 YunoHost 服务器上快速、简单地安装 Lutim。*
|
||||
> *如果您还没有 YunoHost,请参阅[指南](https://yunohost.org/install)了解如何安装它。*
|
||||
|
||||
## 概况
|
||||
|
||||
Lutim stores images and allows you to see them, download them or share them on social networks.
|
||||
Images are indefinitely stored unless you request that they will be deleted at first view or after 24 hours / one week / one month / one year.
|
||||
|
||||
**分发版本:** 0.12.1~ynh5
|
||||
|
||||
**演示:** <https://lut.im/>
|
||||
## 文档与资源
|
||||
|
||||
- 官方应用网站: <https://lut.im>
|
||||
- 官方用户文档: <https://framagit.org/luc/lutim/wikis/home>
|
||||
- 上游应用代码库: <https://framagit.org/fiat-tux/hat-softwares/lutim>
|
||||
- YunoHost 商店: <https://apps.yunohost.org/app/lutim>
|
||||
- 报告 bug: <https://github.com/YunoHost-Apps/lutim_ynh/issues>
|
||||
|
||||
## 开发者信息
|
||||
|
||||
请向 [`testing` 分支](https://github.com/YunoHost-Apps/lutim_ynh/tree/testing) 发送拉取请求。
|
||||
|
||||
如要尝试 `testing` 分支,请这样操作:
|
||||
|
||||
```bash
|
||||
sudo yunohost app install 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
|
||||
```
|
||||
|
||||
**有关应用打包的更多信息:** <https://yunohost.org/packaging_apps>
|
52
actions.toml
52
actions.toml
|
@ -1,52 +0,0 @@
|
|||
[clean_ip]
|
||||
name = "Clean old ip from database"
|
||||
command = "/bin/bash scripts/actions/clean_ip"
|
||||
accepted_return_codes = [0]
|
||||
description = "Remove obsolete IP from the database."
|
||||
|
||||
[clean_images]
|
||||
name = "Clean old images"
|
||||
command = "/bin/bash scripts/actions/clean_images"
|
||||
accepted_return_codes = [0]
|
||||
description = "Remove expired images."
|
||||
|
||||
[check_quota]
|
||||
name = "Check disk quota"
|
||||
command = "/bin/bash scripts/actions/check_quota"
|
||||
accepted_return_codes = [0]
|
||||
description = "Check the disk quota for images stored by Lutim."
|
||||
|
||||
[reset_default_config]
|
||||
name = "Reset the config file and restore a default one."
|
||||
command = "/bin/bash scripts/actions/reset_default_config \"lutim.conf\""
|
||||
accepted_return_codes = [0]
|
||||
description = "Reset the config file lutim.conf."
|
||||
|
||||
|
||||
[reset_default_nginx]
|
||||
name = "Reset the nginx config for this app."
|
||||
command = "/bin/bash scripts/actions/reset_default_system nginx"
|
||||
# user = "root" # optional
|
||||
# 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."
|
|
@ -1,26 +0,0 @@
|
|||
;; Test complet
|
||||
; Manifest
|
||||
domain="domain.tld"
|
||||
path="/path"
|
||||
is_public=1
|
||||
always_encrypt=1
|
||||
; Checks
|
||||
pkg_linter=1
|
||||
setup_sub_dir=1
|
||||
setup_root=1
|
||||
setup_nourl=0
|
||||
setup_private=1
|
||||
setup_public=1
|
||||
upgrade=1
|
||||
upgrade=1 from_commit=ec8858ed0d054049a0c8f46c6126ee8ae0798e8f
|
||||
backup_restore=1
|
||||
multi_instance=0
|
||||
port_already_use=0
|
||||
change_url=1
|
||||
;;; Options
|
||||
Email=
|
||||
Notification=none
|
||||
;;; Upgrade options
|
||||
; commit=ec8858ed0d054049a0c8f46c6126ee8ae0798e8f
|
||||
name=22 May 2020 ec8858ed0d054049a0c8f46c6126ee8ae0798e8f
|
||||
manifest_arg=domain=DOMAIN&path=PATH&admin=USER&is_public=1&always_encrypt=1&
|
|
@ -1,55 +0,0 @@
|
|||
version = "0.1"
|
||||
name = "Lutim configuration panel"
|
||||
|
||||
[main]
|
||||
name = "Lutim configuration"
|
||||
|
||||
[main.configuration]
|
||||
name = "Lutim configuration"
|
||||
|
||||
[main.configuration.always_encrypt]
|
||||
ask = "Force the encryption of images?"
|
||||
type = "boolean"
|
||||
default = true
|
||||
|
||||
[main.configuration.antiflood]
|
||||
ask = "Anti-flood protection delay (seconds)"
|
||||
type = "number"
|
||||
default = 0
|
||||
help = "Users won't be able to ask Lutim to download images more than one per anti_flood_delay seconds."
|
||||
|
||||
[main.configuration.delay]
|
||||
ask = "Default time limit for files"
|
||||
choices = ["None", "Day", "Week", "Month", "Year"]
|
||||
default = "Year"
|
||||
help = "Users won't be able to ask Lutim to download images more than one per anti_flood_delay seconds."
|
||||
|
||||
[main.overwrite_files]
|
||||
name = "Overwriting config files"
|
||||
|
||||
[main.overwrite_files.overwrite_settings]
|
||||
ask = "Overwrite the config file lutim.conf?"
|
||||
type = "boolean"
|
||||
default = true
|
||||
help = "If the file is overwritten, a backup will be created."
|
||||
|
||||
[main.overwrite_files.overwrite_nginx]
|
||||
ask = "Overwrite the nginx config file?"
|
||||
type = "boolean"
|
||||
default = true
|
||||
help = "If the file is overwritten, a backup will be created."
|
||||
|
||||
[main.overwrite_files.overwrite_systemd]
|
||||
ask = "Overwrite the systemd config file?"
|
||||
type = "boolean"
|
||||
default = true
|
||||
help = "If the file is overwritten, a backup will be created."
|
||||
|
||||
[main.global_config]
|
||||
name = "Global configuration"
|
||||
|
||||
[main.global_config.email_type]
|
||||
ask = "Send HTML email to admin?"
|
||||
type = "boolean"
|
||||
default = true
|
||||
help = "Allow app scripts to send HTML mails instead of plain text."
|
|
@ -1,26 +0,0 @@
|
|||
#!/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
|
|
@ -1,34 +0,0 @@
|
|||
#!/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
|
|
@ -50,6 +50,7 @@ ram.runtime = "50M"
|
|||
[resources.sources.main]
|
||||
url = "https://framagit.org/fiat-tux/hat-softwares/lutim/-/archive/0.12.1/lutim-0.12.1.tar.gz"
|
||||
sha256 = "141f142d47e3a8367e0c292304ddbecfc34b49ae7e561e2c3526000040318973"
|
||||
autoupdate.strategy = "latest_gitlab_release"
|
||||
|
||||
[resources.ports]
|
||||
|
||||
|
|
|
@ -92,75 +92,3 @@ ynh_maintenance_mode_OFF () {
|
|||
}
|
||||
|
||||
|
||||
#=================================================
|
||||
|
||||
# Check the amount of available RAM
|
||||
#
|
||||
# usage: ynh_check_ram [--required=RAM required in Mb] [--no_swap|--only_swap] [--free_ram]
|
||||
# | arg: -r, --required= - Amount of RAM required in Mb. The helper will return 0 is there's enough RAM, or 1 otherwise.
|
||||
# If --required isn't set, the helper will print the amount of RAM, in Mb.
|
||||
# | arg: -s, --no_swap - Ignore swap
|
||||
# | arg: -o, --only_swap - Ignore real RAM, consider only swap.
|
||||
# | arg: -f, --free_ram - Count only free RAM, not the total amount of RAM available.
|
||||
ynh_check_ram () {
|
||||
# Declare an array to define the options of this helper.
|
||||
declare -Ar args_array=( [r]=required= [s]=no_swap [o]=only_swap [f]=free_ram )
|
||||
local required
|
||||
local no_swap
|
||||
local only_swap
|
||||
# Manage arguments with getopts
|
||||
ynh_handle_getopts_args "$@"
|
||||
required=${required:-}
|
||||
no_swap=${no_swap:-0}
|
||||
only_swap=${only_swap:-0}
|
||||
|
||||
local total_ram=$(vmstat --stats --unit M | grep "total memory" | awk '{print $1}')
|
||||
local total_swap=$(vmstat --stats --unit M | grep "total swap" | awk '{print $1}')
|
||||
local total_ram_swap=$(( total_ram + total_swap ))
|
||||
|
||||
local free_ram=$(vmstat --stats --unit M | grep "free memory" | awk '{print $1}')
|
||||
local free_swap=$(vmstat --stats --unit M | grep "free swap" | awk '{print $1}')
|
||||
local free_ram_swap=$(( free_ram + free_swap ))
|
||||
|
||||
# Use the total amount of ram
|
||||
local ram=$total_ram_swap
|
||||
if [ $free_ram -eq 1 ]
|
||||
then
|
||||
# Use the total amount of free ram
|
||||
ram=$free_ram_swap
|
||||
if [ $no_swap -eq 1 ]
|
||||
then
|
||||
# Use only the amount of free ram
|
||||
ram=$free_ram
|
||||
elif [ $only_swap -eq 1 ]
|
||||
then
|
||||
# Use only the amount of free swap
|
||||
ram=$free_swap
|
||||
fi
|
||||
else
|
||||
if [ $no_swap -eq 1 ]
|
||||
then
|
||||
# Use only the amount of free ram
|
||||
ram=$total_ram
|
||||
elif [ $only_swap -eq 1 ]
|
||||
then
|
||||
# Use only the amount of free swap
|
||||
ram=$total_swap
|
||||
fi
|
||||
fi
|
||||
|
||||
if [ -n "$required" ]
|
||||
then
|
||||
# Return 1 if the amount of ram isn't enough.
|
||||
if [ $ram -lt $required ]
|
||||
then
|
||||
return 1
|
||||
else
|
||||
return 0
|
||||
fi
|
||||
|
||||
# If no RAM is required, return the amount of available ram.
|
||||
else
|
||||
echo $ram
|
||||
fi
|
||||
}
|
||||
|
|
|
@ -1,48 +0,0 @@
|
|||
#!/bin/bash
|
||||
|
||||
#=================================================
|
||||
# GENERIC STARTING
|
||||
#=================================================
|
||||
# IMPORT GENERIC HELPERS
|
||||
#=================================================
|
||||
|
||||
source scripts/_common.sh
|
||||
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
|
||||
#=================================================
|
||||
|
||||
app=$YNH_APP_INSTANCE_NAME
|
||||
|
||||
final_path=$(ynh_app_setting_get --app=$app --key=final_path)
|
||||
|
||||
#=================================================
|
||||
# CHECK IF ARGUMENTS ARE CORRECT
|
||||
#=================================================
|
||||
|
||||
#=================================================
|
||||
# CHECK IF AN ACTION HAS TO BE DONE
|
||||
#=================================================
|
||||
|
||||
#=================================================
|
||||
# SPECIFIC ACTION
|
||||
#=================================================
|
||||
# CHECK THE DISK QUOTA FOR IMAGES STORED BY LUTIM
|
||||
#=================================================
|
||||
ynh_script_progression --message="Checking the disk quota for images stored by lutim..." --weight=9
|
||||
|
||||
(cd "$final_path" && ynh_exec_as $app $(which carton) exec script/lutim cron watch)
|
||||
|
||||
#=================================================
|
||||
# END OF SCRIPT
|
||||
#=================================================
|
||||
|
||||
ynh_script_progression --message="Execution completed" --last
|
|
@ -1,48 +0,0 @@
|
|||
#!/bin/bash
|
||||
|
||||
#=================================================
|
||||
# GENERIC STARTING
|
||||
#=================================================
|
||||
# IMPORT GENERIC HELPERS
|
||||
#=================================================
|
||||
|
||||
source scripts/_common.sh
|
||||
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
|
||||
#=================================================
|
||||
|
||||
app=$YNH_APP_INSTANCE_NAME
|
||||
|
||||
final_path=$(ynh_app_setting_get --app=$app --key=final_path)
|
||||
|
||||
#=================================================
|
||||
# CHECK IF ARGUMENTS ARE CORRECT
|
||||
#=================================================
|
||||
|
||||
#=================================================
|
||||
# CHECK IF AN ACTION HAS TO BE DONE
|
||||
#=================================================
|
||||
|
||||
#=================================================
|
||||
# SPECIFIC ACTION
|
||||
#=================================================
|
||||
# REMOVE EXPIRED IMAGES
|
||||
#=================================================
|
||||
ynh_script_progression --message="Removing expired images..." --weight=9
|
||||
|
||||
(cd "$final_path" && ynh_exec_as $app $(which carton) exec script/lutim cron cleanfiles)
|
||||
|
||||
#=================================================
|
||||
# END OF SCRIPT
|
||||
#=================================================
|
||||
|
||||
ynh_script_progression --message="Execution completed" --last
|
|
@ -1,48 +0,0 @@
|
|||
#!/bin/bash
|
||||
|
||||
#=================================================
|
||||
# GENERIC STARTING
|
||||
#=================================================
|
||||
# IMPORT GENERIC HELPERS
|
||||
#=================================================
|
||||
|
||||
source scripts/_common.sh
|
||||
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
|
||||
#=================================================
|
||||
|
||||
app=$YNH_APP_INSTANCE_NAME
|
||||
|
||||
final_path=$(ynh_app_setting_get --app=$app --key=final_path)
|
||||
|
||||
#=================================================
|
||||
# CHECK IF ARGUMENTS ARE CORRECT
|
||||
#=================================================
|
||||
|
||||
#=================================================
|
||||
# CHECK IF AN ACTION HAS TO BE DONE
|
||||
#=================================================
|
||||
|
||||
#=================================================
|
||||
# SPECIFIC ACTION
|
||||
#=================================================
|
||||
# REMOVE OBSOLETE IP FROM THE DATABASE
|
||||
#=================================================
|
||||
ynh_script_progression --message="Removing obsolete ip from the database..." --weight=9
|
||||
|
||||
(cd "$final_path" && ynh_exec_as $app $(which carton) exec script/lutim cron cleanbdd)
|
||||
|
||||
#=================================================
|
||||
# END OF SCRIPT
|
||||
#=================================================
|
||||
|
||||
ynh_script_progression --message="Execution completed" --last
|
|
@ -1,158 +0,0 @@
|
|||
#!/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
|
|
@ -1,84 +0,0 @@
|
|||
#!/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
|
||||
|
||||
final_path=$(ynh_app_setting_get --app=$app --key=final_path)
|
||||
domain=$(ynh_app_setting_get --app=$app --key=domain)
|
||||
path_url=$(ynh_app_setting_get --app=$app --key=path)
|
||||
port=$(ynh_app_setting_get --app=$app --key=port)
|
||||
always_encrypt=$(ynh_app_setting_get --app=$app --key=always_encrypt)
|
||||
secret=$(ynh_app_setting_get --app=$app --key=secret)
|
||||
|
||||
#=================================================
|
||||
# SORT OUT THE CONFIG FILE TO HANDLE
|
||||
#=================================================
|
||||
|
||||
file="$1"
|
||||
|
||||
if [ "$file" = "lutim.conf" ]; then
|
||||
config_file="$final_path/lutim.conf"
|
||||
fi
|
||||
|
||||
#=================================================
|
||||
# SPECIFIC ACTION
|
||||
#=================================================
|
||||
# RESET THE CONFIG FILE
|
||||
#=================================================
|
||||
ynh_script_progression --message="Resetting the config file $config_file..." --weight=9
|
||||
|
||||
# Verify the checksum and backup the file if it's different
|
||||
ynh_backup_if_checksum_is_different --file="$config_file"
|
||||
|
||||
if [ "$file" = "lutim.conf" ]
|
||||
then
|
||||
# Get the default file and overwrite the current config
|
||||
cp /etc/yunohost/apps/$app/conf/lutim.conf.template "$config_file"
|
||||
|
||||
# Recreate the default config
|
||||
ynh_replace_string --match_string="__DOMAIN__" --replace_string="$domain" --target_file="$config_file"
|
||||
ynh_replace_string --match_string="__PATH__" --replace_string="$path_url" --target_file="$config_file"
|
||||
ynh_replace_string --match_string="__PORT__" --replace_string="$port" --target_file="$config_file"
|
||||
ynh_replace_string --match_string="__ENCRYPT__" --replace_string="$always_encrypt" --target_file="$config_file"
|
||||
ynh_replace_string --match_string="__SECRET__" --replace_string="$secret" --target_file="$config_file"
|
||||
# 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"
|
||||
fi
|
||||
|
||||
# Calculate and store the config file checksum into the app settings
|
||||
ynh_store_file_checksum --file="$config_file"
|
||||
|
||||
ynh_script_progression --message="Restarting Lutim..." --weight=5
|
||||
|
||||
# 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"
|
||||
|
||||
#=================================================
|
||||
# END OF SCRIPT
|
||||
#=================================================
|
||||
|
||||
ynh_script_progression --message="Execution completed" --last
|
||||
|
|
@ -1,67 +0,0 @@
|
|||
#!/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
|
Loading…
Reference in a new issue