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

shfmt and shellcheck compliance #368

Open
wants to merge 2 commits into
base: master
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
32 changes: 16 additions & 16 deletions hack/install.sh
Original file line number Diff line number Diff line change
Expand Up @@ -7,13 +7,13 @@ set -e -x -o pipefail
export OWNER="openfaas"
export REPO="faasd"

# On CentOS /usr/local/bin is not included in the PATH when using sudo.
# On CentOS /usr/local/bin is not included in the PATH when using sudo.
# Running arkade with sudo on CentOS requires the full path
# to the arkade binary.
# to the arkade binary.
export ARKADE=/usr/local/bin/arkade

# When running as a startup script (cloud-init), the HOME variable is not always set.
# As it is required for arkade to properly download tools,
# As it is required for arkade to properly download tools,
# set the variable to /usr/local so arkade will download binaries to /usr/local/.arkade
if [ -z "${HOME}" ]; then
export HOME=/usr/local
Expand All @@ -25,7 +25,7 @@ echo "Finding latest version from GitHub"
version=$(curl -sI https://github.com/$OWNER/$REPO/releases/latest | grep -i "location:" | awk -F"/" '{ printf "%s", $NF }' | tr -d '\r')
echo "$version"

if [ ! $version ]; then
if [ ! "$version" ]; then
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I'd be fine with this change being added.

echo "Failed while attempting to get latest version"
exit 1
fi
Expand Down Expand Up @@ -60,17 +60,17 @@ has_pacman() {
}

install_required_packages() {
if $(has_apt_get); then
if has_apt_get; then
# Debian bullseye is missing iptables. Added to required packages
# to get it working in raspberry pi. No such known issues in
# other distros. Hence, adding only to this block.
# reference: https://github.com/openfaas/faasd/pull/237
$SUDO apt-get update -y
$SUDO apt-get install -y curl runc bridge-utils iptables
elif $(has_yum); then
elif has_yum; then
$SUDO yum check-update -y
$SUDO yum install -y curl runc iptables-services
elif $(has_pacman); then
elif has_pacman; then
$SUDO pacman -Syy
$SUDO pacman -Sy curl runc bridge-utils
else
Expand All @@ -79,7 +79,7 @@ install_required_packages() {
fi
}

install_arkade(){
install_arkade() {
curl -sLS https://get.arkade.dev | $SUDO sh
arkade --help
}
Expand All @@ -95,8 +95,8 @@ install_containerd() {

arch=$(uname -m)

$SUDO $ARKADE system install containerd --systemd --version v${CONTAINERD_VER} --progress=false
$SUDO $ARKADE system install containerd --systemd --version v${CONTAINERD_VER} --progress=false

sleep 5
}

Expand All @@ -118,8 +118,8 @@ install_faasd() {
$SUDO curl -fSLs "https://github.com/openfaas/faasd/releases/download/${version}/faasd${suffix}" --output "/usr/local/bin/faasd"
$SUDO chmod a+x "/usr/local/bin/faasd"

mkdir -p /tmp/faasd-${version}-installation/hack
cd /tmp/faasd-${version}-installation
mkdir -p /tmp/faasd-"$version"-installation/hack
cd /tmp/faasd-"$version"-installation
$SUDO curl -fSLs "https://raw.githubusercontent.com/openfaas/faasd/${version}/docker-compose.yaml" --output "docker-compose.yaml"
$SUDO curl -fSLs "https://raw.githubusercontent.com/openfaas/faasd/${version}/prometheus.yml" --output "prometheus.yml"
$SUDO curl -fSLs "https://raw.githubusercontent.com/openfaas/faasd/${version}/resolv.conf" --output "resolv.conf"
Expand All @@ -129,19 +129,19 @@ install_faasd() {
}

install_caddy() {
if [ ! -z "${FAASD_DOMAIN}" ]; then
if [ -n "${FAASD_DOMAIN}" ]; then
CADDY_VER=v2.4.3
arkade get --progress=false caddy -v ${CADDY_VER}

# /usr/bin/caddy is specified in the upstream service file.
$SUDO install -m 755 $HOME/.arkade/bin/caddy /usr/bin/caddy

$SUDO curl -fSLs https://raw.githubusercontent.com/caddyserver/dist/master/init/caddy.service --output /etc/systemd/system/caddy.service

$SUDO mkdir -p /etc/caddy
$SUDO mkdir -p /var/lib/caddy
if $(id caddy >/dev/null 2>&1); then

if id caddy >/dev/null 2>&1; then
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This syntax does not look right?

Copy link
Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I agree is looks funky, but removing the parens fixes the SC2091 warning in shellcheck and it still evaluates the same.

Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I am not a shellcheck user so this doesn't bother me. I prefer the clarity we had originally.

echo "User caddy already exists."
else
$SUDO useradd --system --home /var/lib/caddy --shell /bin/false caddy
Expand Down