]> 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 # #
4 # IPFire.org - A linux based firewall #
5 # Copyright (C) 2007-2022 IPFire Team <info@ipfire.org> #
6 # #
7 # This program is free software: you can redistribute it and/or modify #
8 # it under the terms of the GNU General Public License as published by #
9 # the Free Software Foundation, either version 3 of the License, or #
10 # (at your option) any later version. #
11 # #
12 # This program is distributed in the hope that it will be useful, #
13 # but WITHOUT ANY WARRANTY; without even the implied warranty of #
14 # MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the #
15 # GNU General Public License for more details. #
16 # #
17 # You should have received a copy of the GNU General Public License #
18 # along with this program. If not, see <http://www.gnu.org/licenses/>. #
19 # #
20 ###############################################################################
21
22 . /etc/sysconfig/rc
23 . ${rc_functions}
24
25 case "${1}" in
26 start)
27 # Check if we are running in the cloud
28 if running_on_ec2; then
29 scriptname="/etc/rc.d/helper/aws-setup"
30 elif running_on_exoscale; then
31 scriptname="/etc/rc.d/helper/exoscale-setup"
32 elif running_on_azure; then
33 scriptname="/etc/rc.d/helper/azure-setup"
34 elif running_on_gcp; then
35 scriptname="/etc/rc.d/helper/gcp-setup"
36 elif running_on_oci; then
37 scriptname="/etc/rc.d/helper/oci-setup"
38 else
39 # This system is not running in the cloud
40 exit 0
41 fi
42
43 # Find the first interface to use
44 for i in /sys/class/net/red* /sys/class/net/eth* \
45 /sys/class/net/*; do
46 [ -d "${i}" ] || continue
47 i=$(basename ${i})
48
49 # Skip loopback
50 [ "${i}" = "lo" ] && continue
51
52 # Use whatever we have found
53 intf="${i}"
54 break
55 done
56
57 # Check if we found a network interface
58 if [ ! -n "${intf}" ]; then
59 echo_failure
60
61 boot_mesg -n "Could not find a network interface" ${FAILURE}
62 boot_mesg "" ${NORMAL}
63 fi
64
65 # Run a DHCP client and set up the system accordingly
66 dhclient -sf "${scriptname}" "${intf}"
67
68 # End DHCP client immediately
69 dhclient -sf "${scriptname}" -r "${intf}" &>/dev/null
70
71 # Rename network devices
72 udevadm trigger --action="add" --subsystem-match="net"
73
74 exit 0
75 ;;
76
77 status)
78 # Check Amazon
79 if running_on_ec2; then
80 echo "This system is running on AWS EC2"
81 exit 0
82
83 # Check Exoscale
84 elif running_on_exoscale; then
85 echo "This system is running on Exoscale"
86 exit 0
87
88 # Check Microsoft
89 elif running_on_azure; then
90 echo "This system is running on Microsoft Azure"
91 exit 0
92
93 # Check Google
94 elif running_on_gcp; then
95 echo "This system is running on Google Cloud"
96 exit 0
97
98 # The rest
99 else
100 echo "This system is NOT running in the cloud"
101 exit 1
102 fi
103 ;;
104
105 *)
106 echo "Usage: ${0} {start|status}"
107 exit 1
108 ;;
109 esac