mirror of
https://github.com/k3s-io/k3s.git
synced 2024-06-07 19:41:36 +00:00
install.sh: Use contemporary command substitution syntax
The install.sh script currently uses a mix of the legacy backquote syntax and the recommended contemporary $() syntax. This patch brings consistency by replacing the occurrences of the legacy backquote ones with the $() syntax. Change-Id: I018f3250175064dcb22ef86a0240b2c804153641 Signed-off-by: Joakim Roubert <joakimr@axis.com>
This commit is contained in:
parent
ffe0288b68
commit
9982da1953
30
install.sh
30
install.sh
@ -167,7 +167,7 @@ setup_env() {
|
||||
|
||||
# --- use sudo if we are not already root ---
|
||||
SUDO=sudo
|
||||
if [ `id -u` = 0 ]; then
|
||||
if [ $(id -u) = 0 ]; then
|
||||
SUDO=
|
||||
fi
|
||||
|
||||
@ -207,7 +207,7 @@ setup_env() {
|
||||
fi
|
||||
|
||||
# --- get hash of config & exec for currently installed k3s ---
|
||||
PRE_INSTALL_HASHES=`get_installed_hashes`
|
||||
PRE_INSTALL_HASHES=$(get_installed_hashes)
|
||||
|
||||
# --- if bin directory is read only skip download ---
|
||||
if [ "${INSTALL_K3S_BIN_DIR_READ_ONLY}" = "true" ]; then
|
||||
@ -232,7 +232,7 @@ verify_k3s_is_executable() {
|
||||
# --- set arch and suffix, fatal if architecture not supported ---
|
||||
setup_verify_arch() {
|
||||
if [ -z "$ARCH" ]; then
|
||||
ARCH=`uname -m`
|
||||
ARCH=$(uname -m)
|
||||
fi
|
||||
case $ARCH in
|
||||
amd64)
|
||||
@ -262,14 +262,14 @@ setup_verify_arch() {
|
||||
|
||||
# --- fatal if no curl ---
|
||||
verify_curl() {
|
||||
if [ -z `which curl || true` ]; then
|
||||
if [ -z $(which curl || true) ]; then
|
||||
fatal "Can not find curl for downloading files"
|
||||
fi
|
||||
}
|
||||
|
||||
# --- create tempory directory and cleanup when done ---
|
||||
setup_tmp() {
|
||||
TMP_DIR=`mktemp -d -t k3s-install.XXXXXXXXXX`
|
||||
TMP_DIR=$(mktemp -d -t k3s-install.XXXXXXXXXX)
|
||||
TMP_HASH=${TMP_DIR}/k3s.hash
|
||||
TMP_BIN=${TMP_DIR}/k3s.bin
|
||||
cleanup() {
|
||||
@ -288,7 +288,7 @@ get_release_version() {
|
||||
VERSION_K3S="${INSTALL_K3S_VERSION}"
|
||||
else
|
||||
info "Finding latest release"
|
||||
VERSION_K3S=`curl -w "%{url_effective}" -I -L -s -S ${GITHUB_URL}/latest -o /dev/null | sed -e 's|.*/||'`
|
||||
VERSION_K3S=$(curl -w "%{url_effective}" -I -L -s -S ${GITHUB_URL}/latest -o /dev/null | sed -e 's|.*/||')
|
||||
fi
|
||||
info "Using ${VERSION_K3S} as release"
|
||||
}
|
||||
@ -298,13 +298,13 @@ download_hash() {
|
||||
HASH_URL=${GITHUB_URL}/download/${VERSION_K3S}/sha256sum-${ARCH}.txt
|
||||
info "Downloading hash ${HASH_URL}"
|
||||
curl -o ${TMP_HASH} -sfL ${HASH_URL} || fatal "Hash download failed"
|
||||
HASH_EXPECTED=`grep " k3s${SUFFIX}$" ${TMP_HASH} | awk '{print $1}'`
|
||||
HASH_EXPECTED=$(grep " k3s${SUFFIX}$" ${TMP_HASH} | awk '{print $1}')
|
||||
}
|
||||
|
||||
# --- check hash against installed version ---
|
||||
installed_hash_matches() {
|
||||
if [ -x ${BIN_DIR}/k3s ]; then
|
||||
HASH_INSTALLED=`sha256sum ${BIN_DIR}/k3s | awk '{print $1}'`
|
||||
HASH_INSTALLED=$(sha256sum ${BIN_DIR}/k3s | awk '{print $1}')
|
||||
if [ "${HASH_EXPECTED}" = "${HASH_INSTALLED}" ]; then
|
||||
return
|
||||
fi
|
||||
@ -322,7 +322,7 @@ download_binary() {
|
||||
# --- verify downloaded binary hash ---
|
||||
verify_binary() {
|
||||
info "Verifying binary download"
|
||||
HASH_BIN=`sha256sum ${TMP_BIN} | awk '{print $1}'`
|
||||
HASH_BIN=$(sha256sum ${TMP_BIN} | awk '{print $1}')
|
||||
if [ "${HASH_EXPECTED}" != "${HASH_BIN}" ]; then
|
||||
fatal "Download sha256 does not match ${HASH_EXPECTED}, got ${HASH_BIN}"
|
||||
fi
|
||||
@ -336,7 +336,7 @@ setup_binary() {
|
||||
$SUDO mv -f ${TMP_BIN} ${BIN_DIR}/k3s
|
||||
|
||||
if command -v getenforce > /dev/null 2>&1; then
|
||||
if [ "Disabled" != `getenforce` ]; then
|
||||
if [ "Disabled" != $(getenforce) ]; then
|
||||
info "SeLinux is enabled, setting permissions"
|
||||
if ! $SUDO semanage fcontext -l | grep "${BIN_DIR}/k3s" > /dev/null 2>&1; then
|
||||
$SUDO semanage fcontext -a -t bin_t "${BIN_DIR}/k3s"
|
||||
@ -397,7 +397,7 @@ create_killall() {
|
||||
$SUDO tee ${BIN_DIR}/${KILLALL_K3S_SH} >/dev/null << \EOF
|
||||
#!/bin/sh
|
||||
set -x
|
||||
[ `id -u` = 0 ] || exec sudo $0 $@
|
||||
[ $(id -u) = 0 ] || exec sudo $0 $@
|
||||
|
||||
for bin in /var/lib/rancher/k3s/data/**/bin/; do
|
||||
[ -d $bin ] && export PATH=$bin:$PATH
|
||||
@ -425,7 +425,7 @@ killtree() {
|
||||
killtree $(lsof | sed -e 's/^[^0-9]*//g; s/ */\t/g' | grep -w 'k3s/data/[^/]*/bin/containerd-shim' | cut -f1 | sort -n -u)
|
||||
|
||||
do_unmount() {
|
||||
MOUNTS=`cat /proc/self/mounts | awk '{print $2}' | grep "^$1" | sort -r`
|
||||
MOUNTS=$(cat /proc/self/mounts | awk '{print $2}' | grep "^$1" | sort -r)
|
||||
if [ -n "${MOUNTS}" ]; then
|
||||
umount ${MOUNTS}
|
||||
fi
|
||||
@ -453,7 +453,7 @@ create_uninstall() {
|
||||
$SUDO tee ${BIN_DIR}/${UNINSTALL_K3S_SH} >/dev/null << EOF
|
||||
#!/bin/sh
|
||||
set -x
|
||||
[ \`id -u\` = 0 ] || exec sudo \$0 \$@
|
||||
[ \$(id -u) = 0 ] || exec sudo \$0 \$@
|
||||
|
||||
${BIN_DIR}/${KILLALL_K3S_SH}
|
||||
|
||||
@ -504,7 +504,7 @@ systemd_disable() {
|
||||
# --- capture current env and create file containing k3s_ variables ---
|
||||
create_env_file() {
|
||||
info "env: Creating environment file ${FILE_K3S_ENV}"
|
||||
UMASK=`umask`
|
||||
UMASK=$(umask)
|
||||
umask 0377
|
||||
env | grep '^K3S_' | $SUDO tee ${FILE_K3S_ENV} >/dev/null
|
||||
umask $UMASK
|
||||
@ -629,7 +629,7 @@ service_enable_and_start() {
|
||||
|
||||
[ "${INSTALL_K3S_SKIP_START}" = "true" ] && return
|
||||
|
||||
POST_INSTALL_HASHES=`get_installed_hashes`
|
||||
POST_INSTALL_HASHES=$(get_installed_hashes)
|
||||
if [ "${PRE_INSTALL_HASHES}" = "${POST_INSTALL_HASHES}" ]; then
|
||||
info "No change detected so skipping service start"
|
||||
return
|
||||
|
Loading…
Reference in New Issue
Block a user