Merge pull request #657 from erikwilson/install-symlink-update

Install script symlink update
This commit is contained in:
Erik Wilson 2019-07-23 10:54:46 -07:00 committed by GitHub
commit dd4f343118
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23

View File

@ -22,6 +22,10 @@ set -e
# - INSTALL_K3S_SKIP_DOWNLOAD # - INSTALL_K3S_SKIP_DOWNLOAD
# If set to true will not download k3s hash or binary. # If set to true will not download k3s hash or binary.
# #
# - INSTALL_K3S_SYMLINK
# If set to 'skip' will not create symlinks, 'force' will overwrite,
# default will symlink if command does not exist in path.
#
# - INSTALL_K3S_SKIP_START # - INSTALL_K3S_SKIP_START
# If set to true will not start k3s service. # If set to true will not start k3s service.
# #
@ -369,18 +373,23 @@ download_and_verify() {
# --- add additional utility links --- # --- add additional utility links ---
create_symlinks() { create_symlinks() {
[ "${INSTALL_K3S_BIN_DIR_READ_ONLY}" = "true" ] && return [ "${INSTALL_K3S_BIN_DIR_READ_ONLY}" = "true" ] && return
if [ ! -e ${BIN_DIR}/kubectl ]; then [ "${INSTALL_K3S_SYMLINK}" = "skip" ] && return
info "Creating ${BIN_DIR}/kubectl symlink to k3s"
$SUDO ln -s k3s ${BIN_DIR}/kubectl
fi
if [ ! -e ${BIN_DIR}/crictl ]; then for cmd in kubectl crictl ctr; do
info "Creating ${BIN_DIR}/crictl symlink to k3s" if [ ! -e ${BIN_DIR}/${cmd} ] || [ "${INSTALL_K3S_SYMLINK}" = "force" ]; then
$SUDO ln -s k3s ${BIN_DIR}/crictl which_cmd=$(which ${cmd} || true)
fi if [ -z "${which_cmd}" ] || [ "${INSTALL_K3S_SYMLINK}" = "force" ]; then
info "Creating ${BIN_DIR}/${cmd} symlink to k3s"
$SUDO ln -sf k3s ${BIN_DIR}/${cmd}
else
info "Skipping ${BIN_DIR}/${cmd} symlink to k3s, command exists in PATH at ${which_cmd}"
fi
else
info "Skipping ${BIN_DIR}/${cmd} symlink to k3s, already exists"
fi
done
} }
# --- create killall script --- # --- create killall script ---
create_killall() { create_killall() {
[ "${INSTALL_K3S_BIN_DIR_READ_ONLY}" = "true" ] && return [ "${INSTALL_K3S_BIN_DIR_READ_ONLY}" = "true" ] && return
@ -470,12 +479,11 @@ if (ls ${SYSTEMD_DIR}/k3s*.service || ls /etc/init.d/k3s*) >/dev/null 2>&1; then
exit exit
fi fi
if [ -L ${BIN_DIR}/kubectl ]; then for cmd in kubectl crictl ctr; do
rm -f ${BIN_DIR}/kubectl if [ -L ${BIN_DIR}/\$cmd ]; then
fi rm -f ${BIN_DIR}/\$cmd
if [ -L ${BIN_DIR}/crictl ]; then fi
rm -f ${BIN_DIR}/crictl done
fi
rm -rf /etc/rancher/k3s rm -rf /etc/rancher/k3s
rm -rf /var/lib/rancher/k3s rm -rf /var/lib/rancher/k3s