]>
Commit | Line | Data |
---|---|---|
1c21ebf8 | 1 | #!/bin/sh |
66c36198 PM |
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 | ############################################################################### | |
1c21ebf8 MT |
21 | |
22 | . /etc/sysconfig/rc | |
23 | . ${rc_functions} | |
24 | ||
1c21ebf8 MT |
25 | case "${1}" in |
26 | start) | |
b9021f92 MT |
27 | # Check if we are running in the cloud |
28 | if running_on_ec2; then | |
29 | scriptname="/etc/rc.d/helper/aws-setup" | |
5ae3706d MT |
30 | elif running_on_exoscale; then |
31 | scriptname="/etc/rc.d/helper/exoscale-setup" | |
b9021f92 MT |
32 | elif running_on_azure; then |
33 | scriptname="/etc/rc.d/helper/azure-setup" | |
86c64598 MT |
34 | elif running_on_gcp; then |
35 | scriptname="/etc/rc.d/helper/gcp-setup" | |
7c24a0d9 MT |
36 | elif running_on_oci; then |
37 | scriptname="/etc/rc.d/helper/oci-setup" | |
b9021f92 MT |
38 | else |
39 | # This system is not running in the cloud | |
40 | exit 0 | |
41 | fi | |
1c21ebf8 MT |
42 | |
43 | # Find the first interface to use | |
81e1e80e MT |
44 | for i in /sys/class/net/red* /sys/class/net/eth* \ |
45 | /sys/class/net/*; do | |
1c21ebf8 MT |
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 | ||
bd3bcb45 | 65 | # Run a DHCP client and set up the system accordingly |
b9021f92 | 66 | dhclient -sf "${scriptname}" "${intf}" |
1c21ebf8 | 67 | |
bd3bcb45 | 68 | # End DHCP client immediately |
b9021f92 | 69 | dhclient -sf "${scriptname}" -r "${intf}" &>/dev/null |
ba062943 | 70 | |
c5465a94 MT |
71 | # Rename network devices |
72 | udevadm trigger --action="add" --subsystem-match="net" | |
73 | ||
ba062943 | 74 | exit 0 |
1c21ebf8 MT |
75 | ;; |
76 | ||
77 | status) | |
d035f60c | 78 | # Check Amazon |
1c21ebf8 MT |
79 | if running_on_ec2; then |
80 | echo "This system is running on AWS EC2" | |
81 | exit 0 | |
d035f60c | 82 | |
5ae3706d MT |
83 | # Check Exoscale |
84 | elif running_on_exoscale; then | |
85 | echo "This system is running on Exoscale" | |
86 | exit 0 | |
87 | ||
d035f60c MT |
88 | # Check Microsoft |
89 | elif running_on_azure; then | |
90 | echo "This system is running on Microsoft Azure" | |
91 | exit 0 | |
92 | ||
86c64598 MT |
93 | # Check Google |
94 | elif running_on_gcp; then | |
95 | echo "This system is running on Google Cloud" | |
96 | exit 0 | |
97 | ||
d035f60c | 98 | # The rest |
1c21ebf8 | 99 | else |
d035f60c | 100 | echo "This system is NOT running in the cloud" |
1c21ebf8 MT |
101 | exit 1 |
102 | fi | |
103 | ;; | |
104 | ||
105 | *) | |
106 | echo "Usage: ${0} {start|status}" | |
107 | exit 1 | |
108 | ;; | |
109 | esac |