From cffb4a63efb510226f6eede3faf17d3d54ec08a3 Mon Sep 17 00:00:00 2001 From: ewilly Date: Sun, 28 Nov 2021 14:12:43 +0100 Subject: [PATCH] Fix --- scripts/_common.sh | 15 +-------------- scripts/install | 4 ++++ 2 files changed, 5 insertions(+), 14 deletions(-) diff --git a/scripts/_common.sh b/scripts/_common.sh index 356e3cd..db4736f 100644 --- a/scripts/_common.sh +++ b/scripts/_common.sh @@ -13,19 +13,6 @@ PKG_DEPENDENCIES="python3 python3-dev python3-venv python3-pip libffi-dev libssl # Pyhton 3.9.2 will be shiped with bullseye PY_REQUIRED_VERSION=3.9.2 -# Execute a command as another user -# usage: exec_as USER COMMAND [ARG ...] -exec_as() { - local USER=$1 - shift 1 - - if [[ $USER = $(whoami) ]]; then - eval "$@" - else - sudo -u "$USER" "$@" - fi -} - # Check if directory/file already exists (path in argument) myynh_check_path () { [ -z "$1" ] && ynh_die "No argument supplied" @@ -146,7 +133,7 @@ myynh_install_homeassistant () { # Manage arguments with getopts ynh_handle_getopts_args "$@" - exec_as $app -H -s /bin/bash -c " \ + ynh_exec_as $app -H -s /bin/bash -c " \ echo 'create the virtual environment' \ && $MY_PYTHON -m venv "$final_path" \ && echo 'activate the virtual environment' \ diff --git a/scripts/install b/scripts/install index bba09ef..e5bbdd8 100644 --- a/scripts/install +++ b/scripts/install @@ -67,7 +67,9 @@ myynh_install_dependencies --python="$PY_REQUIRED_VERSION" # installation in a virtual environment ynh_script_progression --message="Installing Home Assistant in a virtual environment..." +ynh_print_info --message="$(whoami)" ynh_exec_fully_quiet myynh_install_homeassistant --path="$data_path" +ynh_print_info --message="$(whoami)" # set default configuration files and move all homeassistant_conf_files ynh_script_progression --message="Configuring the installation..." @@ -77,12 +79,14 @@ ynh_replace_string --match_string="__DATAPATH__" --replace_string="$data_path" - cp -r "../conf/homeassistant_conf_files/." "$data_path/.$app/" chown -R $app: "$data_path/.$app" chmod -R +x "$data_path/.$app/bin/" +ynh_print_info --message="$(whoami)" # setup up systemd service ynh_script_progression --message="Adding the dedicated service..." ynh_replace_string --match_string="__DATAPATH__" --replace_string="$data_path" --target_file="../conf/systemd.service" ynh_replace_string --match_string="__LOGFILE__" --replace_string="$log_file" --target_file="../conf/systemd.service" ynh_add_systemd_config --service="$app" +ynh_print_info --message="$(whoami)" ## add service in admin panel yunohost service add "$app" --log "$log_file" --description "Home Assistant server" --needs_exposed_ports $port