3
3
# Reset SECONDS
4
4
SECONDS=0
5
5
6
- # Cloud User: cloud-user (CentOS) or ubuntu?
7
- CLOUD_USER=ubuntu
8
-
9
6
ENABLE_OVN=true
10
7
11
8
# Registry IP
@@ -14,8 +11,7 @@ registry_ip=$1
14
11
echo " [INFO] Given docker registry IP: $registry_ip "
15
12
16
13
# Disable the firewall.
17
- if [[ " ${CLOUD_USER} " = " ubuntu" ]]
18
- then
14
+ if type apt; then
19
15
grep -q $HOSTNAME /etc/hosts || (echo " $( ip r | grep -o ' ^default via.*src [0-9.]*' | awk ' {print $NF}' ) $HOSTNAME " | sudo tee -a /etc/hosts)
20
16
dpkg -l ufw && sudo systemctl is-enabled ufw && sudo systemctl stop ufw && sudo systemctl disable ufw
21
17
else
26
22
fi
27
23
28
24
# Useful packages
29
- if [[ " ${CLOUD_USER} " = " ubuntu" ]]
30
- then
25
+ if type apt; then
31
26
# Avoid the interactive dialog prompting for service restart: set policy to leave services unchanged
32
27
echo " \$ nrconf{restart} = 'l';" | sudo tee /etc/needrestart/conf.d/90-aufn.conf
33
28
sudo apt update
45
40
sudo sysctl --load /etc/sysctl.d/70-ipv6.conf
46
41
47
42
# 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
50
44
case $( grep -o " [89]\.[0-9]" /etc/redhat-release) in
51
45
" 8.*" )
52
46
sudo dnf install -y network-scripts
63
57
exit -1
64
58
;;
65
59
esac
66
- elif [[ " ${CLOUD_USER} " = " ubuntu" ]]
67
- then
60
+ elif type apt; then
68
61
# Prepare for disabling of Netplan and enabling of systemd-networkd.
69
62
# Netplan has an interaction with systemd and cloud-init to populate
70
63
# systemd-networkd files, but ephemerally. If /etc/systemd/network is
84
77
set -e
85
78
86
79
# Ensure an ssh key is generated
80
+ CLOUD_USER=$( ls /home | grep -v lab | grep -v stack | head -1)
87
81
# NOTE: you might think ~${CLOUD_USER} would work but apparently not
88
82
CLOUD_USER_DIR=/home/${CLOUD_USER}
89
83
keyfile=" $HOME /.ssh/id_rsa"
0 commit comments