1
0
Fork 0
mirror of https://github.com/YunoHost-Apps/discourse_ynh.git synced 2024-09-03 18:26:18 +02:00

ynh_exec_as

This commit is contained in:
ericgaspar 2021-06-03 14:48:24 +02:00
parent 2fecb768e0
commit 3ca92dc581
No known key found for this signature in database
GPG key ID: 574F281483054D44
3 changed files with 4 additions and 18 deletions

View file

@ -21,19 +21,6 @@ exec_login_as() {
exec_as $user --login "$@"
}
# 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
}
# Returns true if a swap partition is enabled, false otherwise
# usage: is_swap_present
is_swap_present() {

View file

@ -72,11 +72,10 @@ ynh_script_progression --message="Creating a PostgreSQL database..."
db_name=$(ynh_sanitize_dbid --db_name=$app)
db_user=$db_name
db_pwd=$(ynh_app_setting_get --app=$app --key=psqlpwd)
#db_pwd=$(ynh_app_setting_get --app=$app --key=psqlpwd)
ynh_app_setting_set --app=$app --key=db_name --value=$db_name
ynh_app_setting_set --app=$app --key=db_pwd --value=$db_pwd
ynh_psql_test_if_first_run
ynh_psql_setup_db --db_user=$db_user --db_name=$db_name --db_pwd=$db_pwd
ynh_psql_setup_db --db_user=$db_user --db_name=$db_name
# Set extensions
ynh_psql_execute_as_root --sql="CREATE EXTENSION IF NOT EXISTS hstore;" --database=$db_name
ynh_psql_execute_as_root --sql="CREATE EXTENSION IF NOT EXISTS pg_trgm;" --database=$db_name
@ -169,7 +168,7 @@ pushd "$final_path"
# Install bundler, a gems installer
gem install bundler
# Install without documentation
exec_as $app echo "gem: --no-ri --no-rdoc" >> "$final_path/.gemrc"
ynh_exec_as $app echo "gem: --no-ri --no-rdoc" >> "$final_path/.gemrc"
popd
# Specific actions on ARM architecture

View file

@ -247,7 +247,7 @@ then
# Install bundler, a gems installer
gem install bundler
# Install without documentation
exec_as $app echo "gem: --no-ri --no-rdoc" >> "$final_path/.gemrc"
ynh_exec_as $app echo "gem: --no-ri --no-rdoc" >> "$final_path/.gemrc"
)
# Specific actions on ARM architecture
if [ -n "$(uname -m | grep arm)" ] ; then