Skip to content

Commit 3c2e81d

Browse files
committed
optimize finding type of the systemvm, minor optimizations
Signed-off-by: Rohit Yadav <rohit.yadav@shapeblue.com>
1 parent 5000a2c commit 3c2e81d

4 files changed

Lines changed: 14 additions & 61 deletions

File tree

systemvm/debian/opt/cloud/bin/setup/cloud-early-config

Lines changed: 1 addition & 16 deletions
Original file line numberDiff line numberDiff line change
@@ -143,21 +143,6 @@ get_boot_params() {
143143
esac
144144
}
145145

146-
get_systemvm_type() {
147-
for str in $(cat $CMDLINE)
148-
do
149-
KEY=$(echo $str | cut -d= -f1)
150-
VALUE=$(echo $str | cut -d= -f2)
151-
case $KEY in
152-
type)
153-
export TYPE=$VALUE
154-
;;
155-
*)
156-
;;
157-
esac
158-
done
159-
}
160-
161146
patch() {
162147
local PATCH_MOUNT=/media/cdrom
163148
local patchfile=$PATCH_MOUNT/cloud-scripts.tgz
@@ -224,11 +209,11 @@ start() {
224209

225210
config_guest
226211
get_boot_params
227-
get_systemvm_type
228212
patch
229213
sync
230214
sysctl -p
231215

216+
export TYPE=$(grep -Po 'type=\K[a-zA-Z]*' $CMDLINE)
232217
log_it "Configuring systemvm type=$TYPE"
233218

234219
if [ -f "/opt/cloud/bin/setup/$TYPE.sh" ]; then

systemvm/debian/opt/cloud/bin/setup/common.sh

Lines changed: 0 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -578,24 +578,13 @@ setup_ntp() {
578578
}
579579

580580
routing_svcs() {
581-
systemctl disable --now cloud
582-
systemctl disable --now nfs-common
583-
systemctl disable --now portmap
584-
systemctl enable apache2
585-
systemctl enable haproxy
586581
echo "haproxy apache2" > /var/cache/cloud/enabled_svcs
587582
echo "cloud nfs-common portmap" > /var/cache/cloud/disabled_svcs
588583
if [ "$RROUTER" -eq "1" ]
589584
then
590-
systemctl disable --now dnsmasq
591-
systemctl enable conntrackd
592-
systemctl enable keepalived
593585
echo "keepalived conntrackd" >> /var/cache/cloud/enabled_svcs
594586
echo "dnsmasq" >> /var/cache/cloud/disabled_svcs
595587
else
596-
systemctl disable --now conntrackd
597-
systemctl disable --now keepalived
598-
systemctl enable dnsmasq
599588
echo "dnsmasq" >> /var/cache/cloud/enabled_svcs
600589
echo "keepalived conntrackd " >> /var/cache/cloud/disabled_svcs
601590
fi

systemvm/debian/opt/cloud/bin/setup/postinit.sh

Lines changed: 10 additions & 29 deletions
Original file line numberDiff line numberDiff line change
@@ -21,48 +21,25 @@
2121
# Eject cdrom if any
2222
eject || true
2323

24-
# Setup router
25-
CMDLINE=/var/cache/cloud/cmdline
26-
for str in $(cat $CMDLINE)
27-
do
28-
KEY=$(echo $str | cut -d= -f1)
29-
VALUE=$(echo $str | cut -d= -f2)
30-
case $KEY in
31-
type)
32-
export TYPE=$VALUE
33-
;;
34-
*)
35-
;;
36-
esac
37-
done
38-
24+
TYPE=$(grep -Po 'type=\K[a-zA-Z]*' $CMDLINE)
3925
if [ "$TYPE" == "router" ] || [ "$TYPE" == "vpcrouter" ] || [ "$TYPE" == "dhcpsrvr" ]
4026
then
4127
if [ -x /opt/cloud/bin/update_config.py ]
4228
then
4329
/opt/cloud/bin/update_config.py cmd_line.json || true
44-
logger -t cloud "postinit: Updated config cmd_line.json"
4530
fi
4631
fi
4732

48-
if [ "$TYPE" == "router" ]
49-
then
50-
python /opt/cloud/bin/baremetal-vr.py &
51-
logger -t cloud "Started baremetal-vr service"
52-
fi
53-
5433
[ ! -f /var/cache/cloud/enabled_svcs ] && touch /var/cache/cloud/enabled_svcs
5534
for svc in $(cat /var/cache/cloud/enabled_svcs)
5635
do
57-
logger -t cloud "Starting $svc"
58-
systemctl enable --no-block --now $svc
36+
systemctl enable --now --no-block $svc
5937
done
6038

6139
[ ! -f /var/cache/cloud/disabled_svcs ] && touch /var/cache/cloud/disabled_svcs
6240
for svc in $(cat /var/cache/cloud/disabled_svcs)
6341
do
64-
logger -t cloud "Stopping $svc"
65-
systemctl disable --no-block --now $svc
42+
systemctl disable --now --no-block $svc
6643
done
6744

6845
# Restore the persistent iptables nat, rules and filters for IPv4 and IPv6 if they exist
@@ -78,8 +55,12 @@ then
7855
ip6tables-restore < $ipv6
7956
fi
8057

81-
# Enable SSH by default
82-
systemctl enable --no-block --now ssh
58+
# Enable SSH
59+
systemctl enable --now --no-block ssh
8360

8461
date > /var/cache/cloud/boot_up_done
85-
logger -t cloud "Boot up process done"
62+
63+
if [ "$TYPE" == "router" ]
64+
then
65+
python /opt/cloud/bin/baremetal-vr.py &
66+
fi

systemvm/debian/opt/cloud/bin/setup/router.sh

Lines changed: 3 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -19,9 +19,7 @@
1919
. /opt/cloud/bin/setup/common.sh
2020

2121
setup_router() {
22-
log_it "Setting up virtual router system vm"
23-
24-
#To save router public interface and gw ip information
22+
# To save router public interface and gw ip information
2523
touch /var/cache/cloud/ifaceGwIp
2624

2725
oldmd5=
@@ -82,11 +80,11 @@ setup_router() {
8280
cp /etc/iptables/iptables-router /etc/iptables/rules.v4
8381
setup_sshd $ETH1_IP "eth1"
8482

85-
#Only allow DNS service for current network
83+
# Only allow DNS service for current network
8684
sed -i "s/-A INPUT -i eth0 -p udp -m udp --dport 53 -j ACCEPT/-A INPUT -i eth0 -p udp -m udp --dport 53 -s $DHCP_RANGE\/$CIDR_SIZE -j ACCEPT/g" /etc/iptables/rules.v4
8785
sed -i "s/-A INPUT -i eth0 -p tcp -m tcp --dport 53 -j ACCEPT/-A INPUT -i eth0 -p tcp -m tcp --dport 53 -s $DHCP_RANGE\/$CIDR_SIZE -j ACCEPT/g" /etc/iptables/rules.v4
8886

89-
#setup hourly logrotate
87+
# Setup hourly logrotate
9088
mv -n /etc/cron.daily/logrotate /etc/cron.hourly 2>&1
9189
}
9290

0 commit comments

Comments
 (0)