Add alpine setup functions and sharable script
This commit is contained in:
parent
1a5f9dfc49
commit
ada0595f36
32
script/include/alpine_setup_functions.inc.sh
Executable file
32
script/include/alpine_setup_functions.inc.sh
Executable file
@ -0,0 +1,32 @@
|
||||
#!/bin/sh
|
||||
|
||||
# alpine_setup_functions: Functions used by the run_alpine_setup script
|
||||
|
||||
update_system_packages() {
|
||||
apk update
|
||||
apk upgrade
|
||||
}
|
||||
|
||||
install_package() {
|
||||
local package_name=${1}
|
||||
|
||||
apk add ${1}
|
||||
return $?
|
||||
}
|
||||
|
||||
add_group() {
|
||||
local group_name="${1}"
|
||||
local gid="${2}"
|
||||
|
||||
addgroup -g "${gid}" -S "${group_name}"
|
||||
return $?
|
||||
}
|
||||
|
||||
add_user() {
|
||||
local username="${1}"
|
||||
local primary_group="${2}"
|
||||
local uid="${3}"
|
||||
|
||||
adduser -u "${3}" -D -S -G "${primary_group}" "${username}"
|
||||
return $?
|
||||
}
|
25
script/include/run_alpine_setup
Executable file
25
script/include/run_alpine_setup
Executable file
@ -0,0 +1,25 @@
|
||||
# run_alpine_setup: Install basic system requirements for an app to run
|
||||
|
||||
# Load alpine setup functions
|
||||
source ./script/include/alpine_setup_functions.inc.sh
|
||||
|
||||
## Set option defaults
|
||||
# If GROUP information is incomplete, use the default one
|
||||
if [ -z "${APP_GROUP+is_set}" ] || \
|
||||
[ -z "${APP_GID+is_set}" ]; then
|
||||
APP_GROUP="atat"
|
||||
APP_GROUP_ID="8000"
|
||||
fi
|
||||
|
||||
# If USER information is incomplete, error out
|
||||
if [ -z "${APP_USER+is_set}" ] || \
|
||||
[ -z "${APP_UID+is_set}" ]; then
|
||||
exit 1
|
||||
fi
|
||||
|
||||
## Main
|
||||
update_system_packages
|
||||
install_package "bash"
|
||||
install_package "dumb-init"
|
||||
add_group "${APP_GROUP}" "${APP_GID}"
|
||||
add_user "${APP_USER}" "${APP_GROUP}" "${APP_UID}"
|
Loading…
x
Reference in New Issue
Block a user