Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

add back check to enforce root/sudo startup. #1031

Open
wants to merge 1 commit into
base: develop-3.0
Choose a base branch
from
Open
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
43 changes: 17 additions & 26 deletions rel/files/riak
Original file line number Diff line number Diff line change
Expand Up @@ -8,6 +8,10 @@ RUNNER_LOG_DIR={{platform_log_dir}}
RELX_CONFIG_PATH=${RUNNER_GEN_DIR}/sys.config
VMARGS_PATH=${RUNNER_GEN_DIR}/vm.args

if [[ $EUID -ne 0 ]]; then
echo "You need to be root or use sudo to run this command."
exit 1
fi

# On first running the sys.config and vm.args will not be a link
# as cfconfig has not yet been run as a pre_start hook. If there's no
Expand All @@ -19,31 +23,18 @@ if [ ! -L $VMARGS_PATH ]; then
cp $RELEASE_ROOT_DIR/releases/{{release_version}}/vm.args $VMARGS_PATH
fi

# When running as a service, running as riak not as root, and systemd has created PID folder
if [[ $EUID -ne 0 ]]; then
case "$1" in
start|console|foreground)
RELX_CONFIG_PATH=${RELX_CONFIG_PATH} VMARGS_PATH=${VMARGS_PATH} RUNNER_LOG_DIR=${RUNNER_LOG_DIR} PIPE_DIR=${PIPE_DIR} ${COMMAND} ${*} -pa {{platform_lib_dir}}/patches
;;
*)
RELX_CONFIG_PATH=${RELX_CONFIG_PATH} VMARGS_PATH=${VMARGS_PATH} RUNNER_LOG_DIR=${RUNNER_LOG_DIR} PIPE_DIR=${PIPE_DIR} ${COMMAND} ${*}
;;
esac
else
# In this case we're running sudo riak - so have root access, but cannot rely
# systemd having created the PID dir, and need to sudo to the riak user
if [ ! -d $PID_DIR ]; then
mkdir $PID_DIR
chown riak:riak $PID_DIR
fi
case "$1" in
start|console|foreground)
su - riak -c "RELX_CONFIG_PATH=${RELX_CONFIG_PATH} VMARGS_PATH=${VMARGS_PATH} RUNNER_LOG_DIR=${RUNNER_LOG_DIR} PIPE_DIR=${PIPE_DIR} ${COMMAND} ${*} -pa {{platform_lib_dir}}/patches"
;;
*)
su - riak -c "RELX_CONFIG_PATH=${RELX_CONFIG_PATH} VMARGS_PATH=${VMARGS_PATH} RUNNER_LOG_DIR=${RUNNER_LOG_DIR} PIPE_DIR=${PIPE_DIR} ${COMMAND} ${*}"
;;
esac
# In this case we're running sudo riak - so have root access, but cannot rely
# systemd having created the PID dir, and need to sudo to the riak user
if [ ! -d $PID_DIR ]; then
mkdir $PID_DIR
chown riak:riak $PID_DIR
fi

case "$1" in
start|console|foreground)
su - riak -c "RELX_CONFIG_PATH=${RELX_CONFIG_PATH} VMARGS_PATH=${VMARGS_PATH} RUNNER_LOG_DIR=${RUNNER_LOG_DIR} PIPE_DIR=${PIPE_DIR} ${COMMAND} ${*} -pa {{platform_lib_dir}}/patches"
;;
*)
su - riak -c "RELX_CONFIG_PATH=${RELX_CONFIG_PATH} VMARGS_PATH=${VMARGS_PATH} RUNNER_LOG_DIR=${RUNNER_LOG_DIR} PIPE_DIR=${PIPE_DIR} ${COMMAND} ${*}"
;;
esac