mirror of
https://github.com/YunoHost-Apps/homeassistant_ynh.git
synced 2024-09-03 19:26:16 +02:00
Fix
This commit is contained in:
parent
3f5c027d52
commit
4eaae0532f
6 changed files with 47 additions and 34 deletions
|
@ -1,5 +1,5 @@
|
||||||
# Grant sudo permissions to the user to manage his own systemd service
|
# Grant sudo permissions to the user to manage his own systemd service
|
||||||
__NAME__ ALL=(ALL) NOPASSWD: /bin/systemctl stop __NAME__@__NAME__.service
|
__APP__ ALL=(ALL) NOPASSWD: /bin/systemctl stop __APP__.service
|
||||||
__NAME__ ALL=(ALL) NOPASSWD: /bin/systemctl start __NAME__@__NAME__.service
|
__APP__ ALL=(ALL) NOPASSWD: /bin/systemctl start __APP__.service
|
||||||
__NAME__ ALL=(ALL) NOPASSWD: /bin/systemctl restart __NAME__@__NAME__.service
|
__APP__ ALL=(ALL) NOPASSWD: /bin/systemctl restart __APP__.service
|
||||||
__NAME__ ALL=(ALL) NOPASSWD: /bin/systemctl status __NAME__@__NAME__.service
|
__APP__ ALL=(ALL) NOPASSWD: /bin/systemctl status __APP__.service
|
||||||
|
|
|
@ -11,12 +11,12 @@ ynh_abort_if_errors
|
||||||
# retrieve arguments
|
# retrieve arguments
|
||||||
app=$YNH_APP_INSTANCE_NAME
|
app=$YNH_APP_INSTANCE_NAME
|
||||||
domain=$(ynh_app_setting_get --app="$app" --key=domain)
|
domain=$(ynh_app_setting_get --app="$app" --key=domain)
|
||||||
|
port=$(ynh_app_setting_get --app="$app" --key=port)
|
||||||
# definie useful vars
|
final_path=$(ynh_app_setting_get --app="$app" --key=final_path)
|
||||||
final_path="/opt/yunohost/$app"
|
data_path=$(ynh_app_setting_get --app="$app" --key=data_path)
|
||||||
data_path="/home/yunohost.app/$app"
|
log_file=$(ynh_app_setting_get --app="$app" --key=log_file)
|
||||||
log_file="/var/log/$app/$app.log"
|
path_url=$(ynh_app_setting_get --app="$app" --key=path_url)
|
||||||
path_url="/"
|
python=$(ynh_app_setting_get --app="$app" --key=python)
|
||||||
|
|
||||||
# backup source & conf files
|
# backup source & conf files
|
||||||
ynh_print_info --message="Declaring files to be backed up..."
|
ynh_print_info --message="Declaring files to be backed up..."
|
||||||
|
|
|
@ -25,24 +25,28 @@ ynh_script_progression --message="Validating installation parameters..."
|
||||||
[ ! -d "$final_path" ] || ynh_die --message="This path already contains a folder"
|
[ ! -d "$final_path" ] || ynh_die --message="This path already contains a folder"
|
||||||
ynh_webpath_register --app="$app" --domain="$domain" --path_url="$path_url"
|
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
|
# find a free port & open it
|
||||||
ynh_script_progression --message="Looking for a free port and opening it..."
|
ynh_script_progression --message="Looking for a free port and opening it..."
|
||||||
port=$(ynh_find_port 8123)
|
port=$(ynh_find_port 8123)
|
||||||
ynh_app_setting_set --app="$app" --key=port --value="$port"
|
|
||||||
ynh_exec_fully_quiet yunohost firewall allow TCP "$port"
|
ynh_exec_fully_quiet yunohost firewall allow TCP "$port"
|
||||||
|
|
||||||
# create a dedicated system user
|
# save app settings
|
||||||
ynh_script_progression --message="Creating dedicated user, rights and folders..."
|
ynh_script_progression --message="Storing installation settings..."
|
||||||
ynh_system_user_create --username="$app"
|
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
|
# grant sudo permissions to the user to manage his own systemd service
|
||||||
myynh_create_dir "/etc/sudoers.d"
|
myynh_create_dir "/etc/sudoers.d"
|
||||||
ynh_add_config --template="../conf/sudoers" --destination="/etc/sudoers.d/$app"
|
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
|
# create a directory for the installation of Home Assistant
|
||||||
myynh_create_dir "$final_path"
|
myynh_create_dir "$final_path"
|
||||||
chown $app: "$final_path"
|
chown $app: "$final_path"
|
||||||
|
|
|
@ -9,12 +9,11 @@ source /usr/share/yunohost/helpers
|
||||||
app=$YNH_APP_INSTANCE_NAME
|
app=$YNH_APP_INSTANCE_NAME
|
||||||
domain=$(ynh_app_setting_get --app=$app --key=domain)
|
domain=$(ynh_app_setting_get --app=$app --key=domain)
|
||||||
port=$(ynh_app_setting_get --app=$app --key=port)
|
port=$(ynh_app_setting_get --app=$app --key=port)
|
||||||
|
final_path=$(ynh_app_setting_get --app="$app" --key=final_path)
|
||||||
# definie useful vars
|
data_path=$(ynh_app_setting_get --app="$app" --key=data_path)
|
||||||
final_path="/opt/yunohost/$app"
|
log_file=$(ynh_app_setting_get --app="$app" --key=log_file)
|
||||||
data_path="/home/yunohost.app/$app"
|
path_url=$(ynh_app_setting_get --app="$app" --key=path_url)
|
||||||
log_file="/var/log/$app/$app.log"
|
python=$(ynh_app_setting_get --app="$app" --key=python)
|
||||||
path_url="/"
|
|
||||||
|
|
||||||
# Remove a service from the admin panel, added by `yunohost service add`
|
# Remove a service from the admin panel, added by `yunohost service add`
|
||||||
if ynh_exec_warn_less yunohost service status "$app" >/dev/null ; then
|
if ynh_exec_warn_less yunohost service status "$app" >/dev/null ; then
|
||||||
|
|
|
@ -18,14 +18,12 @@ ynh_abort_if_errors
|
||||||
app=$YNH_APP_INSTANCE_NAME
|
app=$YNH_APP_INSTANCE_NAME
|
||||||
domain=$(ynh_app_setting_get --app="$app" --key=domain)
|
domain=$(ynh_app_setting_get --app="$app" --key=domain)
|
||||||
port=$(ynh_app_setting_get --app="$app" --key=port)
|
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)
|
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
|
# check domain/path availability
|
||||||
ynh_script_progression --message="Validating recovery parameters..."
|
ynh_script_progression --message="Validating recovery parameters..."
|
||||||
[ ! -d "$final_path" ] || ynh_die --message="This path already contains a folder"
|
[ ! -d "$final_path" ] || ynh_die --message="This path already contains a folder"
|
||||||
|
|
|
@ -15,10 +15,22 @@ domain=$(ynh_app_setting_get --app="$app" --key=domain)
|
||||||
port=$(ynh_app_setting_get --app="$app" --key=port)
|
port=$(ynh_app_setting_get --app="$app" --key=port)
|
||||||
|
|
||||||
# definie useful vars
|
# definie useful vars
|
||||||
|
if [ -z $(ynh_app_setting_get --app="$app" --key=final_path) ]; then
|
||||||
final_path="/opt/yunohost/$app"
|
final_path="/opt/yunohost/$app"
|
||||||
data_path="/home/yunohost.app/$app"
|
data_path="/home/yunohost.app/$app"
|
||||||
log_file="/var/log/$app/$app.log"
|
log_file="/var/log/$app/$app.log"
|
||||||
path_url="/"
|
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
|
# 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..."
|
ynh_script_progression --message="Creating backup in case of failure..."
|
||||||
|
|
Loading…
Reference in a new issue