Skip to content

Commit

Permalink
fix(autok3s): fix install script
Browse files Browse the repository at this point in the history
  • Loading branch information
JacieChao committed Jun 2, 2022
1 parent 5bb13b4 commit 05b4e8a
Show file tree
Hide file tree
Showing 2 changed files with 23 additions and 102 deletions.
2 changes: 1 addition & 1 deletion hack/make-rules/autok3s.sh
Original file line number Diff line number Diff line change
Expand Up @@ -9,7 +9,7 @@ CURR_DIR="$(cd "$(dirname "${BASH_SOURCE[0]}")/../.." && pwd -P)"
# The root of the autok3s directory
ROOT_DIR="${CURR_DIR}"
CROSS=${CROSS:-}
UI_VERSION="v0.5.0-rc2"
UI_VERSION="v0.5.0"

source "${ROOT_DIR}/hack/lib/init.sh"
source "${CURR_DIR}/hack/lib/constant.sh"
Expand Down
123 changes: 22 additions & 101 deletions scripts/install.sh
Original file line number Diff line number Diff line change
Expand Up @@ -14,6 +14,10 @@ BINLOCATION=${BINLOCATION:-'/usr/local/bin'}
KUBEEXPLORER_REPO=${KUBEEXPLORER_REPO:-'kube-explorer'}
KUBEEXPLORER_DOWNLOAD_URL=https://github.com/$OWNER/$KUBEEXPLORER_REPO/releases/download
KUBEEXPLORER_VERSION=v0.2.9
SUDO=sudo
if [ $(id -u) -eq 0 ]; then
SUDO=
fi

# - INSTALL_AUTOK3S_MIRROR
# For Chinese users, set INSTALL_AUTOK3S_MIRROR=cn to use the mirror address to accelerate
Expand Down Expand Up @@ -139,71 +143,27 @@ getPackage() {

curl -sSL $url --output "$targetFile"

if [ "$?" = "0" ]; then

if [ "$VERIFY_CHECKSUM" = "1" ]; then
checkHash
fi

chmod +x "$targetFile"
if [ "$VERIFY_CHECKSUM" = "1" ]; then
checkHash
fi

echo "Download complete."

if [ ! -w "$BINLOCATION" ]; then

echo
echo "============================================================"
echo " The script was run as a user who is unable to write"
echo " to $BINLOCATION. To complete the installation the"
echo " following commands may need to be run manually."
echo "============================================================"
echo
echo " sudo cp $REPO$suffix $BINLOCATION/$REPO"

if [ -n "$ALIAS_NAME" ]; then
echo " sudo ln -sf $BINLOCATION/$REPO $BINLOCATION/$ALIAS_NAME"
fi

echo

else

echo
echo "Running with sufficient permissions to attempt to move $REPO to $BINLOCATION"
$SUDO mv -f $targetFile $BINLOCATION/$REPO
$SUDO chmod +x $BINLOCATION/$REPO

if [ ! -w "$BINLOCATION/$REPO" ] && [ -f "$BINLOCATION/$REPO" ]; then

echo
echo "================================================================"
echo " $BINLOCATION/$REPO already exists and is not writeable"
echo " by the current user. Please adjust the binary ownership"
echo " or run sh/bash with sudo."
echo "================================================================"
echo
exit 1

fi

mv $targetFile $BINLOCATION/$REPO

if [ "$?" = "0" ]; then
echo "New version of $REPO installed to $BINLOCATION"
fi

if [ -e "$targetFile" ]; then
rm "$targetFile"
fi

if [ -n "$ALIAS_NAME" ]; then
if [ ! -L $BINLOCATION/$ALIAS_NAME ]; then
ln -s $BINLOCATION/$REPO $BINLOCATION/$ALIAS_NAME
echo "Creating alias '$ALIAS_NAME' for '$REPO'."
fi
fi
if [ -e "$targetFile" ]; then
rm "$targetFile"
fi

${SUCCESS_CMD}
if [ -n "$ALIAS_NAME" ]; then
if [ ! -L $BINLOCATION/$ALIAS_NAME ]; then
$SUDO ln -s $BINLOCATION/$REPO $BINLOCATION/$ALIAS_NAME
echo "Creating alias '$ALIAS_NAME' for '$REPO'."
fi
fi

${SUCCESS_CMD}
}

getKubeExplorer() {
Expand Down Expand Up @@ -240,51 +200,13 @@ getKubeExplorer() {
echo "Downloading package $url as $targetFile"

curl -sSL $url --output "$targetFile"

chmod +x "$targetFile"

echo "Download complete."

if [ ! -w "$BINLOCATION" ]; then

echo
echo "============================================================"
echo " The script was run as a user who is unable to write"
echo " to $BINLOCATION. To complete the installation the"
echo " following commands may need to be run manually."
echo "============================================================"
echo
echo " sudo cp $KUBEEXPLORER_REPO$suffix $BINLOCATION/$KUBEEXPLORER_REPO"
echo

else

echo
echo "Running with sufficient permissions to attempt to move $KUBEEXPLORER_REPO to $BINLOCATION"

if [ ! -w "$BINLOCATION/$KUBEEXPLORER_REPO" ] && [ -f "$BINLOCATION/$KUBEEXPLORER_REPO" ]; then

echo
echo "================================================================"
echo " $BINLOCATION/$KUBEEXPLORER_REPO already exists and is not writeable"
echo " by the current user. Please adjust the binary ownership"
echo " or run sh/bash with sudo."
echo "================================================================"
echo
exit 1

fi

mv $targetFile $BINLOCATION/$KUBEEXPLORER_REPO

if [ "$?" = "0" ]; then
echo "New version of $KUBEEXPLORER_REPO installed to $BINLOCATION"
fi

if [ -e "$targetFile" ]; then
rm "$targetFile"
fi
$SUDO mv $targetFile $BINLOCATION/$KUBEEXPLORER_REPO
$SUDO chmod +x $BINLOCATION/$KUBEEXPLORER_REPO

if [ -e "$targetFile" ]; then
rm "$targetFile"
fi
}

Expand Down Expand Up @@ -331,7 +253,6 @@ rm -f ${BINLOCATION}/kube-explorer
EOF
$SUDO chmod 755 ${BINLOCATION}/autok3s-uninstall.sh
$SUDO chown root:root ${BINLOCATION}/autok3s-uninstall.sh
}

hasCli
Expand Down

0 comments on commit 05b4e8a

Please sign in to comment.