@@ -48,6 +48,7 @@ __ScriptArgs="$*"
48
48
# * BS_GENTOO_USE_BINHOST: If 1 add `--getbinpkg` to gentoo's emerge
49
49
# * BS_SALT_MASTER_ADDRESS: The IP or DNS name of the salt-master the minion should connect to
50
50
# * BS_SALT_GIT_CHECKOUT_DIR: The directory where to clone Salt on git installations
51
+ # * BS_TMP_DIR: The directory to use for executing the installation (defaults to /tmp)
51
52
# ======================================================================================================================
52
53
53
54
@@ -171,12 +172,12 @@ __check_config_dir() {
171
172
172
173
case " $CC_DIR_NAME " in
173
174
http://* |https://* )
174
- __fetch_url " /tmp /${CC_DIR_BASE} " " ${CC_DIR_NAME} "
175
- CC_DIR_NAME=" /tmp /${CC_DIR_BASE} "
175
+ __fetch_url " ${_TMP_DIR} /${CC_DIR_BASE} " " ${CC_DIR_NAME} "
176
+ CC_DIR_NAME=" ${_TMP_DIR} /${CC_DIR_BASE} "
176
177
;;
177
178
ftp://* )
178
- __fetch_url " /tmp /${CC_DIR_BASE} " " ${CC_DIR_NAME} "
179
- CC_DIR_NAME=" /tmp /${CC_DIR_BASE} "
179
+ __fetch_url " ${_TMP_DIR} /${CC_DIR_BASE} " " ${CC_DIR_NAME} "
180
+ CC_DIR_NAME=" ${_TMP_DIR} /${CC_DIR_BASE} "
180
181
;;
181
182
* ://* )
182
183
echoerror " Unsupported URI scheme for $CC_DIR_NAME "
@@ -194,22 +195,22 @@ __check_config_dir() {
194
195
195
196
case " $CC_DIR_NAME " in
196
197
* .tgz|* .tar.gz)
197
- tar -zxf " ${CC_DIR_NAME} " -C /tmp
198
+ tar -zxf " ${CC_DIR_NAME} " -C ${_TMP_DIR}
198
199
CC_DIR_BASE=$( basename " ${CC_DIR_BASE} " " .tgz" )
199
200
CC_DIR_BASE=$( basename " ${CC_DIR_BASE} " " .tar.gz" )
200
- CC_DIR_NAME=" /tmp /${CC_DIR_BASE} "
201
+ CC_DIR_NAME=" ${_TMP_DIR} /${CC_DIR_BASE} "
201
202
;;
202
203
* .tbz|* .tar.bz2)
203
- tar -xjf " ${CC_DIR_NAME} " -C /tmp
204
+ tar -xjf " ${CC_DIR_NAME} " -C ${_TMP_DIR}
204
205
CC_DIR_BASE=$( basename " ${CC_DIR_BASE} " " .tbz" )
205
206
CC_DIR_BASE=$( basename " ${CC_DIR_BASE} " " .tar.bz2" )
206
- CC_DIR_NAME=" /tmp /${CC_DIR_BASE} "
207
+ CC_DIR_NAME=" ${_TMP_DIR} /${CC_DIR_BASE} "
207
208
;;
208
209
* .txz|* .tar.xz)
209
- tar -xJf " ${CC_DIR_NAME} " -C /tmp
210
+ tar -xJf " ${CC_DIR_NAME} " -C ${_TMP_DIR}
210
211
CC_DIR_BASE=$( basename " ${CC_DIR_BASE} " " .txz" )
211
212
CC_DIR_BASE=$( basename " ${CC_DIR_BASE} " " .tar.xz" )
212
- CC_DIR_NAME=" /tmp /${CC_DIR_BASE} "
213
+ CC_DIR_NAME=" ${_TMP_DIR} /${CC_DIR_BASE} "
213
214
;;
214
215
esac
215
216
@@ -245,6 +246,7 @@ __check_unparsed_options() {
245
246
# ----------------------------------------------------------------------------------------------------------------------
246
247
_KEEP_TEMP_FILES=${BS_KEEP_TEMP_FILES:- $BS_FALSE }
247
248
_TEMP_CONFIG_DIR=" null"
249
+ _TMP_DIR=${BS_TMP_DIR:- " /tmp" }
248
250
_SALTSTACK_REPO_URL=" https://github.com/saltstack/salt.git"
249
251
_SALT_REPO_URL=${_SALTSTACK_REPO_URL}
250
252
_TEMP_KEYS_DIR=" null"
@@ -281,7 +283,7 @@ _SIMPLIFY_VERSION=$BS_TRUE
281
283
_LIBCLOUD_MIN_VERSION=" 0.14.0"
282
284
_EXTRA_PACKAGES=" "
283
285
_HTTP_PROXY=" "
284
- _SALT_GIT_CHECKOUT_DIR=${BS_SALT_GIT_CHECKOUT_DIR:-/ tmp / git/ salt}
286
+ _SALT_GIT_CHECKOUT_DIR=${BS_SALT_GIT_CHECKOUT_DIR:- ${_TMP_DIR} / git/ salt}
285
287
_NO_DEPS=$BS_FALSE
286
288
_FORCE_SHALLOW_CLONE=$BS_FALSE
287
289
_DISABLE_SSL=$BS_FALSE
@@ -367,7 +369,7 @@ __usage() {
367
369
also be specified. Salt installation will be ommitted, but some of the
368
370
dependencies could be installed to write configuration with -j or -J.
369
371
-d Disables checking if Salt services are enabled to start on system boot.
370
- You can also do this by touching /tmp /disable_salt_checks on the target
372
+ You can also do this by touching ${BS_TMP_DIR} /disable_salt_checks on the target
371
373
host. Default: \$ {BS_FALSE}
372
374
-D Show debug output
373
375
-f Force shallow cloning for git installations.
@@ -424,6 +426,9 @@ __usage() {
424
426
-r Disable all repository configuration performed by this script. This
425
427
option assumes all necessary repository configuration is already present
426
428
on the system.
429
+ -T If set this overrides the use of /tmp for script execution. This is
430
+ to allow for systems in which noexec is applied to temp filesystem mounts
431
+ for security reasons
427
432
-U If set, fully upgrade the system prior to bootstrapping Salt
428
433
-v Display script version
429
434
-V Install Salt into virtualenv
@@ -436,7 +441,7 @@ __usage() {
436
441
EOT
437
442
} # ---------- end of function __usage ----------
438
443
439
- while getopts ' :hvnDc:g:Gx:k:s:MSWNXCPFUKIA:i:Lp:dH:bflV:J:j:rR:aqQ' opt
444
+ while getopts ' :hvnDc:g:Gx:k:s:MSWNXCPFUKIA:i:Lp:dH:bflV:J:j:rR:T: aqQ' opt
440
445
do
441
446
case " ${opt} " in
442
447
478
483
a ) _PIP_ALL=$BS_TRUE ;;
479
484
r ) _DISABLE_REPOS=$BS_TRUE ;;
480
485
R ) _CUSTOM_REPO_URL=$OPTARG ;;
486
+ T ) _TMP_DIR=" $OPTARG " ;;
481
487
J ) _CUSTOM_MASTER_CONFIG=$OPTARG ;;
482
488
j ) _CUSTOM_MINION_CONFIG=$OPTARG ;;
483
489
q ) _QUIET_GIT_INSTALLATION=$BS_TRUE ;;
@@ -495,10 +501,10 @@ done
495
501
shift $(( OPTIND- 1 ))
496
502
497
503
# Define our logging file and pipe paths
498
- LOGFILE=" /tmp /$( echo " $__ScriptName " | sed s/.sh/.log/g ) "
499
- LOGPIPE=" /tmp /$( echo " $__ScriptName " | sed s/.sh/.logpipe/g ) "
504
+ LOGFILE=" ${_TMP_DIR} /$( echo " $__ScriptName " | sed s/.sh/.log/g ) "
505
+ LOGPIPE=" ${_TMP_DIR} /$( echo " $__ScriptName " | sed s/.sh/.logpipe/g ) "
500
506
# Ensure no residual pipe exists
501
- rm " $LOGPIPE " 2> /dev/null
507
+ rm -f " $LOGPIPE " 2> /dev/null
502
508
503
509
# Create our logging pipe
504
510
# On FreeBSD we have to use mkfifo instead of mknod
@@ -534,7 +540,7 @@ exec 2>"$LOGPIPE"
534
540
# 14 SIGALRM
535
541
# 15 SIGTERM
536
542
# ----------------------------------------------------------------------------------------------------------------------
537
- APT_ERR=$( mktemp /tmp /apt_error.XXXXXX)
543
+ APT_ERR=$( mktemp ${_TMP_DIR} /apt_error.XXXXXX)
538
544
__exit_cleanup () {
539
545
EXIT_CODE=$?
540
546
@@ -927,6 +933,11 @@ if [ -d "${_VIRTUALENV_DIR}" ]; then
927
933
exit 1
928
934
fi
929
935
936
+ # Make sure the designated temp directory exists
937
+ if [ ! -d " ${_TMP_DIR} " ]; then
938
+ mkdir -p " ${_TMP_DIR} "
939
+ fi
940
+
930
941
# --- FUNCTION -------------------------------------------------------------------------------------------------------
931
942
# NAME: __fetch_url
932
943
# DESCRIPTION: Retrieves a URL and writes it to a given path
@@ -1996,14 +2007,14 @@ __apt_get_upgrade_noinput() {
1996
2007
# ----------------------------------------------------------------------------------------------------------------------
1997
2008
__temp_gpg_pub () {
1998
2009
if __check_command_exists mktemp; then
1999
- tempfile=" $( mktemp /tmp /salt-gpg-XXXXXXXX.pub 2> /dev/null) "
2010
+ tempfile=" $( mktemp ${_TMP_DIR} /salt-gpg-XXXXXXXX.pub 2> /dev/null) "
2000
2011
2001
2012
if [ -z " $tempfile " ]; then
2002
- echoerror " Failed to create temporary file in /tmp "
2013
+ echoerror " Failed to create temporary file in ${_TMP_DIR} "
2003
2014
return 1
2004
2015
fi
2005
2016
else
2006
- tempfile=" /tmp /salt-gpg-$$ .pub"
2017
+ tempfile=" ${_TMP_DIR} /salt-gpg-$$ .pub"
2007
2018
fi
2008
2019
2009
2020
echo $tempfile
@@ -2043,7 +2054,7 @@ __rpm_import_gpg() {
2043
2054
__fetch_url " $tempfile " " $url " || return 1
2044
2055
2045
2056
# At least on CentOS 8, a missing newline at the end causes:
2046
- # error: /tmp /salt-gpg-n1gKUb1u.pub: key 1 not an armored public key.
2057
+ # error: ${_TMP_DIR} /salt-gpg-n1gKUb1u.pub: key 1 not an armored public key.
2047
2058
# shellcheck disable=SC1003,SC2086
2048
2059
sed -i -e ' $a\' $tempfile
2049
2060
@@ -2109,7 +2120,7 @@ __git_clone_and_checkout() {
2109
2120
fi
2110
2121
2111
2122
__SALT_GIT_CHECKOUT_PARENT_DIR=$( dirname " ${_SALT_GIT_CHECKOUT_DIR} " 2> /dev/null)
2112
- __SALT_GIT_CHECKOUT_PARENT_DIR=" ${__SALT_GIT_CHECKOUT_PARENT_DIR:-/ tmp / git} "
2123
+ __SALT_GIT_CHECKOUT_PARENT_DIR=" ${__SALT_GIT_CHECKOUT_PARENT_DIR:- ${_TMP_DIR} / git} "
2113
2124
__SALT_CHECKOUT_REPONAME=" $( basename " ${_SALT_GIT_CHECKOUT_DIR} " 2> /dev/null) "
2114
2125
__SALT_CHECKOUT_REPONAME=" ${__SALT_CHECKOUT_REPONAME:- salt} "
2115
2126
[ -d " ${__SALT_GIT_CHECKOUT_PARENT_DIR} " ] || mkdir " ${__SALT_GIT_CHECKOUT_PARENT_DIR} "
@@ -2162,7 +2173,7 @@ __git_clone_and_checkout() {
2162
2173
2163
2174
if [ " $__SHALLOW_CLONE " -eq $BS_TRUE ]; then
2164
2175
# Let's try 'treeless' cloning to speed up. Treeless cloning omits trees and blobs ('files')
2165
- # but includes metadata (commit history, tags, branches etc.
2176
+ # but includes metadata (commit history, tags, branches etc.
2166
2177
# Test for "--filter" option introduced in git 2.19, the minimal version of git where the treeless
2167
2178
# cloning we need actually works
2168
2179
if [ " $( git clone 2>&1 | grep ' filter' ) " != " " ]; then
@@ -2390,14 +2401,14 @@ __overwriteconfig() {
2390
2401
2391
2402
# Make a tempfile to dump any python errors into.
2392
2403
if __check_command_exists mktemp; then
2393
- tempfile=" $( mktemp /tmp /salt-config-XXXXXXXX 2> /dev/null) "
2404
+ tempfile=" $( mktemp ${_TMP_DIR} /salt-config-XXXXXXXX 2> /dev/null) "
2394
2405
2395
2406
if [ -z " $tempfile " ]; then
2396
- echoerror " Failed to create temporary file in /tmp "
2407
+ echoerror " Failed to create temporary file in ${_TMP_DIR} "
2397
2408
return 1
2398
2409
fi
2399
2410
else
2400
- tempfile=" /tmp /salt-config-$$ "
2411
+ tempfile=" ${_TMP_DIR} /salt-config-$$ "
2401
2412
fi
2402
2413
2403
2414
if [ -n " $_PY_EXE " ]; then
@@ -2760,8 +2771,8 @@ __install_salt_from_repo() {
2760
2771
echoinfo " Installing salt using ${_py_exe} , $( ${_py_exe} --version) "
2761
2772
cd " ${_SALT_GIT_CHECKOUT_DIR} " || return 1
2762
2773
2763
- mkdir -p /tmp /git/deps
2764
- echodebug " Created directory /tmp /git/deps"
2774
+ mkdir -p ${_TMP_DIR} /git/deps
2775
+ echodebug " Created directory ${_TMP_DIR} /git/deps"
2765
2776
2766
2777
if [ ${DISTRO_NAME_L} = " ubuntu" ] && [ " $DISTRO_MAJOR_VERSION " -eq 22 ]; then
2767
2778
echodebug " Ubuntu 22.04 has problem with base.txt requirements file, not parsing sys_platform == 'win32', upgrading from default pip works"
@@ -2774,7 +2785,7 @@ __install_salt_from_repo() {
2774
2785
fi
2775
2786
fi
2776
2787
2777
- rm -f /tmp /git/deps/*
2788
+ rm -f ${_TMP_DIR} /git/deps/*
2778
2789
2779
2790
echodebug " Installing Salt requirements from PyPi, ${_pip_cmd} install ${_USE_BREAK_SYSTEM_PACKAGES} --ignore-installed ${_PIP_INSTALL_ARGS} -r requirements/static/ci/py${_py_version} /linux.txt"
2780
2791
${_pip_cmd} install ${_USE_BREAK_SYSTEM_PACKAGES} --ignore-installed ${_PIP_INSTALL_ARGS} -r " requirements/static/ci/py${_py_version} /linux.txt"
@@ -2799,7 +2810,7 @@ __install_salt_from_repo() {
2799
2810
2800
2811
echodebug " Running '${_py_exe} setup.py --salt-config-dir=$_SALT_ETC_DIR --salt-cache-dir=${_SALT_CACHE_DIR} ${SETUP_PY_INSTALL_ARGS} bdist_wheel'"
2801
2812
${_py_exe} setup.py --salt-config-dir=" $_SALT_ETC_DIR " --salt-cache-dir=" ${_SALT_CACHE_DIR} ${SETUP_PY_INSTALL_ARGS} " bdist_wheel || return 1
2802
- mv dist/salt* .whl /tmp /git/deps/ || return 1
2813
+ mv dist/salt* .whl ${_TMP_DIR} /git/deps/ || return 1
2803
2814
2804
2815
cd " ${__SALT_GIT_CHECKOUT_PARENT_DIR} " || return 1
2805
2816
@@ -2813,14 +2824,14 @@ __install_salt_from_repo() {
2813
2824
${_pip_cmd} install --force-reinstall --break-system-packages " ${_arch_dep} "
2814
2825
fi
2815
2826
2816
- echodebug " Running '${_pip_cmd} install ${_USE_BREAK_SYSTEM_PACKAGES} --no-deps --force-reinstall ${_PIP_INSTALL_ARGS} /tmp /git/deps/salt*.whl'"
2827
+ echodebug " Running '${_pip_cmd} install ${_USE_BREAK_SYSTEM_PACKAGES} --no-deps --force-reinstall ${_PIP_INSTALL_ARGS} ${_TMP_DIR} /git/deps/salt*.whl'"
2817
2828
2818
- echodebug " Running ${_pip_cmd} install ${_USE_BREAK_SYSTEM_PACKAGES} --no-deps --force-reinstall ${_PIP_INSTALL_ARGS} --global-option=--salt-config-dir=$_SALT_ETC_DIR --salt-cache-dir=${_SALT_CACHE_DIR} ${SETUP_PY_INSTALL_ARGS} /tmp /git/deps/salt*.whl"
2829
+ echodebug " Running ${_pip_cmd} install ${_USE_BREAK_SYSTEM_PACKAGES} --no-deps --force-reinstall ${_PIP_INSTALL_ARGS} --global-option=--salt-config-dir=$_SALT_ETC_DIR --salt-cache-dir=${_SALT_CACHE_DIR} ${SETUP_PY_INSTALL_ARGS} ${_TMP_DIR} /git/deps/salt*.whl"
2819
2830
2820
2831
${_pip_cmd} install ${_USE_BREAK_SYSTEM_PACKAGES} --no-deps --force-reinstall \
2821
2832
${_PIP_INSTALL_ARGS} \
2822
2833
--global-option=" --salt-config-dir=$_SALT_ETC_DIR --salt-cache-dir=${_SALT_CACHE_DIR} ${SETUP_PY_INSTALL_ARGS} " \
2823
- /tmp /git/deps/salt* .whl || return 1
2834
+ ${_TMP_DIR} /git/deps/salt* .whl || return 1
2824
2835
2825
2836
echoinfo " Checking if Salt can be imported using ${_py_exe} "
2826
2837
CHECK_SALT_SCRIPT=$( cat << EOM
@@ -7797,7 +7808,7 @@ install_macosx_git_deps() {
7797
7808
export PATH=/usr/local/bin:$PATH
7798
7809
fi
7799
7810
7800
- __fetch_url " /tmp /get-pip.py" " https://bootstrap.pypa.io/get-pip.py" || return 1
7811
+ __fetch_url " ${_TMP_DIR} /get-pip.py" " https://bootstrap.pypa.io/get-pip.py" || return 1
7801
7812
7802
7813
if [ -n " $_PY_EXE " ]; then
7803
7814
_PYEXE=" ${_PY_EXE} "
@@ -7807,7 +7818,7 @@ install_macosx_git_deps() {
7807
7818
fi
7808
7819
7809
7820
# Install PIP
7810
- $_PYEXE /tmp /get-pip.py || return 1
7821
+ $_PYEXE ${_TMP_DIR} /get-pip.py || return 1
7811
7822
7812
7823
# shellcheck disable=SC2119
7813
7824
__git_clone_and_checkout || return 1
@@ -7819,9 +7830,9 @@ install_macosx_stable() {
7819
7830
7820
7831
install_macosx_stable_deps || return 1
7821
7832
7822
- __fetch_url " /tmp /${PKG} " " ${SALTPKGCONFURL} " || return 1
7833
+ __fetch_url " ${_TMP_DIR} /${PKG} " " ${SALTPKGCONFURL} " || return 1
7823
7834
7824
- /usr/sbin/installer -pkg " /tmp /${PKG} " -target / || return 1
7835
+ /usr/sbin/installer -pkg " ${_TMP_DIR} /${PKG} " -target / || return 1
7825
7836
7826
7837
return 0
7827
7838
}
@@ -7830,9 +7841,9 @@ install_macosx_onedir() {
7830
7841
7831
7842
install_macosx_onedir_deps || return 1
7832
7843
7833
- __fetch_url " /tmp /${PKG} " " ${SALTPKGCONFURL} " || return 1
7844
+ __fetch_url " ${_TMP_DIR} /${PKG} " " ${SALTPKGCONFURL} " || return 1
7834
7845
7835
- /usr/sbin/installer -pkg " /tmp /${PKG} " -target / || return 1
7846
+ /usr/sbin/installer -pkg " ${_TMP_DIR} /${PKG} " -target / || return 1
7836
7847
7837
7848
return 0
7838
7849
}
0 commit comments