diff --git a/.gitignore b/.gitignore index b411b21..b185473 100644 --- a/.gitignore +++ b/.gitignore @@ -3,5 +3,4 @@ /Config.ps1 /crons/*.status /distinct/*.msg -/git-prompt.sh /ssh diff --git a/internal/update-git-prompt.sh b/internal/update-git-prompt.sh new file mode 100644 index 0000000..bab4547 --- /dev/null +++ b/internal/update-git-prompt.sh @@ -0,0 +1,12 @@ +#!/usr/bin/env bash + +# the command used to initialize our partial subtree +#git remote add -f -t master --no-tags gitprompt https://github.com/git/git.git +#git read-tree --prefix=git-prompt/ -u gitprompt/master:contrib/completion +#git commit + +# the command used to update our partial subtree +git rm -rf git-prompt +git read-tree --prefix=git-prompt/ -u gitprompt/master:contrib/completion +git commit + diff --git a/setup/0-pre-config.sh b/setup/0-pre-config.sh index accfe6f..bc07e14 100755 --- a/setup/0-pre-config.sh +++ b/setup/0-pre-config.sh @@ -26,91 +26,3 @@ case "${response}" in esac echo '' -# ---------------------------------------------------------- - -read -p 'Install scripts into your ~/bin? [y/N]: ' response -case "${response}" in - [Yy]* ) - # setup symlinks, if not installed in users bin directory - # need absolute path, so the symbolic links will be created correctly. - script_dir=$(readlink -f "$0" | xargs dirname | xargs dirname) - - # --- home bin folder --- - if [[ ! -d "${HOME}/bin" ]]; then - echo 'making personal bin directory' - mkdir -p "${HOME}/bin" - fi - - # --- general scripts --- - if [[ ! -f "${HOME}/bin/4-public-ip.sh" ]]; then - echo 'installing 4-public-ip.sh' - ln -s "${script_dir}/4-public-ip.sh" "${HOME}/bin/4-public-ip.sh" - fi - - if [[ ! -f "${HOME}/bin/6-public-ip.sh" ]]; then - echo 'installing 6-public-ip.sh' - ln -s "${script_dir}/6-public-ip.sh" "${HOME}/bin/6-public-ip.sh" - fi - - if [[ ! -f "${HOME}/bin/docker-ps.sh" ]]; then - echo 'installing docker-ps.sh' - ln -s "${script_dir}/docker-ps.sh" "${HOME}/bin/docker-ps.sh" - fi - - if [[ ! -f "${HOME}/bin/delay.sh" ]]; then - echo 'installing delay.sh' - ln -s "${script_dir}/delay.sh" "${HOME}/bin/delay.sh" - fi - - if [[ ! -f "${HOME}/bin/enumerate.sh" ]]; then - echo 'installing enumerate.sh' - ln -s "${script_dir}/enumerate.sh" "${HOME}/bin/enumerate.sh" - fi - - if [[ ! -f "${HOME}/bin/is-restart-needed.sh" ]]; then - echo 'installing is-restart-needed.sh' - ln -s "${script_dir}/is-restart-needed.sh" "${HOME}/bin/is-restart-needed.sh" - fi - - if [[ ! -f "${HOME}/bin/named-cat.sh" ]]; then - echo 'installing named-cat.sh' - ln -s "${script_dir}/named-cat.sh" "${HOME}/bin/named-cat.sh" - fi - - if [[ ! -f "${HOME}/bin/restart-if-needed.sh" ]]; then - echo 'installing restart-if-needed.sh' - ln -s "${script_dir}/restart-if-needed.sh" "${HOME}/bin/restart-if-needed.sh" - fi - - if [[ ! -f "${HOME}/bin/upgrade.sh" ]]; then - echo 'installing upgrade.sh' - ln -s "${script_dir}/upgrade.sh" "${HOME}/bin/upgrade.sh" - fi - - # --- git related scripts --- - if [[ ! -f "${HOME}/bin/fetch-all.sh" ]]; then - echo 'installing fetch-all.sh' - ln -s "${script_dir}/fetch-all.sh" "${HOME}/bin/fetch-all.sh" - fi - - if [[ ! -f "${HOME}/bin/list-all.sh" ]]; then - echo 'installing list-all.sh' - ln -s "${script_dir}/list-all.sh" "${HOME}/bin/list-all.sh" - fi - - if [[ ! -f "${HOME}/bin/pull-all.sh" ]]; then - echo 'installing pull-all.sh' - ln -s "${script_dir}/pull-all.sh" "${HOME}/bin/pull-all.sh" - fi - - if [[ ! -f "${HOME}/bin/status-all.sh" ]]; then - echo 'installing status-all.sh' - ln -s "${script_dir}/status-all.sh" "${HOME}/bin/status-all.sh" - fi - ;; - * ) - echo 'Skipping' - ;; -esac -echo '' - diff --git a/setup/1-choose-packages.sh b/setup/1-choose-packages.sh index a5e9db0..83bf6b5 100755 --- a/setup/1-choose-packages.sh +++ b/setup/1-choose-packages.sh @@ -1,7 +1,11 @@ #!/usr/bin/env bash +called_backup=false called_update=false +curdate=$(date '+%Y-%m-%d') script_dir=$(dirname "$0") +# absolute path to this scripts parent directory (package root) +package_dir=$(readlink -f "$0" | xargs dirname | xargs dirname) # ---------------------------------------------------------- @@ -26,6 +30,39 @@ function install_collection () { # ---------------------------------------------------------- +# call this function before editing bashrc, will only make backup if needed +function make_bashrc_backup () { + if [ "${called_backup}" = false ]; then + called_backup=true + if [[ ! -f "${HOME}/bashrc.backup.${curdate}" ]]; then + echo 'backing up existing bashrc' + cp "${HOME}/.bashrc" "${HOME}/bashrc.backup.${curdate}" + fi + fi +} + +# ---------------------------------------------------------- + +read -p 'Configure PATH for scripts in this package? [y/N]: ' response +case "${response}" in + [Yy]* ) + make_bashrc_backup + ( cat << BASHRC + +# ABS include shell scripts +export PATH="${package_dir}:\$PATH" + +BASHRC +) >> "${HOME}/.bashrc" + ;; + * ) + echo 'Skipping' + ;; +esac +echo '' + +# ---------------------------------------------------------- + install_collection 'core utilities: (curl, python3, jq, htop, etc.)' curl fail2ban git htop jq grep gzip net-tools goaccess dnsutils bash-completion cron vim make chrony build-essential gcc inotify-tools python3 python-is-python3 screen bc # ---------------------------------------------------------- @@ -41,15 +78,15 @@ install_collection 'Ruby: (ruby, build-essential)' ruby-full build-essential zli read -p 'Configure GEM_HOME and PATH for Ruby support? [y/N]: ' response case "${response}" in [Yy]* ) + make_bashrc_backup ( cat << 'BASHRC' -# Install Ruby Gems to ~/gems +# ABS configure ruby gems export GEM_HOME="$HOME/gems" export PATH="$HOME/gems/bin:$PATH" BASHRC ) >> "${HOME}/.bashrc" - show_note=true ;; * ) echo 'Skipping' @@ -90,6 +127,7 @@ echo '' read -p 'Install GoLang? [y/N]: ' response case "${response}" in [Yy]* ) + make_bashrc_backup sudo apt install wget jq -y # load json file with version info, filter to only stable versions, take the first (newest), strip to just numeric version_flag='' diff --git a/setup/2-config.sh b/setup/2-config.sh index d1c5ca5..33b816a 100755 --- a/setup/2-config.sh +++ b/setup/2-config.sh @@ -3,6 +3,8 @@ called_backup=false curdate=$(date '+%Y-%m-%d') script_dir=$(dirname "$0") +# absolute path to this scripts parent directory (package root) +package_dir=$(readlink -f "$0" | xargs dirname | xargs dirname) # ---------------------------------------------------------- @@ -23,18 +25,13 @@ read -p 'Install git-prompt and include in ~/.bashrc? [y/N]: ' response case "${response}" in [Yy]* ) make_bashrc_backup - sudo apt install wget jq -y - # make home bin folder if needed - [ ! -d "${HOME}/bin" ] && mkdir "${HOME}/bin" - # download git-prompt - wget 'https://raw.githubusercontent.com/git/git/master/contrib/completion/git-prompt.sh' -O "${HOME}/bin/git-prompt.sh" -q && ( cat << 'BASHRC' + ( cat << BASHRC -# ABS git prompt -source ~/bin/git-prompt.sh +# ABS include git prompt +source ${package_dir}/git-prompt.sh BASHRC ) >> "${HOME}/.bashrc" - chmod +x "${HOME}/bin/git-prompt.sh" ;; * ) echo 'Skipping' @@ -165,12 +162,12 @@ echo '' # ---------------------------------------------------------- -read -p 'Set "ssh" alias to ssh-ident"? (and set python3 as python) [y/N]: ' response +read -p 'Set "ssh" symlink to "ssh-ident"? (and set python3 as python) [y/N]: ' response case "${response}" in [Yy]* ) sudo apt install python-is-python3 -y - if [[ ! -f "${HOME}/bin/ssh" ]]; then - ln -s "${script_dir}/ssh-ident" "${HOME}/bin/ssh" + if [[ ! -f "${script_dir}/../ssh" ]]; then + ln -s './ssh-ident' "${script_dir}/../ssh" fi ;; * )