1
0
Fork 0
mirror of https://github.com/YunoHost-Apps/homeassistant_ynh.git synced 2024-09-03 19:26:16 +02:00
This commit is contained in:
ewilly 2021-11-27 21:27:01 +01:00
parent 3f5c027d52
commit 4eaae0532f
6 changed files with 47 additions and 34 deletions

View file

@ -1,5 +1,5 @@
# Grant sudo permissions to the user to manage his own systemd service
__NAME__ ALL=(ALL) NOPASSWD: /bin/systemctl stop __NAME__@__NAME__.service
__NAME__ ALL=(ALL) NOPASSWD: /bin/systemctl start __NAME__@__NAME__.service
__NAME__ ALL=(ALL) NOPASSWD: /bin/systemctl restart __NAME__@__NAME__.service
__NAME__ ALL=(ALL) NOPASSWD: /bin/systemctl status __NAME__@__NAME__.service
__APP__ ALL=(ALL) NOPASSWD: /bin/systemctl stop __APP__.service
__APP__ ALL=(ALL) NOPASSWD: /bin/systemctl start __APP__.service
__APP__ ALL=(ALL) NOPASSWD: /bin/systemctl restart __APP__.service
__APP__ ALL=(ALL) NOPASSWD: /bin/systemctl status __APP__.service

View file

@ -11,12 +11,12 @@ ynh_abort_if_errors
# retrieve arguments
app=$YNH_APP_INSTANCE_NAME
domain=$(ynh_app_setting_get --app="$app" --key=domain)
# definie useful vars
final_path="/opt/yunohost/$app"
data_path="/home/yunohost.app/$app"
log_file="/var/log/$app/$app.log"
path_url="/"
port=$(ynh_app_setting_get --app="$app" --key=port)
final_path=$(ynh_app_setting_get --app="$app" --key=final_path)
data_path=$(ynh_app_setting_get --app="$app" --key=data_path)
log_file=$(ynh_app_setting_get --app="$app" --key=log_file)
path_url=$(ynh_app_setting_get --app="$app" --key=path_url)
python=$(ynh_app_setting_get --app="$app" --key=python)
# backup source & conf files
ynh_print_info --message="Declaring files to be backed up..."

View file

@ -25,24 +25,28 @@ ynh_script_progression --message="Validating installation parameters..."
[ ! -d "$final_path" ] || ynh_die --message="This path already contains a folder"
ynh_webpath_register --app="$app" --domain="$domain" --path_url="$path_url"
# save app settings
ynh_script_progression --message="Storing installation settings..."
ynh_app_setting_set --app="$app" --key=domain --value="$domain"
# find a free port & open it
ynh_script_progression --message="Looking for a free port and opening it..."
port=$(ynh_find_port 8123)
ynh_app_setting_set --app="$app" --key=port --value="$port"
ynh_exec_fully_quiet yunohost firewall allow TCP "$port"
# create a dedicated system user
ynh_script_progression --message="Creating dedicated user, rights and folders..."
ynh_system_user_create --username="$app"
# save app settings
ynh_script_progression --message="Storing installation settings..."
ynh_app_setting_set --app="$app" --key=domain --value="$domain"
ynh_app_setting_set --app="$app" --key=port --value="$port"
ynh_app_setting_set --app="$app" --key=final_path --value="$final_path"
ynh_app_setting_set --app="$app" --key=data_path --value="$data_path"
ynh_app_setting_set --app="$app" --key=log_file --value="$log_file"
ynh_app_setting_set --app="$app" --key=path_url --value="$path_url"
# grant sudo permissions to the user to manage his own systemd service
myynh_create_dir "/etc/sudoers.d"
ynh_add_config --template="../conf/sudoers" --destination="/etc/sudoers.d/$app"
# create a dedicated system user
ynh_script_progression --message="Creating dedicated user, rights and folders..."
ynh_system_user_create --username="$app"
# create a directory for the installation of Home Assistant
myynh_create_dir "$final_path"
chown $app: "$final_path"

View file

@ -9,12 +9,11 @@ source /usr/share/yunohost/helpers
app=$YNH_APP_INSTANCE_NAME
domain=$(ynh_app_setting_get --app=$app --key=domain)
port=$(ynh_app_setting_get --app=$app --key=port)
# definie useful vars
final_path="/opt/yunohost/$app"
data_path="/home/yunohost.app/$app"
log_file="/var/log/$app/$app.log"
path_url="/"
final_path=$(ynh_app_setting_get --app="$app" --key=final_path)
data_path=$(ynh_app_setting_get --app="$app" --key=data_path)
log_file=$(ynh_app_setting_get --app="$app" --key=log_file)
path_url=$(ynh_app_setting_get --app="$app" --key=path_url)
python=$(ynh_app_setting_get --app="$app" --key=python)
# Remove a service from the admin panel, added by `yunohost service add`
if ynh_exec_warn_less yunohost service status "$app" >/dev/null ; then

View file

@ -18,14 +18,12 @@ ynh_abort_if_errors
app=$YNH_APP_INSTANCE_NAME
domain=$(ynh_app_setting_get --app="$app" --key=domain)
port=$(ynh_app_setting_get --app="$app" --key=port)
final_path=$(ynh_app_setting_get --app="$app" --key=final_path)
data_path=$(ynh_app_setting_get --app="$app" --key=data_path)
log_file=$(ynh_app_setting_get --app="$app" --key=log_file)
path_url=$(ynh_app_setting_get --app="$app" --key=path_url)
python=$(ynh_app_setting_get --app="$app" --key=python)
# definie useful vars
final_path="/opt/yunohost/$app"
data_path="/home/yunohost.app/$app"
log_file="/var/log/$app/$app.log"
path_url="/"
# check domain/path availability
ynh_script_progression --message="Validating recovery parameters..."
[ ! -d "$final_path" ] || ynh_die --message="This path already contains a folder"

View file

@ -15,10 +15,22 @@ domain=$(ynh_app_setting_get --app="$app" --key=domain)
port=$(ynh_app_setting_get --app="$app" --key=port)
# definie useful vars
if [ -z $(ynh_app_setting_get --app="$app" --key=final_path) ]; then
final_path="/opt/yunohost/$app"
data_path="/home/yunohost.app/$app"
log_file="/var/log/$app/$app.log"
path_url="/"
ynh_app_setting_set --app="$app" --key=final_path --value="$final_path"
ynh_app_setting_set --app="$app" --key=data_path --value="$data_path"
ynh_app_setting_set --app="$app" --key=log_file --value="$log_file"
ynh_app_setting_set --app="$app" --key=path_url --value="$path_url"
else
final_path=$(ynh_app_setting_get --app="$app" --key=final_path)
data_path=$(ynh_app_setting_get --app="$app" --key=data_path)
log_file=$(ynh_app_setting_get --app="$app" --key=log_file)
path_url=$(ynh_app_setting_get --app="$app" --key=path_url)
python=$(ynh_app_setting_get --app="$app" --key=python)
fi
# use prior backup and restore on error only if backup feature exists on installed instance
ynh_script_progression --message="Creating backup in case of failure..."