Fix password generation and OS case problems in install scripts (#4184)

* Fix password generation in k8s install script

* OS should always be lower case
This commit is contained in:
Shrikant Sharat Kandula 2021-04-27 20:43:22 +05:30 committed by GitHub
parent c8bce7344b
commit 379ea708fa
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
4 changed files with 56 additions and 40 deletions

View File

@ -10,7 +10,8 @@
- name: Deploy appsmith on host
block:
- name: Get OS
shell: cat /etc/*-release | awk -F= '$1 == "NAME" { gsub(/"/, ""); print $2; exit }'
shell: |
cat /etc/*-release | awk -F= '$1 == "NAME" { gsub(/"/, ""); print $2; exit }' | tr '[:upper:]' '[:lower:]'
register: os
- name: Get app installation id

View File

@ -36,7 +36,7 @@ bye() { # Prints a friendly good bye message and exits the script.
"userId": "'"$APPSMITH_INSTALLATION_ID"'",
"event": "Installation Support",
"data": {
"os": "Ubuntu",
"os": "ubuntu",
"platform" : "aws_ami"
}
}' > /dev/null
@ -88,7 +88,7 @@ curl -s --location --request POST 'https://hook.integromat.com/dkwb6i52am93pi30o
"userId": "'"$APPSMITH_INSTALLATION_ID"'",
"event": "Installation Started",
"data": {
"os": "Ubuntu",
"os": "ubuntu",
"platform": "aws_ami"
}
}' > /dev/null
@ -163,7 +163,7 @@ if [[ $status_code -eq 401 ]]; then
"userId": "'"$APPSMITH_INSTALLATION_ID"'",
"event": "Installation Success",
"data": {
"os": "Ubuntu",
"os": "ubuntu",
"platform": "aws_ami"
}
}' > /dev/null

View File

@ -60,20 +60,22 @@ install_docker() {
$apt_cmd update
echo "Installing docker"
$apt_cmd install docker-ce docker-ce-cli containerd.io
elif [[ $package_manager == zypper ]]; then
zypper_cmd="sudo zypper --quiet --no-gpg-checks --non-interactive"
echo "Installing docker"
if [[ $os == sles ]]; then
os_sp="$(cat /etc/*-release | awk -F= '$1 == "VERSION_ID" { gsub(/"/, ""); print $2; exit }')"
os_arch="$(uname -i)"
sudo SUSEConnect -p sle-module-containers/$os_sp/$os_arch -r ''
sudo SUSEConnect -p "sle-module-containers/$os_sp/$os_arch" -r ''
fi
$zypper_cmd install docker docker-runc containerd
sudo systemctl enable docker.service
else
yum_cmd="sudo yum --assumeyes --quiet"
$yum_cmd install yum-utils
sudo yum-config-manager --add-repo https://download.docker.com/linux/$os/docker-ce.repo
sudo yum-config-manager --add-repo "https://download.docker.com/linux/$os/docker-ce.repo"
echo "Installing docker"
$yum_cmd install docker-ce docker-ce-cli containerd.io
@ -122,51 +124,55 @@ check_os() {
if is_mac; then
package_manager="brew"
desired_os=1
os="Mac"
os="mac"
return
fi
os_name="$(cat /etc/*-release | awk -F= '$1 == "NAME" { gsub(/"/, ""); print $2; exit }')"
local os_name="$(
cat /etc/*-release \
| awk -F= '$1 == "NAME" { gsub(/"/, ""); print $2; exit }' \
| tr '[:upper:]' '[:lower:]'
)"
case "$os_name" in
Ubuntu*)
ubuntu*)
desired_os=1
os="ubuntu"
package_manager="apt-get"
;;
Debian*)
debian*)
desired_os=1
os="debian"
package_manager="apt-get"
;;
Linux\ Mint*)
linux\ mint*)
desired_os=1
os="linux mint"
package_manager="apt-get"
;;
Red\ Hat*)
red\ hat*)
desired_os=1
os="red hat"
package_manager="yum"
;;
CentOS*)
centos*)
desired_os=1
os="centos"
package_manager="yum"
;;
SLES*)
sles*)
desired_os=1
os="sles"
package_manager="zypper"
;;
openSUSE*)
opensuse*)
desired_os=1
os="opensuse"
package_manager="zypper"
;;
*)
desired_os=0
os="Not Found"
os="Not Found: $os_name"
esac
}

View File

@ -56,36 +56,40 @@ check_os() {
if is_mac; then
package_manager="brew"
desired_os=1
os="Mac"
os="mac"
return
fi
os_name="$(cat /etc/*-release | awk -F= '$1 == "NAME" { gsub(/"/, ""); print $2; exit }')"
local os_name="$(
cat /etc/*-release \
| awk -F= '$1 == "NAME" { gsub(/"/, ""); print $2; exit }' \
| tr '[:upper:]' '[:lower:]'
)"
case "$os_name" in
Ubuntu*)
ubuntu*)
desired_os=1
os="ubuntu"
package_manager="apt-get"
;;
Debian*)
debian*)
desired_os=1
os="debian"
package_manager="apt-get"
;;
Red\ Hat*)
red\ hat*)
desired_os=1
os="red hat"
package_manager="yum"
;;
CentOS*)
centos*)
desired_os=1
os="centos"
package_manager="yum"
;;
*)
desired_os=0
os="Not Found"
os="Not Found: $os_name"
esac
}
@ -147,8 +151,13 @@ urlencode() {
}
generate_password() {
local gen_string="$(/usr/bin/python -c 'import random, string; print("".join(random.choice(string.ascii_letters + string.digits) for _ in range(13)))' 2>/dev/null)"
if [[ -n $gen_string ]]; then
echo "$gen_string"
else
# Picked up the following method of generation from : https://gist.github.com/earthgecko/3089509
LC_CTYPE=C tr -dc 'a-zA-Z0-9' < /dev/urandom | fold -w 13 | head -n 1
LC_ALL=C tr -dc 'a-zA-Z0-9' < /dev/urandom | fold -w 13 | head -n 1
fi
}
confirm() {