Skip to content

Commit

Permalink
Merge pull request #130 from briandowns/reorder_install_script_setup
Browse files Browse the repository at this point in the history
reorder env setup, user create calls, add missing sudo
  • Loading branch information
briandowns authored Jul 27, 2020
2 parents 52ceb50 + 5314eda commit b71ab7e
Show file tree
Hide file tree
Showing 2 changed files with 11 additions and 9 deletions.
19 changes: 10 additions & 9 deletions install.sh
Original file line number Diff line number Diff line change
Expand Up @@ -846,13 +846,13 @@ create_user() {
exit 1
fi

if [ "$(id -u "$1" 2>/dev/null)" != 1 ]; then
if [ ! $(id -u $1 > /dev/null 2>&1; echo $?) ]; then
no_login=$(command -v nologin)

if [ ! -z "${no_login}" ]; then
useradd -r -d "${BASE_DIR}" -c "$2" -s "${no_login}" "$1"
${SUDO} useradd -r -d "${BASE_DIR}" -c "$2" -s "${no_login}" "$1"
else
useradd -r -d "${BASE_DIR}" -c "$2" -s /bin/false "$1"
${SUDO} useradd -r -d "${BASE_DIR}" -c "$2" -s /bin/false "$1"
fi
else
info "$1 exists. moving on..."
Expand All @@ -865,9 +865,9 @@ eval set -- $(escape "${INSTALL_RKE2_EXEC}") $(quote "$@")
# setup_rke2_user creates the rke2 user and group, home
# directory, and sets necessary ownership.
setup_rke2_user() {
mkdir -p "${BASE_DIR}"
${SUDO} mkdir -p "${BASE_DIR}"
create_user "$1" "RKE2 Service User"
chown -R "$1":"$1" "$(dirname ${BASE_DIR})"
${SUDO} chown -R "$1":"$1" "$(dirname ${BASE_DIR})"
USING_RKE2_USER=1
}

Expand All @@ -876,7 +876,7 @@ setup_rke2_user() {
setup_etcd_user() {
create_user "$1" "ETCD Service User"
if [ "$(id -u "rke2" 2>/dev/null)" = 1 ]; then
usermod -a -G "${INSTALL_RKE2_USER}" "${INSTALL_RKE2_ETCD_USER}"
${SUDO} usermod -a -G "${INSTALL_RKE2_USER}" "${INSTALL_RKE2_ETCD_USER}"
fi
USING_ETCD_USER=1
}
Expand All @@ -886,12 +886,15 @@ setup_etcd_user() {
update_kernel_params() {
for param in vm.panic_on_oom=0 kernel.panic=10 kernel.panic_on_oops=1 kernel.keys.root_maxbytes=25000000 vm.overcommit_memory=1; do
${SUDO} sysctl -w ${param}
echo ${param} | ${SUDO} tee -a /etc/sysctl.d/local.conf
echo ${param} | ${SUDO} tee -a /etc/sysctl.d/local.conf >/dev/null
done
}

# main
{
verify_system
setup_env "$@"

if [ "${INSTALL_RKE2_CIS_MODE}" = true ]; then
update_kernel_params
setup_etcd_user "etcd"
Expand All @@ -905,8 +908,6 @@ update_kernel_params() {
setup_etcd_user "etcd"
fi

verify_system
setup_env "$@"
download_and_verify
setup_selinux
create_killall
Expand Down
1 change: 1 addition & 0 deletions pkg/cli/cmds/root.go
Original file line number Diff line number Diff line change
Expand Up @@ -44,6 +44,7 @@ func init() {
// kernel.panic_on_oops=1
// kernel.keys.root_maxbytes=25000000
var kernelRuntimeParameters = map[string]int{
"vm.overcommit_memory": 1,
"vm.panic_on_oom": 0,
"kernel.panic": 10,
"kernel.panic_on_oops": 1,
Expand Down

0 comments on commit b71ab7e

Please sign in to comment.