Compare commits

..

No commits in common. "d691f67581762842bc8a5ad5f62d5f4797e09d92" and "96f0697e37a7c8f8fd84670f041ccc0470815bc1" have entirely different histories.

7 changed files with 49 additions and 48 deletions

View file

@ -16,7 +16,7 @@ sh_gnome_workspaces_primary() {
bool="$(gsettings get "${group}" "${name}")"
sh_log_debug "${var}: ${bool}"
# not
bool="$(sh_not "${bool}")"
bool="$(not "${bool}")"
sh_log_debug "bool: ${bool}"
# set
gsettings set "${group}" "${name}" "${bool}"

View file

@ -28,12 +28,12 @@ main_source_directory() {
IFS="
"
count=0
#echo
#echo ". ${path}"
echo
echo ". ${path}"
for module in ${modules}; do
count=$((count + 1))
#printf "%02d" "${count}"
#echo " ${module%.sh}"
printf "%02d" "${count}"
echo " ${module%.sh}"
module="${path}/${module}"
if [ "${module}" != "${ENV}" ]; then
. "${module}"
@ -47,7 +47,7 @@ main_source_directory() {
done
IFS="${ifs}"
else
#echo "Not a directory: ${path}"
echo "Not a directory: ${path}"
return 1
fi
}
@ -57,7 +57,7 @@ main_source_file() {
if [ -f "${path}" ]; then
main_source_directory "$(dirname "${path}")"
else
#echo "Not a file: ${path}"
echo "Not a file: ${path}"
return 1
fi
}
@ -66,7 +66,7 @@ main_source_file "${ENV}"
main_source_directory "${SH_USER}"
#sh_log "" \
# "sh_… = shell functions" \
# "a__… = aliases" \
# "u__… = user"
sh_log "" \
"sh_… = shell functions" \
"a__… = aliases" \
"u__… = user"

View file

@ -7,9 +7,9 @@ rescue_wipe_0_init_hetzner_8_8() {
local number
local passphrase
# read passphrase
passphrase="$(sh_read_passphrase)"
passphrase="$(read_passphrase)"
# warn
sh_warn_wipe "${@}"
warn_wipe "${@}"
#
number=0
for device in "${@}"; do
@ -105,7 +105,7 @@ rescue_wipe_2_make_hetzner_8_8() {
# close
cryptsetup luksClose "crypt"
# read passphrase
passphrase="$(sh_read_passphrase)"
passphrase="$(read_passphrase)"
# encrypt
sh_fs_luks_format "${passphrase}" "/dev/md/crypt"
# open

View file

@ -2,9 +2,9 @@ rescue_wipe_0_init_ovh_vle2() {
local device="/dev/sdb"
local passphrase
# read passphrase
passphrase="$(sh_read_passphrase)"
passphrase="$(read_passphrase)"
# warn
sh_warn_wipe "${device}"
warn_wipe "${device}"
#
parted --script "${device}" \
mktable gpt \
@ -50,7 +50,7 @@ rescue_wipe_2_make_ovh_vle2() {
# crypt / close
cryptsetup luksClose "crypt"
# read passphrase
passphrase="$(sh_read_passphrase)"
passphrase="$(read_passphrase)"
# crypt / encrypt
sh_fs_luks_format "${passphrase}" "${device}1"
# crypt / open

View file

@ -1,3 +1,7 @@
PS1="\$(sh_shell_prompt \${?})"
PS2="\
"
_sh_shell_color() {
local code="${1}"
case "${SH_SHELL}" in
@ -19,14 +23,14 @@ _sh_shell_color() {
;;
esac
}
SH_COLOR_BROWN="$(_sh_shell_color 33)"
SH_COLOR_CYAN="$(_sh_shell_color 36)"
SH_COLOR_DEFAULT="$(_sh_shell_color)"
SH_COLOR_GREEN="$(_sh_shell_color 31)"
SH_COLOR_MAGENTA="$(_sh_shell_color 35)"
SH_COLOR_RED="$(_sh_shell_color 32)"
SH_BROWN="$(_sh_shell_color 33)"
SH_CYAN="$(_sh_shell_color 36)"
SH_DEFAULT="$(_sh_shell_color)"
SH_GREEN="$(_sh_shell_color 31)"
SH_MAGENTA="$(_sh_shell_color 35)"
SH_RED="$(_sh_shell_color 32)"
sh_shell_configure() {
shell_configure() {
case "${SH_SHELL}" in
"bash")
# completion
@ -48,14 +52,11 @@ sh_shell_configure() {
HISTCONTROL="ignorespace"
HISTSIZE=-1
HISTTIMEFORMAT="%Y%m%d %H%M%S "
# prompt
PS1="\$(sh_shell_prompt \${?})"
PS2="├ "
;;
*) ;;
esac
}
sh_shell_configure
shell_configure
sh_shell_prompt() {
local date host id
@ -69,48 +70,48 @@ sh_shell_prompt() {
local view="└ "
# code
if [ "${code}" -ne 0 ]; then
view="${view}${SH_COLOR_GREEN}"
view="${view}${SH_GREEN}"
else
view="${view}${SH_COLOR_RED}"
view="${view}${SH_RED}"
fi
view="${view}${code}"
# date
view="${view}${SH_COLOR_DEFAULT} @ "
view="${view}${SH_COLOR_BROWN}${date}"
view="${view}${SH_DEFAULT} @ "
view="${view}${SH_BROWN}${date}"
# git
if command -v "__git_ps1" >"/dev/null"; then
git="$(__git_ps1)"
if [ -n "${git}" ]; then
view="${view}${SH_COLOR_DEFAULT}${SH_COLOR_MAGENTA}${git}"
view="${view}${SH_DEFAULT}${SH_MAGENTA}${git}"
fi
fi
# new
view="${view}\\n"
# path
view="${view}${SH_COLOR_CYAN}${path}"
view="${view}${SH_CYAN}${path}"
# new
view="${view}\\n"
# frame
view="${view}${SH_COLOR_DEFAULT}"
view="${view}${SH_DEFAULT}"
# user
if [ "${id}" -eq 0 ]; then
view="${view}${SH_COLOR_GREEN}"
view="${view}${SH_GREEN}"
else
view="${view}${SH_COLOR_RED}"
view="${view}${SH_RED}"
fi
view="${view}${user}"
# host
view="${view}${SH_COLOR_DEFAULT} @ "
view="${view}${SH_COLOR_BROWN}${host}"
view="${view}${SH_DEFAULT} @ "
view="${view}${SH_BROWN}${host}"
# new
view="${view}\\n"
# prompt
view="${view}${SH_COLOR_DEFAULT}${PS2}"
view="${view}${SH_DEFAULT}${PS2}"
# print
printf "%b" "${view}"
}
sh_shell_setup() {
shell_setup() {
# shell
echo "export ENV=\"${ENV}\"" >"/etc/profile.d/sh.sh"
# bash

View file

@ -1,10 +1,10 @@
sh_list_block_devices() {
list_block_devices() {
lsblk \
--noempty \
--output "NAME,SIZE,TYPE,FSTYPE,LABEL,MOUNTPOINTS"
}
sh_not() {
not() {
case "${1}" in
"false") echo "true" ;;
"true") echo "false" ;;
@ -12,11 +12,11 @@ sh_not() {
esac
}
sh_read_passphrase() {
sh_read_secret "PassPhrase: "
read_passphrase() {
read_secret "PassPhrase: "
}
sh_read_secret() {
read_secret() {
local prompt="${1}"
local secret
printf "%s" "${prompt}" 1>&2
@ -28,9 +28,9 @@ sh_read_secret() {
unset secret
}
sh_warn_wipe() {
warn_wipe() {
local tmp
sh_list_block_devices
list_block_devices
printf "%s" "WIPE ${*} /?\\ OR CANCEL /!\\"
read -r tmp
sh_log_trace "${tmp}"