Skip to content

Commit

Permalink
Automate default user selection and OS evaluation
Browse files Browse the repository at this point in the history
  • Loading branch information
Alex-Welsh committed May 31, 2024
1 parent 2d1c11e commit c312b12
Show file tree
Hide file tree
Showing 2 changed files with 7 additions and 18 deletions.
16 changes: 5 additions & 11 deletions a-seed-from-nothing.sh
Original file line number Diff line number Diff line change
Expand Up @@ -3,9 +3,6 @@
# Reset SECONDS
SECONDS=0

# Cloud User: cloud-user (CentOS) or ubuntu?
CLOUD_USER=ubuntu

ENABLE_OVN=true

# Registry IP
Expand All @@ -14,8 +11,7 @@ registry_ip=$1
echo "[INFO] Given docker registry IP: $registry_ip"

# Disable the firewall.
if [[ "${CLOUD_USER}" = "ubuntu" ]]
then
if type apt; then
grep -q $HOSTNAME /etc/hosts || (echo "$(ip r | grep -o '^default via.*src [0-9.]*' | awk '{print $NF}') $HOSTNAME" | sudo tee -a /etc/hosts)
dpkg -l ufw && sudo systemctl is-enabled ufw && sudo systemctl stop ufw && sudo systemctl disable ufw
else
Expand All @@ -26,8 +22,7 @@ else
fi

# Useful packages
if [[ "${CLOUD_USER}" = "ubuntu" ]]
then
if type apt; then
# Avoid the interactive dialog prompting for service restart: set policy to leave services unchanged
echo "\$nrconf{restart} = 'l';" | sudo tee /etc/needrestart/conf.d/90-aufn.conf
sudo apt update
Expand All @@ -45,8 +40,7 @@ EOF
sudo sysctl --load /etc/sysctl.d/70-ipv6.conf

# CentOS Stream 8 requires network-scripts. Rocky Linux 9 and onwards use NetworkManager.
if [[ "${CLOUD_USER}" = "cloud-user" ]]
then
if type dnf; then
case $(grep -o "[89]\.[0-9]" /etc/redhat-release) in
"8.*")
sudo dnf install -y network-scripts
Expand All @@ -63,8 +57,7 @@ then
exit -1
;;
esac
elif [[ "${CLOUD_USER}" = "ubuntu" ]]
then
elif type apt; then
# Prepare for disabling of Netplan and enabling of systemd-networkd.
# Netplan has an interaction with systemd and cloud-init to populate
# systemd-networkd files, but ephemerally. If /etc/systemd/network is
Expand All @@ -84,6 +77,7 @@ fi
set -e

# Ensure an ssh key is generated
CLOUD_USER=$(ls /home | grep -v lab | grep -v stack | head -1)
# NOTE: you might think ~${CLOUD_USER} would work but apparently not
CLOUD_USER_DIR=/home/${CLOUD_USER}
keyfile="$HOME/.ssh/id_rsa"
Expand Down
9 changes: 2 additions & 7 deletions pull-retag-push-images.sh
Original file line number Diff line number Diff line change
Expand Up @@ -5,11 +5,7 @@ set -e
# Reset SECONDS
SECONDS=0

# DISTRO: CentOS or Ubuntu?
DISTRO=ubuntu

if [[ "${DISTRO}" = "ubuntu" ]]
then
if type apt; then
# Install and start docker
[[ -f /usr/share/keyrings/docker-archive-keyring.gpg ]] || (curl -fsSL https://download.docker.com/linux/ubuntu/gpg | sudo gpg --dearmor -o /usr/share/keyrings/docker-archive-keyring.gpg)
echo \
Expand Down Expand Up @@ -43,8 +39,7 @@ fi

registry=quay.io
acct=openstack.kolla
if [[ "${DISTRO}" = "ubuntu" ]]
then
if type apt; then
tag=${1:-2023.1-ubuntu-jammy}
else
tag=${1:-2023.1-rocky-9}
Expand Down

0 comments on commit c312b12

Please sign in to comment.