Fix shell expansion and file permission issues install.sh

Signed-off-by: Brad Davidson <brad.davidson@rancher.com>
pull/3357/head
Brad Davidson 2021-05-19 15:50:34 -07:00 committed by Brad Davidson
parent f11cbc5a8e
commit 25c2888d28
1 changed files with 7 additions and 5 deletions

View File

@ -1,5 +1,6 @@
#!/bin/sh #!/bin/sh
set -e set -e
set -o noglob
# Usage: # Usage:
# curl ... | ENV_VAR=... sh - # curl ... | ENV_VAR=... sh -
@ -489,6 +490,9 @@ install_selinux_rpm() {
if [ -r /etc/redhat-release ] || [ -r /etc/centos-release ] || [ -r /etc/oracle-release ]; then if [ -r /etc/redhat-release ] || [ -r /etc/centos-release ] || [ -r /etc/oracle-release ]; then
dist_version="$(. /etc/os-release && echo "$VERSION_ID")" dist_version="$(. /etc/os-release && echo "$VERSION_ID")"
maj_ver=$(echo "$dist_version" | sed -E -e "s/^([0-9]+)\.?[0-9]*$/\1/") maj_ver=$(echo "$dist_version" | sed -E -e "s/^([0-9]+)\.?[0-9]*$/\1/")
set +o noglob
$SUDO rm -f /etc/yum.repos.d/rancher-k3s-common*.repo
set -o noglob
if [ -r /etc/redhat-release ]; then if [ -r /etc/redhat-release ]; then
case ${maj_ver} in case ${maj_ver} in
7) 7)
@ -503,7 +507,6 @@ install_selinux_rpm() {
;; ;;
esac esac
fi fi
$SUDO rm -f /etc/yum.repos.d/rancher-k3s-common*.repo
$SUDO tee /etc/yum.repos.d/rancher-k3s-common.repo >/dev/null << EOF $SUDO tee /etc/yum.repos.d/rancher-k3s-common.repo >/dev/null << EOF
[rancher-k3s-common-${2}] [rancher-k3s-common-${2}]
name=Rancher K3s Common (${2}) name=Rancher K3s Common (${2})
@ -706,11 +709,10 @@ systemd_disable() {
# --- capture current env and create file containing k3s_ variables --- # --- capture current env and create file containing k3s_ variables ---
create_env_file() { create_env_file() {
info "env: Creating environment file ${FILE_K3S_ENV}" info "env: Creating environment file ${FILE_K3S_ENV}"
UMASK=$(umask) $SUDO touch ${FILE_K3S_ENV}
umask 0377 $SUDO chmod 0600 ${FILE_K3S_ENV}
env | grep '^K3S_' | $SUDO tee ${FILE_K3S_ENV} >/dev/null env | grep '^K3S_' | $SUDO tee ${FILE_K3S_ENV} >/dev/null
env | egrep -i '^(NO|HTTP|HTTPS)_PROXY' | $SUDO tee -a ${FILE_K3S_ENV} >/dev/null env | grep -Ei '^(NO|HTTP|HTTPS)_PROXY' | $SUDO tee -a ${FILE_K3S_ENV} >/dev/null
umask $UMASK
} }
# --- write systemd service file --- # --- write systemd service file ---