Compare commits
10 commits
96f0697e37
...
d691f67581
Author | SHA1 | Date | |
---|---|---|---|
d691f67581 | |||
e305827808 | |||
5ffc9fc840 | |||
cdc976db0b | |||
942de1caed | |||
86db452e72 | |||
510ca5a5b3 | |||
6b45b885c7 | |||
c2a3a130d1 | |||
4cf5783562 |
7 changed files with 48 additions and 49 deletions
|
@ -16,7 +16,7 @@ sh_gnome_workspaces_primary() {
|
|||
bool="$(gsettings get "${group}" "${name}")"
|
||||
sh_log_debug "${var}: ${bool}"
|
||||
# not
|
||||
bool="$(not "${bool}")"
|
||||
bool="$(sh_not "${bool}")"
|
||||
sh_log_debug "bool: ${bool}"
|
||||
# set
|
||||
gsettings set "${group}" "${name}" "${bool}"
|
||||
|
|
20
sh/main.sh
20
sh/main.sh
|
@ -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"
|
||||
|
|
|
@ -7,9 +7,9 @@ rescue_wipe_0_init_hetzner_8_8() {
|
|||
local number
|
||||
local passphrase
|
||||
# read passphrase
|
||||
passphrase="$(read_passphrase)"
|
||||
passphrase="$(sh_read_passphrase)"
|
||||
# warn
|
||||
warn_wipe "${@}"
|
||||
sh_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="$(read_passphrase)"
|
||||
passphrase="$(sh_read_passphrase)"
|
||||
# encrypt
|
||||
sh_fs_luks_format "${passphrase}" "/dev/md/crypt"
|
||||
# open
|
||||
|
|
|
@ -2,9 +2,9 @@ rescue_wipe_0_init_ovh_vle2() {
|
|||
local device="/dev/sdb"
|
||||
local passphrase
|
||||
# read passphrase
|
||||
passphrase="$(read_passphrase)"
|
||||
passphrase="$(sh_read_passphrase)"
|
||||
# warn
|
||||
warn_wipe "${device}"
|
||||
sh_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="$(read_passphrase)"
|
||||
passphrase="$(sh_read_passphrase)"
|
||||
# crypt / encrypt
|
||||
sh_fs_luks_format "${passphrase}" "${device}1"
|
||||
# crypt / open
|
||||
|
|
49
sh/shell.sh
49
sh/shell.sh
|
@ -1,7 +1,3 @@
|
|||
PS1="\$(sh_shell_prompt \${?})"
|
||||
PS2="\
|
||||
├ "
|
||||
|
||||
_sh_shell_color() {
|
||||
local code="${1}"
|
||||
case "${SH_SHELL}" in
|
||||
|
@ -23,14 +19,14 @@ _sh_shell_color() {
|
|||
;;
|
||||
esac
|
||||
}
|
||||
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_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)"
|
||||
|
||||
shell_configure() {
|
||||
sh_shell_configure() {
|
||||
case "${SH_SHELL}" in
|
||||
"bash")
|
||||
# completion
|
||||
|
@ -52,11 +48,14 @@ shell_configure() {
|
|||
HISTCONTROL="ignorespace"
|
||||
HISTSIZE=-1
|
||||
HISTTIMEFORMAT="%Y%m%d %H%M%S "
|
||||
# prompt
|
||||
PS1="\$(sh_shell_prompt \${?})"
|
||||
PS2="├ "
|
||||
;;
|
||||
*) ;;
|
||||
esac
|
||||
}
|
||||
shell_configure
|
||||
sh_shell_configure
|
||||
|
||||
sh_shell_prompt() {
|
||||
local date host id
|
||||
|
@ -70,48 +69,48 @@ sh_shell_prompt() {
|
|||
local view="└ "
|
||||
# code
|
||||
if [ "${code}" -ne 0 ]; then
|
||||
view="${view}${SH_GREEN}"
|
||||
view="${view}${SH_COLOR_GREEN}"
|
||||
else
|
||||
view="${view}${SH_RED}"
|
||||
view="${view}${SH_COLOR_RED}"
|
||||
fi
|
||||
view="${view}${code}"
|
||||
# date
|
||||
view="${view}${SH_DEFAULT} @ "
|
||||
view="${view}${SH_BROWN}${date}"
|
||||
view="${view}${SH_COLOR_DEFAULT} @ "
|
||||
view="${view}${SH_COLOR_BROWN}${date}"
|
||||
# git
|
||||
if command -v "__git_ps1" >"/dev/null"; then
|
||||
git="$(__git_ps1)"
|
||||
if [ -n "${git}" ]; then
|
||||
view="${view}${SH_DEFAULT} –${SH_MAGENTA}${git}"
|
||||
view="${view}${SH_COLOR_DEFAULT} –${SH_COLOR_MAGENTA}${git}"
|
||||
fi
|
||||
fi
|
||||
# new
|
||||
view="${view}\\n"
|
||||
# path
|
||||
view="${view}${SH_CYAN}${path}"
|
||||
view="${view}${SH_COLOR_CYAN}${path}"
|
||||
# new
|
||||
view="${view}\\n"
|
||||
# frame
|
||||
view="${view}${SH_DEFAULT}┌ "
|
||||
view="${view}${SH_COLOR_DEFAULT}┌ "
|
||||
# user
|
||||
if [ "${id}" -eq 0 ]; then
|
||||
view="${view}${SH_GREEN}"
|
||||
view="${view}${SH_COLOR_GREEN}"
|
||||
else
|
||||
view="${view}${SH_RED}"
|
||||
view="${view}${SH_COLOR_RED}"
|
||||
fi
|
||||
view="${view}${user}"
|
||||
# host
|
||||
view="${view}${SH_DEFAULT} @ "
|
||||
view="${view}${SH_BROWN}${host}"
|
||||
view="${view}${SH_COLOR_DEFAULT} @ "
|
||||
view="${view}${SH_COLOR_BROWN}${host}"
|
||||
# new
|
||||
view="${view}\\n"
|
||||
# prompt
|
||||
view="${view}${SH_DEFAULT}${PS2}"
|
||||
view="${view}${SH_COLOR_DEFAULT}${PS2}"
|
||||
# print
|
||||
printf "%b" "${view}"
|
||||
}
|
||||
|
||||
shell_setup() {
|
||||
sh_shell_setup() {
|
||||
# shell
|
||||
echo "export ENV=\"${ENV}\"" >"/etc/profile.d/sh.sh"
|
||||
# bash
|
||||
|
|
14
sh/util.sh
14
sh/util.sh
|
@ -1,10 +1,10 @@
|
|||
list_block_devices() {
|
||||
sh_list_block_devices() {
|
||||
lsblk \
|
||||
--noempty \
|
||||
--output "NAME,SIZE,TYPE,FSTYPE,LABEL,MOUNTPOINTS"
|
||||
}
|
||||
|
||||
not() {
|
||||
sh_not() {
|
||||
case "${1}" in
|
||||
"false") echo "true" ;;
|
||||
"true") echo "false" ;;
|
||||
|
@ -12,11 +12,11 @@ not() {
|
|||
esac
|
||||
}
|
||||
|
||||
read_passphrase() {
|
||||
read_secret "PassPhrase: "
|
||||
sh_read_passphrase() {
|
||||
sh_read_secret "PassPhrase: "
|
||||
}
|
||||
|
||||
read_secret() {
|
||||
sh_read_secret() {
|
||||
local prompt="${1}"
|
||||
local secret
|
||||
printf "%s" "${prompt}" 1>&2
|
||||
|
@ -28,9 +28,9 @@ read_secret() {
|
|||
unset secret
|
||||
}
|
||||
|
||||
warn_wipe() {
|
||||
sh_warn_wipe() {
|
||||
local tmp
|
||||
list_block_devices
|
||||
sh_list_block_devices
|
||||
printf "%s" "WIPE ${*} /?\\ OR CANCEL /!\\"
|
||||
read -r tmp
|
||||
sh_log_trace "${tmp}"
|
||||
|
|
Loading…
Reference in a new issue