Skip to content

Commit a887aa7

Browse files
authored
refactor: env variables in uppercase (#35)
* chore: change env variables of network-config.sh * chore: change name of env config vars of app.yml * chore: change env variables of setfirewall.sh * chore: change env variables of encryptedDisk.sh * chore: rename env variables in readme.md * fix: correct malformed variables * fix: correct misspelled variable
1 parent 7dd10fe commit a887aa7

File tree

5 files changed

+31
-31
lines changed

5 files changed

+31
-31
lines changed

apploader/conf/app.yml

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -14,10 +14,10 @@ csvAssistants:
1414
type: job
1515
entrypoint: /bin/bash
1616
env:
17-
ifName: ens3
18-
ifIp: 10.10.11.237
19-
ifNetmask: 255.255.255.0
20-
ifGateway: 10.10.11.254
17+
IF_NAME: ens3
18+
IF_IP: 10.10.11.237
19+
IF_NETMASK: 255.255.255.0
20+
IF_GATEWAY: 10.10.11.254
2121
args: ["/workplace/csv-agent/csvassistants/network-tool/network-config.sh"]
2222
- name: keyProvider
2323
type: job

cvmassistants/disktool/encryptedDisk.sh

Lines changed: 10 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -5,7 +5,7 @@
55
#
66
# This script partitions, formats, and mounts disk devices. Supports both
77
# encrypted (LUKS) and unencrypted disks. Environment variables control behavior:
8-
# `mount_path` (mount point), `disk` (device name), `keyType` (only wrapkey supported),
8+
# `MOUNT_PATH` (mount point), `DISK` (device name), `KEY_TYPE` (only wrapkey supported),
99
# and `wrapkey` (encryption key).
1010
#
1111
# Requirements:
@@ -113,22 +113,22 @@ mount_device() {
113113
log_info "Starting encrypted disk configuration..."
114114

115115
# Check required environment variables
116-
[[ -z "$mount_path" ]] && log_fatal "Mount directory is null"
117-
[[ -z "$disk" ]] && log_fatal "Disk dev name is null"
116+
[[ -z "$MOUNT_PATH" ]] && log_fatal "Mount directory is null"
117+
[[ -z "$DISK" ]] && log_fatal "Disk dev name is null"
118118
# Handle only encrypted disk case
119-
[ "$keyType" != "wrapkey" ] && log_fatal "keyType $keyType is not supported"
119+
[ "$KEY_TYPE" != "wrapkey" ] && log_fatal "KEY_TYPE $KEY_TYPE is not supported"
120120

121121
log_info "Handling encrypted disk case"
122122
[[ -z "$wrapkey" ]] && log_fatal "wrapkey is null"
123123

124-
if [ ! -d "$mount_path" ]; then
125-
log_info "Mount directory $mount_path does not exist"
126-
mkdir -p "$mount_path" && log_info "Created mount directory $mount_path"
124+
if [ ! -d "$MOUNT_PATH" ]; then
125+
log_info "Mount directory $MOUNT_PATH does not exist"
126+
mkdir -p "$MOUNT_PATH" && log_info "Created mount directory $MOUNT_PATH"
127127
else
128-
umount "$mount_path" 2>/dev/null && log_info "Unmounted $mount_path"
128+
umount "$MOUNT_PATH" 2>/dev/null && log_info "Unmounted $MOUNT_PATH"
129129
fi
130130

131-
diskpath="/dev/$disk" # /dev/vda
131+
diskpath="/dev/$DISK" # /dev/vda
132132
part_disk=""
133133

134134
mappername="${disk}"
@@ -145,6 +145,6 @@ echo "$wrapkey" | cryptsetup open --key-file=- "$part_disk" "$mappername"
145145
log_info "cryptsetup open --key-file=- "$part_disk" "$mappername": success"
146146

147147
# Mount the device
148-
mount_device "$device_to_mount" "$mount_path" && log_info "Mounted $device_to_mount to $mount_path"
148+
mount_device "$device_to_mount" "$MOUNT_PATH" && log_info "Mounted $device_to_mount to $MOUNT_PATH"
149149

150150
log_info "Encrypted disk configuration completed."

cvmassistants/disktool/readme.md

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -4,5 +4,5 @@ All existing data on the partition will be **permanently lost**.
44

55
Specifically:
66

7-
- The disk is defined via the `disk` environment variable (e.g., `vda`).
7+
- The disk is defined via the `DISK` environment variable (e.g., `vda`).
88
- The partition affected is the **first partition** of that disk

cvmassistants/firewall/setfirewall.sh

Lines changed: 5 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -4,7 +4,7 @@
44
# Description: Configure UFW firewall rules on Ubuntu systems (e.g., TDX environment)
55
#
66
# This script enables UFW and allows ports defined in the environment variable
7-
# `allowPorts`. Supports single ports and port ranges (e.g., "22,80,3000:3010").
7+
# `ALLOW_PORTS`. Supports single ports and port ranges (e.g., "22,80,3000:3010").
88
#
99
# Requirements:
1010
# - Must be run as root
@@ -51,11 +51,11 @@ fi
5151
log_info "UFW enabled."
5252

5353
# Get ports from environment variable
54-
if [ -z "${allowPorts}" ]; then
55-
log_info "No ports specified (allowPorts is empty). Skipping rule creation."
54+
if [ -z "${ALLOW_PORTS}" ]; then
55+
log_info "No ports specified (ALLOW_PORTS is empty). Skipping rule creation."
5656
else
57-
log_info "Allowing ports: ${allowPorts}"
58-
IFS=',' read -ra PORT_ARRAY <<< "${allowPorts}"
57+
log_info "Allowing ports: ${ALLOW_PORTS}"
58+
IFS=',' read -ra PORT_ARRAY <<< "${ALLOW_PORTS}"
5959

6060
for port in "${PORT_ARRAY[@]}"; do
6161
port="$(echo "$port" | xargs)" # trim spaces

cvmassistants/network-tool/network-config.sh

Lines changed: 11 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -12,10 +12,10 @@
1212
# - Must run on Ubuntu OS (TDX Trusted Domain Environment)
1313
#
1414
# Environment Variables Required:
15-
# - ifName: Network interface name (e.g., eth0)
16-
# - ifIp: IP address to assign to the interface
17-
# - ifNetmask: Network subnet mask
18-
# - ifGateway: Gateway IP address
15+
# - IF_NAME: Network interface name (e.g., eth0)
16+
# - IF_IP: IP address to assign to the interface
17+
# - IF_NETMASK: Network subnet mask
18+
# - IF_GATEWAY: Gateway IP address
1919
#
2020
###############################################################################
2121

@@ -27,20 +27,20 @@ function configureNetwork() {
2727
fi
2828

2929
# Check if all required environment variables are set
30-
if [ -z "${ifName}" ] || [ -z "${ifIp}" ] || [ -z "${ifNetmask}" ] || [ -z "${ifGateway}" ]; then
30+
if [ -z "${IF_NAME}" ] || [ -z "${IF_IP}" ] || [ -z "${IF_NETMASK}" ] || [ -z "${IF_GATEWAY}" ]; then
3131
echo "Error: Missing required environment variables."
32-
echo "Required variables: ifName, ifIp, ifNetmask, ifGateway"
32+
echo "Required variables: IF_NAME, IF_IP, IF_NETMASK, IF_GATEWAY"
3333
exit 1
3434
fi
3535

3636
echo "nameserver 8.8.8.8" > /etc/resolv.conf
3737

3838
cat>/etc/network/interfaces<<EOF
39-
auto ${ifName}
40-
iface ${ifName} inet static
41-
address ${ifIp}
42-
netmask ${ifNetmask}
43-
gateway ${ifGateway}
39+
auto ${IF_NAME}
40+
iface ${IF_NAME} inet static
41+
address ${IF_IP}
42+
netmask ${IF_NETMASK}
43+
gateway ${IF_GATEWAY}
4444
EOF
4545

4646
/etc/init.d/networking restart

0 commit comments

Comments
 (0)