Skip to content

Commit 05f0e58

Browse files
authored
Merge pull request #16 from stackhpc/automate-os
Automate default user selection and OS evaluation
2 parents 67b7e5d + c312b12 commit 05f0e58

File tree

2 files changed

+7
-18
lines changed

2 files changed

+7
-18
lines changed

a-seed-from-nothing.sh

Lines changed: 5 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -3,9 +3,6 @@
33
# Reset SECONDS
44
SECONDS=0
55

6-
# Cloud User: cloud-user (CentOS) or ubuntu?
7-
CLOUD_USER=ubuntu
8-
96
ENABLE_OVN=true
107

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

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

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

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

8679
# Ensure an ssh key is generated
80+
CLOUD_USER=$(ls /home | grep -v lab | grep -v stack | head -1)
8781
# NOTE: you might think ~${CLOUD_USER} would work but apparently not
8882
CLOUD_USER_DIR=/home/${CLOUD_USER}
8983
keyfile="$HOME/.ssh/id_rsa"

pull-retag-push-images.sh

Lines changed: 2 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -5,11 +5,7 @@ set -e
55
# Reset SECONDS
66
SECONDS=0
77

8-
# DISTRO: CentOS or Ubuntu?
9-
DISTRO=ubuntu
10-
11-
if [[ "${DISTRO}" = "ubuntu" ]]
12-
then
8+
if type apt; then
139
# Install and start docker
1410
[[ -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)
1511
echo \
@@ -43,8 +39,7 @@ fi
4339

4440
registry=quay.io
4541
acct=openstack.kolla
46-
if [[ "${DISTRO}" = "ubuntu" ]]
47-
then
42+
if type apt; then
4843
tag=${1:-2023.1-ubuntu-jammy}
4944
else
5045
tag=${1:-2023.1-rocky-9}

0 commit comments

Comments
 (0)