Skip to content

Commit 9016cce

Browse files
committed
build
1 parent 2e620e2 commit 9016cce

File tree

1 file changed

+79
-49
lines changed

1 file changed

+79
-49
lines changed

usr/share/usability-misc/dist-installer-cli-standalone

Lines changed: 79 additions & 49 deletions
Original file line numberDiff line numberDiff line change
@@ -8,7 +8,7 @@
88
## BEGIN DEFAULT VALUES ##
99
##########################
1010

11-
if [ "${BASH_SOURCE-}" != "${0}" ]; then
11+
if [[ -n "${BASH_SOURCE[0]-}" && "${BASH_SOURCE[0]}" != "${0}" ]]; then
1212
## Script was sourced.
1313
## This is useful for other programs / scripts to be able to `source` the
1414
## functions of this script for code re-use. dist-installer-gui will do this.
@@ -158,6 +158,9 @@ fi
158158
##### BEGIN pasted by build-dist-installer-cli from file /usr/libexec/helper-scripts/get_colors.sh
159159
#!/bin/bash
160160

161+
## Copyright (C) 2025 - 2025 ENCRYPTED SUPPORT LLC <[email protected]>
162+
## See the file COPYING for copying conditions.
163+
161164
## colors
162165
# shellcheck disable=SC2034
163166
get_colors(){
@@ -209,6 +212,9 @@ fi
209212
##### BEGIN pasted by build-dist-installer-cli from file /usr/libexec/helper-scripts/has.sh
210213
#!/bin/bash
211214

215+
## Copyright (C) 2025 - 2025 ENCRYPTED SUPPORT LLC <[email protected]>
216+
## See the file COPYING for copying conditions.
217+
212218
## This is just a simple wrapper around 'command -v' to avoid
213219
## spamming '>/dev/null' throughout this function. This also guards
214220
## against aliases and functions.
@@ -222,6 +228,9 @@ has(){
222228
##### BEGIN pasted by build-dist-installer-cli from file /usr/libexec/helper-scripts/capitalize_first_char.sh
223229
#!/bin/bash
224230

231+
## Copyright (C) 2025 - 2025 ENCRYPTED SUPPORT LLC <[email protected]>
232+
## See the file COPYING for copying conditions.
233+
225234
## Capitalize only the first char of a string.
226235
capitalize_first_char(){
227236
printf '%s' "${1:-}" | awk '{$1=toupper(substr($1,0,1))substr($1,2)}1'
@@ -231,6 +240,9 @@ capitalize_first_char(){
231240
##### BEGIN pasted by build-dist-installer-cli from file /usr/libexec/helper-scripts/not_as_root.sh
232241
#!/bin/bash
233242

243+
## Copyright (C) 2025 - 2025 ENCRYPTED SUPPORT LLC <[email protected]>
244+
## See the file COPYING for copying conditions.
245+
234246

235247
## Block running as root.
236248
not_as_root(){
@@ -246,12 +258,15 @@ ${underline}Non-Root Check:${nounderline} Running as root.
246258
##### BEGIN pasted by build-dist-installer-cli from file /usr/libexec/helper-scripts/root_cmd.sh
247259
#!/bin/bash
248260

261+
## Copyright (C) 2025 - 2025 ENCRYPTED SUPPORT LLC <[email protected]>
262+
## See the file COPYING for copying conditions.
263+
249264

250265
## Wrapper that supports su, sudo, doas
251266
root_cmd(){
252267
local cmdarr
253268

254-
test -z "${1:-}" && die 1 "${underline}root_cmd function:${nounderline} Failed to pass arguments to root_cmd."
269+
test -z "${1:-}" && die 1 "${underline}root_cmd function:${nounderline} Failed to pass arguments to function 'root_cmd'."
255270
if test -z "${sucmd:-}"; then
256271
get_su_cmd
257272
fi
@@ -279,7 +294,7 @@ root_cmd(){
279294
log_run "$root_cmd_loglevel" doas -u root -- "${@}"
280295
;;
281296
*)
282-
die 1 "${underline}root_cmd function:${nounderline} root_cmd does not support sucmd: '${sucmd}'"
297+
die 1 "${underline}root_cmd function:${nounderline} 'root_cmd' does not support sucmd: '${sucmd}'"
283298
;;
284299
esac
285300
}
@@ -292,35 +307,36 @@ get_su_cmd(){
292307
has sudo && sucmd=sudo && break
293308
has doas && sucmd=doas && break
294309
has su && sucmd=su && break
310+
[ -z "${sucmd:-}" ] && sucmd=''
295311
test -z "${sucmd}" && {
296-
die 1 "${underline}get_su_cmd:${nounderline} Failed to find program to run commands with administrative (\"root\") privileges. This installer requires either one of the following programs to be installed:
312+
die 1 "${underline}get_su_cmd:${nounderline} Failed to find program to run commands with administrative ('root') privileges. This program requires either one of the following programs to be installed:
297313
- sudo (recommended)
298314
- doas
299315
- su"
300316
}
301317
case "${sucmd}" in
302318
sudo) :;;
303-
*) log warn "Using sucmd '$sucmd'. Consider installation of sudo instead to cache your passwords instead of typing them every time.";;
319+
*) log warn "Using sucmd '$sucmd'. Consider installation of 'sudo' instead to cache your passwords instead of typing them every time.";;
304320
esac
305321
done
306322

307-
log info "Testing root_cmd function..."
323+
log info "Testing 'root_cmd' function..."
308324
root_cmd printf '%s\n' "test" >/dev/null ||
309-
die 1 "${underline}get_su_cmd:${nounderline} Failed to run test command as root."
325+
die 1 "${underline}get_su_cmd:${nounderline} Failed to run test command as 'root'."
310326

311327
if test "${ci:-}" = "1"; then
312328
root_output="$(timeout --kill-after 5 5 sudo --non-interactive -- test -d /usr 2>&1)"
313329
if test -n "${root_output}"; then
314-
log error "sudo output: '${root_output}'"
315-
die 1 "${underline}get_su_cmd:${nounderline} Unexpected non-empty output for sudo test in CI mode."
330+
log error "'sudo' output: '${root_output}'"
331+
die 1 "${underline}get_su_cmd:${nounderline} Unexpected non-empty output for 'sudo' test in CI mode."
316332
fi
317333
return 0
318334
fi
319335

320336
## Other su cmds do not have an option that does the same.
321337
if test "${sucmd}" = "sudo"; then
322338
if ! timeout --kill-after 5 5 sudo --non-interactive -- test -d /usr; then
323-
log warn "Credential Caching Status: 'No' - Without credential caching, this installer will prompt for sudo authorization multiple times. Consider configuring sudo credential caching to streamline the installation process."
339+
log warn "Credential Caching Status: 'No' - Without credential caching, this program will prompt for 'sudo' authorization multiple times. Consider configuring 'sudo' credential caching to streamline the installation process."
324340
return 0
325341
fi
326342
## Used by dist-installer-gui.
@@ -329,8 +345,8 @@ get_su_cmd(){
329345
log info "Credential Caching Status: 'Yes'"
330346
root_output="$(timeout --kill-after 5 5 sudo -- test -d /usr 2>&1)"
331347
if test -n "${root_output}"; then
332-
log error "sudo output: '${root_output}'"
333-
die 1 "${underline}get_su_cmd:${nounderline} Unexpected non-empty output for sudo test in normal mode."
348+
log error "'sudo' output: '${root_output}'"
349+
die 1 "${underline}get_su_cmd:${nounderline} Unexpected non-empty output for 'sudo' test in normal mode."
334350
fi
335351
fi
336352
}
@@ -339,6 +355,9 @@ get_su_cmd(){
339355
##### BEGIN pasted by build-dist-installer-cli from file /usr/libexec/helper-scripts/ip_syntax.sh
340356
#!/bin/bash
341357

358+
## Copyright (C) 2025 - 2025 ENCRYPTED SUPPORT LLC <[email protected]>
359+
## See the file COPYING for copying conditions.
360+
342361

343362
## Check if variable is integer
344363
is_integer(){
@@ -387,6 +406,9 @@ is_addr_port(){
387406
##### BEGIN pasted by build-dist-installer-cli from file /usr/libexec/helper-scripts/get_os.sh
388407
#!/bin/bash
389408

409+
## Copyright (C) 2025 - 2025 ENCRYPTED SUPPORT LLC <[email protected]>
410+
## See the file COPYING for copying conditions.
411+
390412
## TODO: how to handle installer specific code?
391413

392414

@@ -628,6 +650,9 @@ check_not_qubes_template() {
628650
##### BEGIN pasted by build-dist-installer-cli from file /usr/libexec/helper-scripts/parse_opt.sh
629651
#!/bin/bash
630652

653+
## Copyright (C) 2025 - 2025 ENCRYPTED SUPPORT LLC <[email protected]>
654+
## See the file COPYING for copying conditions.
655+
631656

632657
## ------------------- ##
633658
## Usage of parse_opt.sh
@@ -782,6 +807,9 @@ range_arg(){
782807
##### BEGIN pasted by build-dist-installer-cli from file /usr/libexec/helper-scripts/log_run_die.sh
783808
#!/bin/bash
784809

810+
## Copyright (C) 2025 - 2025 ENCRYPTED SUPPORT LLC <[email protected]>
811+
## See the file COPYING for copying conditions.
812+
785813

786814
if ! command -v stecho &>/dev/null ; then
787815
## Fallback to printf in case stecho is unavailable.
@@ -874,6 +902,8 @@ log(){
874902
esac
875903
fi
876904

905+
sleep 0.1
906+
877907
if test "${xtrace:-}" = "1"; then
878908
set -o xtrace
879909
fi
@@ -1033,15 +1063,15 @@ handle_exit() {
10331063
claim_unsupported_distro() {
10341064
status="${1}"
10351065
distro="${2}"
1036-
log error "At this time, your Operating System is unsupported by the ${guest_pretty} Installer."
1066+
log error "At this time, your Operating System is unsupported by the '${guest_pretty}' Installer."
10371067
log error "Visit the following URL to check support for manual installation:"
10381068
log error " ${url_version_domain}/wiki/Virtualbox"
1039-
die 101 "${underline}Distribution Check:${nounderline} Unsupported (${status} '${distro}') system."
1069+
die 101 "${underline}Distribution Check:${nounderline} Unsupported ('${status}' '${distro}') system."
10401070
}
10411071

10421072
## Get necessary packages for your host system to be able to set the guest.
10431073
get_host_pkgs() {
1044-
log notice "Package Installation: installation of hypervisor-required packages... Please wait, as this could take a while..."
1074+
log notice "$hypervisor_pretty Installation: Required system virtualization packages are being installed... Please wait, this process may take a few minutes..."
10451075
if [ "$ubuntu_derivative_detected" = "1" ]; then
10461076
install_package_debian_common
10471077
install_virtualbox_ubuntu
@@ -1052,7 +1082,7 @@ get_host_pkgs() {
10521082
install_package_fedora_common
10531083
install_virtualbox_fedora
10541084
else
1055-
die 1 "Operating system not found in get_host_pkgs. Please report this bug. Debug log required."
1085+
die 1 "Operating system not found in 'get_host_pkgs'. Please report this bug. The debug log is required."
10561086
fi
10571087
}
10581088

@@ -1761,7 +1791,7 @@ Kernel module has been load: '$kernel_module_has_been_load'
17611791
Kernel module can be load: '$kernel_modules_can_be_load' (modules can be load. (sysctl kernel.modules_disabled=0 is set.)
17621792
Only signed kernel modules can be load: '$modules_signed_only'
17631793
Kernel module vboxdrv signer: '$kernel_module_signer'
1764-
kernel_module_modprobe_output ($sucmd modprobe vboxdrv): '$kernel_module_modprobe_output'"
1794+
kernel_module_modprobe_output ('$sucmd modprobe vboxdrv'): '$kernel_module_modprobe_output'"
17651795

17661796
if [ "$kernel_modules_can_be_load" = "true" ]; then
17671797
log error "${underline}VirtualBox Installation Result:${nounderline} ${red}${bold}'FAIL'${nobold}${nocolor} - because kernel modules have not been load yet.
@@ -2086,7 +2116,7 @@ virtualbox_start_failed() {
20862116
- The root cause for this issue is likely not the installer.
20872117
- This issue would likely also happen if the user tried to manually start the VMs.
20882118
- Resolving these issues (as per documentation hyperlinks above) would likely resolve this issue.
2089-
${url_version_domain}/wiki/VirtualBox/Troubleshooting"
2119+
https://www.kicksecure.com/wiki/VirtualBox/Troubleshooting"
20902120
}
20912121

20922122

@@ -3399,13 +3429,13 @@ torify_conn_maybe() {
33993429
if [ ! "${onion}" = "1" ]; then
34003430
if [ -z "${socks_proxy:-}" ]; then
34013431
## TODO: lower log level
3402-
log notice "Not torifying connection, because socks_proxy envrionment variable is unset nor using '--onion'."
3432+
log notice "Not torifying connection, because the 'socks_proxy' environment variable is unset nor using '--onion'."
34033433
return 0
34043434
fi
34053435
fi
34063436

34073437
if ! has tor; then
3408-
log warn "System tor binary (little-t-tor) was not found on the system."
3438+
log warn "System 'tor' binary ('little-t-tor') was not found on the system."
34093439
log warn "Unless your SOCKS connection is made available by the Tor Browser"
34103440
log warn " or by your uplink network, the proxy check may fail."
34113441
log warn "The installer with torified connections depends on a working SOCKS proxy,"
@@ -3424,7 +3454,7 @@ torify_conn_maybe() {
34243454
else
34253455
## Stream Isolation will be enforced get_proxy_cred()
34263456
log warn "Missing SOCKS proxy for torified connections."
3427-
log warn "Trying Tor defaults: system Tor (little-t-tor) (port: 9050) and TBB (Tor Browser Bundle) (port: 9150)."
3457+
log warn "Trying Tor defaults: system Tor ('little-t-tor') (port: '9050') and TBB (Tor Browser Bundle) (port: '9150')."
34283458
proxy="127.0.0.1:9050"
34293459
set_transfer_proxy ${proxy}
34303460
if ! check_tor_proxy; then
@@ -3444,7 +3474,7 @@ Unable to connect to Tor SOCKS proxy.
34443474
34453475
Please note that in order to torify connections, an already functional Tor connection is needed:
34463476
3447-
- A) A pre-installed and running system Tor (little-t-tor), or,
3477+
- A) A pre-installed and running system Tor ('little-t-tor'), or,
34483478
- B) A pre-installed and running TBB (Tor Browser Bundle).
34493479
34503480
Additional details:
@@ -3672,7 +3702,7 @@ get_virtualization() {
36723702
log warn " - The virtualization detection feature of this installer may not be flawless and could potentially fail to detect virtualization support (this is known as a 'false negative')."
36733703
if [ "${hypervisor}" = "virtualbox" ]; then
36743704
log warn " - Refer to user documentation on how to enable virtualization:"
3675-
log warn " ${url_version_domain}/wiki/VirtualBox/Troubleshooting#Enable_VT-x_in_BIOS"
3705+
log warn " https://www.kicksecure.com/wiki/VirtualBox/Troubleshooting#Enable_VT-x_in_BIOS"
36763706
fi
36773707
return 0
36783708
## Let's not hard fail here, let the user do it later.
@@ -4073,7 +4103,7 @@ check_integrity() {
40734103

40744104
## Self explanatory name, make everything after option parsing.
40754105
main() {
4076-
local hypervisor_pretty item cmd_check_internet
4106+
local item cmd_check_internet
40774107

40784108
###############
40794109
## BEGIN PRE ##
@@ -4096,18 +4126,6 @@ main() {
40964126
;;
40974127
esac
40984128

4099-
case "${hypervisor}" in
4100-
virtualbox)
4101-
hypervisor_pretty="VirtualBox"
4102-
;;
4103-
kvm)
4104-
hypervisor_pretty="KVM"
4105-
;;
4106-
*)
4107-
hypervisor_pretty="${hypervisor}"
4108-
;;
4109-
esac
4110-
41114129
log info "Parsed options:"
41124130
for item in $(print_getopt); do
41134131
log info " ${item}"
@@ -4199,7 +4217,7 @@ main() {
41994217
## Print usage message and exit with set exit code, depending if usage was
42004218
## called by [-h|--help] or because user tried and invalid option.
42014219
usage() {
4202-
printf %s"Usage: ${me} [options...]
4220+
printf '%s' "Usage: ${me} [options...]
42034221
42044222
User Options:
42054223
-g, --guest=<guest> Specify the guest. Options: kicksecure, whonix (default)
@@ -4214,8 +4232,8 @@ User Options:
42144232
-s, --socks-proxy=<proxy>
42154233
Set TCP SOCKS proxy for onion client connections.
42164234
(Defaults to TOR_SOCKS_HOST:TOR_SOCKS_PORT; if unset,
4217-
attempts to use TBB (Tor Browser Bundle) proxy at port 9150,
4218-
or system Tor (little-t-tor) proxy at port 9050.)
4235+
attempts to use TBB (Tor Browser Bundle) proxy at port '9150',
4236+
or system Tor ('little-t-tor') proxy at port '9050'.)
42194237
-l, --log-level=<level>
42204238
Choose log verbosity. Options: debug, info,
42214239
notice (default), warn, error.
@@ -4323,12 +4341,12 @@ set_target_user_account() {
43234341
target_user="${1:-}"
43244342

43254343
if [ "${sucmd}" != 'sudo' ]; then
4326-
log warn "Privilege escalation utilities other than 'sudo' for installing to an alternate user account or running under the sysmaint account is untested."
4344+
log warn "Privilege escalation utilities other than 'sudo' for installing to an alternate user account or running under account 'sysmaint' is untested."
43274345
fi
43284346

4329-
## getent may fail if the user doesn't exist, however we ignore it for now.
4347+
## 'getent' may fail if the account doesn't exist, however we ignore it for now.
43304348
## The reason is because if this is run as a user account `sysmaint` on a
4331-
## system with no user `user`, this will fail, but the user may have passed
4349+
## system with no account 'user', this will fail, but the account may have passed
43324350
## their own --user and --directory-prefix flags which will fix it.
43334351
user_home_dir="$(getent passwd "${target_user}" | cut -d':' -f6)" || true
43344352
}
@@ -4346,27 +4364,27 @@ run_as_target_user() {
43464364
run_as_target_user_and_dir() {
43474365
local target_dir
43484366
target_dir="${1:-}"
4349-
[ -z "${target_dir}" ] && die 1 'Failed to provide directory name to run_as_target-user_and_dir!'
4350-
[ -z "${target_user}" ] && die 1 'Cannot use run_as_target_user_and_dir if set_target_user_account is not used first!'
4367+
[ -z "${target_dir}" ] && die 1 "Failed to provide directory name to 'run_as_target_user_and_dir'!"
4368+
[ -z "${target_user}" ] && die 1 "Cannot use 'run_as_target_user_and_dir' if 'set_target_user_account' is not used first!"
43514369
shift
43524370
ROOT_CMD_TARGET_USER="${target_user}" ROOT_CMD_TARGET_DIR="${target_dir}" root_cmd "${@}"
43534371
}
43544372

43554373

43564374
adjust_default_for_sysmaint_maybe() {
43574375
if getent passwd sysmaint >/dev/null; then
4358-
log info 'Sysmaint user present, checking current user name...'
4376+
log info "Account 'sysmaint' exists: 'Yes'"
43594377

43604378
if [ "$(id -un)" = 'sysmaint' ]; then
4361-
log info "Running as sysmaint, adjusting behavior."
4379+
log info "Running under account 'sysmaint': 'Yes', adjusting behavior."
43624380

43634381
set_target_user_account 'user'
43644382
directory_prefix="${user_home_dir}/dist-installer-cli-download"
43654383
else
4366-
log info 'Not running as sysmaint user, ok.'
4384+
log info "Running under account 'sysmaint': 'No'"
43674385
fi
43684386
else
4369-
log info 'Sysmaint user not present, ok.'
4387+
log info "Account 'sysmaint' exists: 'No'"
43704388
fi
43714389
}
43724390

@@ -4665,6 +4683,18 @@ parse_opt() {
46654683
[ "${curr_shell}" = "bash" ] && set +o errtrace
46664684
fi
46674685

4686+
case "${hypervisor}" in
4687+
virtualbox)
4688+
hypervisor_pretty="VirtualBox"
4689+
;;
4690+
kvm)
4691+
hypervisor_pretty="KVM"
4692+
;;
4693+
*)
4694+
hypervisor_pretty="${hypervisor}"
4695+
;;
4696+
esac
4697+
46684698
log info "Option Parsing: 'success'"
46694699
}
46704700

@@ -4728,7 +4758,7 @@ run_installer() {
47284758
set_trap
47294759
## Parse script name for wanted values.
47304760
parse_name
4731-
## If sysmaint is in use and the user hasn't configured their own directory
4761+
## If account 'sysmaint' is in use and the user hasn't configured their own directory
47324762
## prefix and target user, default to target account 'user'.
47334763
adjust_default_for_sysmaint_maybe
47344764
## Parse command-line options.

0 commit comments

Comments
 (0)