1
0
Fork 0
mirror of https://github.com/YunoHost-Apps/mattermost_ynh.git synced 2024-09-03 19:36:29 +02:00

scripts: use an absolute path when invoking mmctl

It seems on some distros (like Raspian), the current working directory
is not preserved accross sudo invocations, which causes an "bin/mmctl
not found" error.

Fix #304
This commit is contained in:
Pierre de La Morinerie 2021-11-05 10:03:13 +00:00
parent 4b3d8ae83f
commit 0aa89327da

View file

@ -185,15 +185,14 @@ ynh_systemd_action --service_name=$app --action=start --log_path=systemd --line_
ynh_script_progression --message="Create the first administrator and team..." --weight=1
team_name=$(echo "$team_display_name" | iconv -f utf8 -t ascii//TRANSLIT//IGNORE | sed -e 's/[^[:alnum:]]/-/g' | tr -s '-' | tr A-Z a-z)
bin_mmctl="$final_path/bin/mmctl"
pushd "$final_path"
export MMCTL_LOCAL=true
export MMCTL_LOCAL_SOCKET_PATH="$local_socket_path"
export MMCTL_LOCAL=true
export MMCTL_LOCAL_SOCKET_PATH="$local_socket_path"
ynh_exec_warn_less sudo --preserve-env -u $app bin/mmctl user create --username "$admin" --email "$email" --password "$password" --locale "$language" --email-verified --system-admin
ynh_exec_warn_less sudo --preserve-env -u $app bin/mmctl team create --name "$team_name" --display_name "$team_display_name" --email "$email"
ynh_exec_warn_less sudo --preserve-env -u $app bin/mmctl team users add "$team_name" "$admin"
popd
ynh_exec_warn_less sudo --preserve-env -u $app "$bin_mmctl" user create --username "$admin" --email "$email" --password "$password" --locale "$language" --email-verified --system-admin
ynh_exec_warn_less sudo --preserve-env -u $app "$bin_mmctl" team create --name "$team_name" --display_name "$team_display_name" --email "$email"
ynh_exec_warn_less sudo --preserve-env -u $app "$bin_mmctl" team users add "$team_name" "$admin"
# Now that the first user is created, disable mmctl passwordless access
ynh_replace_string '"EnableLocalMode": true' '"EnableLocalMode": false' "$final_path/config/config.json"