]> git.ipfire.org Git - ipfire-2.x.git/blob - src/initscripts/system/cloud-init
suricata: Change midstream policy to "pass-flow"
[ipfire-2.x.git] / src / initscripts / system / cloud-init
1 #!/bin/sh
2 ########################################################################
3 # Begin $rc_base/init.d/cloud-init
4 ########################################################################
5
6 . /etc/sysconfig/rc
7 . ${rc_functions}
8
9 case "${1}" in
10 start)
11 # Check if we are running in the cloud
12 if running_on_ec2; then
13 scriptname="/etc/rc.d/helper/aws-setup"
14 elif running_on_exoscale; then
15 scriptname="/etc/rc.d/helper/exoscale-setup"
16 elif running_on_azure; then
17 scriptname="/etc/rc.d/helper/azure-setup"
18 elif running_on_gcp; then
19 scriptname="/etc/rc.d/helper/gcp-setup"
20 elif running_on_oci; then
21 scriptname="/etc/rc.d/helper/oci-setup"
22 else
23 # This system is not running in the cloud
24 exit 0
25 fi
26
27 # Find the first interface to use
28 for i in /sys/class/net/red* /sys/class/net/eth* \
29 /sys/class/net/*; do
30 [ -d "${i}" ] || continue
31 i=$(basename ${i})
32
33 # Skip loopback
34 [ "${i}" = "lo" ] && continue
35
36 # Use whatever we have found
37 intf="${i}"
38 break
39 done
40
41 # Check if we found a network interface
42 if [ ! -n "${intf}" ]; then
43 echo_failure
44
45 boot_mesg -n "Could not find a network interface" ${FAILURE}
46 boot_mesg "" ${NORMAL}
47 fi
48
49 # Run a DHCP client and set up the system accordingly
50 dhclient -sf "${scriptname}" "${intf}"
51
52 # End DHCP client immediately
53 dhclient -sf "${scriptname}" -r "${intf}" &>/dev/null
54
55 # Rename network devices
56 udevadm trigger --action="add" --subsystem-match="net"
57
58 exit 0
59 ;;
60
61 status)
62 # Check Amazon
63 if running_on_ec2; then
64 echo "This system is running on AWS EC2"
65 exit 0
66
67 # Check Exoscale
68 elif running_on_exoscale; then
69 echo "This system is running on Exoscale"
70 exit 0
71
72 # Check Microsoft
73 elif running_on_azure; then
74 echo "This system is running on Microsoft Azure"
75 exit 0
76
77 # Check Google
78 elif running_on_gcp; then
79 echo "This system is running on Google Cloud"
80 exit 0
81
82 # The rest
83 else
84 echo "This system is NOT running in the cloud"
85 exit 1
86 fi
87 ;;
88
89 *)
90 echo "Usage: ${0} {start|status}"
91 exit 1
92 ;;
93 esac
94
95 # End $rc_base/init.d/cloud-init