38 | 38 |
fi
|
39 | 39 |
}
|
40 | 40 |
|
|
41 |
set_env_header_if_unset() {
|
|
42 |
if grep -q '^# STOP KALI-DEFAULTS CONFIG' /etc/environment; then
|
|
43 |
return
|
|
44 |
fi
|
|
45 |
|
|
46 |
echo "Adding KALI-DEFAULTS header to /etc/environment"
|
|
47 |
{
|
|
48 |
echo "# START KALI-DEFAULTS CONFIG"
|
|
49 |
echo "# Everything from here and until STOP KALI-DEFAULTS CONFIG"
|
|
50 |
echo "# was installed by the kali-defaults package, and it will"
|
|
51 |
echo "# be removed if ever the kali-defaults package is removed."
|
|
52 |
echo "# If you want to disable a line, please do NOT remove it,"
|
|
53 |
echo "# as it would be added back when kali-defaults is upgraded."
|
|
54 |
echo "# Instead, comment the line out, and your change will be"
|
|
55 |
echo "# preserved across upgrades."
|
|
56 |
echo "# STOP KALI-DEFAULTS CONFIG"
|
|
57 |
} >> /etc/environment
|
|
58 |
}
|
|
59 |
|
|
60 |
set_env_var_if_unset() {
|
|
61 |
local setting=$1
|
|
62 |
local value=$2
|
|
63 |
|
|
64 |
# Bail out if the setting is set or is commented out
|
|
65 |
if grep -q "^#* *${setting}=" /etc/environment; then
|
|
66 |
return
|
|
67 |
fi
|
|
68 |
|
|
69 |
# Insert the setting just before the STOP marker
|
|
70 |
echo "Setting ${setting} in /etc/environment"
|
|
71 |
sed -i "/^# STOP KALI-DEFAULTS CONFIG/i ${setting}=${value}" \
|
|
72 |
/etc/environment
|
|
73 |
}
|
|
74 |
|
41 | 75 |
configure_environment() {
|
|
76 |
echo "Configuring /etc/environment"
|
|
77 |
|
|
78 |
# Hack for piuparts: break the hard link
|
|
79 |
if [ -n "$PIUPARTS_TEST" ]; then
|
|
80 |
cp /etc/environment /etc/environment.tmp
|
|
81 |
mv /etc/environment.tmp /etc/environment
|
|
82 |
fi
|
|
83 |
|
|
84 |
set_env_header_if_unset
|
|
85 |
|
42 | 86 |
# Force PATH via /etc/environment so that non-root users have system tools
|
43 | 87 |
# available too (those in */sbin/)
|
44 | |
if ! grep -q ^PATH= /etc/environment; then
|
45 | |
echo "Configuring PATH in /etc/environment"
|
46 | |
echo "PATH=/usr/local/sbin:/usr/local/bin:/usr/sbin:/usr/bin:/sbin:/bin:/usr/local/games:/usr/games" >> /etc/environment
|
47 | |
fi
|
|
88 |
set_env_var_if_unset 'PATH' \
|
|
89 |
'/usr/local/sbin:/usr/local/bin:/usr/sbin:/usr/bin:/sbin:/bin:/usr/local/games:/usr/games'
|
|
90 |
|
|
91 |
# Propose to install commands not found
|
|
92 |
set_env_var_if_unset COMMAND_NOT_FOUND_INSTALL_PROMPT 1
|
|
93 |
|
|
94 |
# Opt-out of powershell telemetry reporting
|
|
95 |
set_env_var_if_unset POWERSHELL_TELEMETRY_OPTOUT 1
|
48 | 96 |
}
|
49 | 97 |
|
50 | 98 |
if [ "$1" = "configure" ]; then
|
|
79 | 127 |
install_config_file /etc/skel/.bashrc force
|
80 | 128 |
fi
|
81 | 129 |
|
|
130 |
if dpkg --compare-versions "$2" lt-nl 2021.2.0; then
|
|
131 |
# Drop PATH= from /etc/environment. No worries, we add
|
|
132 |
# it again with configure_environment().
|
|
133 |
sed -i '\|^PATH=/usr/local/sbin:/usr/local/bin:/usr/sbin:/usr/bin:/sbin:/bin:/usr/local/games:/usr/games|d' /etc/environment
|
|
134 |
fi
|
|
135 |
|
82 | 136 |
for file in $FILES_TO_DIVERT; do
|
83 | 137 |
install_config_file $file
|
84 | 138 |
done
|