2020-01-18 10:28:47 +01:00
|
|
|
#!/bin/bash
|
|
|
|
|
|
|
|
#=================================================
|
|
|
|
# COMMON VARIABLES
|
|
|
|
#=================================================
|
2020-12-20 00:27:44 +01:00
|
|
|
RUBY_VERSION="2.7.2"
|
2020-01-18 10:28:47 +01:00
|
|
|
|
|
|
|
# dependencies used by the app
|
2020-12-20 00:27:44 +01:00
|
|
|
pkg_dependencies="\
|
2020-12-27 23:18:55 +01:00
|
|
|
zlib1g-dev \
|
|
|
|
libsqlite3-dev \
|
|
|
|
default-libmysqlclient-dev \
|
|
|
|
libssl-dev \
|
|
|
|
libreadline-dev \
|
|
|
|
libjemalloc-dev"
|
2020-01-18 10:28:47 +01:00
|
|
|
|
|
|
|
#=================================================
|
|
|
|
# PERSONAL HELPERS
|
|
|
|
#=================================================
|
|
|
|
|
|
|
|
# Execute a command as another user with login
|
|
|
|
# (hence in user home dir, with prior loading of .profile, etc.)
|
|
|
|
# usage: exec_login_as USER COMMAND [ARG ...]
|
|
|
|
exec_login_as() {
|
2020-12-27 23:18:55 +01:00
|
|
|
local user=$1
|
|
|
|
shift 1
|
|
|
|
exec_as $user --login "$@"
|
2020-01-18 10:28:47 +01:00
|
|
|
}
|
|
|
|
# Execute a command as another user
|
|
|
|
# usage: exec_as USER COMMAND [ARG ...]
|
|
|
|
exec_as() {
|
2020-12-27 23:18:55 +01:00
|
|
|
local user=$1
|
|
|
|
shift 1
|
|
|
|
|
|
|
|
if [[ $user = $(whoami) ]]; then
|
|
|
|
eval "$@"
|
|
|
|
else
|
|
|
|
sudo -u "$user" "$@"
|
|
|
|
fi
|
2020-01-18 10:28:47 +01:00
|
|
|
}
|
|
|
|
|
|
|
|
#================================================
|
|
|
|
# EXPERIMENTAL HELPERS
|
|
|
|
#=================================================
|
|
|
|
|
|
|
|
#=================================================
|
|
|
|
# FUTURE OFFICIAL HELPERS
|
|
|
|
#=================================================
|