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}")" bool="$(gsettings get "${group}" "${name}")"
sh_log_debug "${var}: ${bool}" sh_log_debug "${var}: ${bool}"
# not # not
bool="$(sh_not "${bool}")" bool="$(not "${bool}")"
sh_log_debug "bool: ${bool}" sh_log_debug "bool: ${bool}"
# set # set
gsettings set "${group}" "${name}" "${bool}" gsettings set "${group}" "${name}" "${bool}"

View file

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

View file

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

View file

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

View file

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

View file

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