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:
parent
2fecb768e0
commit
3ca92dc581
3 changed files with 4 additions and 18 deletions
|
@ -21,19 +21,6 @@ exec_login_as() {
|
||||||
exec_as $user --login "$@"
|
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
|
# Returns true if a swap partition is enabled, false otherwise
|
||||||
# usage: is_swap_present
|
# usage: is_swap_present
|
||||||
is_swap_present() {
|
is_swap_present() {
|
||||||
|
|
|
@ -72,11 +72,10 @@ ynh_script_progression --message="Creating a PostgreSQL database..."
|
||||||
|
|
||||||
db_name=$(ynh_sanitize_dbid --db_name=$app)
|
db_name=$(ynh_sanitize_dbid --db_name=$app)
|
||||||
db_user=$db_name
|
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_name --value=$db_name
|
||||||
ynh_app_setting_set --app=$app --key=db_pwd --value=$db_pwd
|
|
||||||
ynh_psql_test_if_first_run
|
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
|
# 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 hstore;" --database=$db_name
|
||||||
ynh_psql_execute_as_root --sql="CREATE EXTENSION IF NOT EXISTS pg_trgm;" --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
|
# Install bundler, a gems installer
|
||||||
gem install bundler
|
gem install bundler
|
||||||
# Install without documentation
|
# 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
|
popd
|
||||||
|
|
||||||
# Specific actions on ARM architecture
|
# Specific actions on ARM architecture
|
||||||
|
|
|
@ -247,7 +247,7 @@ then
|
||||||
# Install bundler, a gems installer
|
# Install bundler, a gems installer
|
||||||
gem install bundler
|
gem install bundler
|
||||||
# Install without documentation
|
# 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
|
# Specific actions on ARM architecture
|
||||||
if [ -n "$(uname -m | grep arm)" ] ; then
|
if [ -n "$(uname -m | grep arm)" ] ; then
|
||||||
|
|
Loading…
Add table
Reference in a new issue