Skip to content

Commit dc89b5e

Browse files
committed
Export and unset SNAPSHOTS_ENABLED and USE_ALL_DISK_SPACE variables
- Export variables when set to make them available to child processes - Unset them after use to clean up the environment - Fixes shellcheck SC2034 warning
1 parent be11318 commit dc89b5e

File tree

1 file changed

+8
-4
lines changed

1 file changed

+8
-4
lines changed

nextcloud_install_production.sh

Lines changed: 8 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -101,7 +101,7 @@ fi
101101

102102
# Create a placeholder volume before modifying anything
103103
# Ask about snapshots first
104-
SNAPSHOTS_ENABLED=""
104+
export SNAPSHOTS_ENABLED=""
105105
if [ -z "$PROVISIONING" ]
106106
then
107107
if ! does_snapshot_exist "NcVM-installation" && yesno_box_no "Do you want to use LVM snapshots to be able to restore your root partition during upgrades and such?
@@ -117,7 +117,7 @@ Enabling this will also force an automatic reboot after running the update scrip
117117
sleep 1
118118
# Create a placeholder snapshot
119119
check_command lvcreate --size 10G --name "NcVM-installation" ubuntu-vg
120-
SNAPSHOTS_ENABLED="yes"
120+
export SNAPSHOTS_ENABLED="yes"
121121
else
122122
print_text_in_color "$IRed" "Could not create volume because of insufficient space..."
123123
sleep 2
@@ -127,14 +127,14 @@ fi
127127

128128
# Fix LVM on BASE image
129129
# Ask about disk space - now snapshots have been reserved, we can use remaining space
130-
USE_ALL_DISK_SPACE=""
130+
export USE_ALL_DISK_SPACE=""
131131
if grep -q "LVM" /etc/fstab
132132
then
133133
# In provisioning mode, always extend
134134
# In normal mode, ask the user
135135
if [ -n "$PROVISIONING" ] || yesno_box_yes "Do you want to make all free space available to your root partition?"
136136
then
137-
USE_ALL_DISK_SPACE="yes"
137+
export USE_ALL_DISK_SPACE="yes"
138138
fi
139139
fi
140140

@@ -167,6 +167,10 @@ then
167167
done
168168
fi
169169

170+
# Cleanup environment variables
171+
unset SNAPSHOTS_ENABLED
172+
unset USE_ALL_DISK_SPACE
173+
170174
# Install needed dependencies
171175
install_if_not lshw
172176
install_if_not net-tools

0 commit comments

Comments
 (0)