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}")"
|
bool="$(gsettings get "${group}" "${name}")"
|
||||||
sh_log_debug "${var}: ${bool}"
|
sh_log_debug "${var}: ${bool}"
|
||||||
# not
|
# not
|
||||||
bool="$(not "${bool}")"
|
bool="$(sh_not "${bool}")"
|
||||||
sh_log_debug "bool: ${bool}"
|
sh_log_debug "bool: ${bool}"
|
||||||
# set
|
# set
|
||||||
gsettings set "${group}" "${name}" "${bool}"
|
gsettings set "${group}" "${name}" "${bool}"
|
||||||
|
|
20
sh/main.sh
20
sh/main.sh
|
@ -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"
|
||||||
|
|
|
@ -7,9 +7,9 @@ rescue_wipe_0_init_hetzner_8_8() {
|
||||||
local number
|
local number
|
||||||
local passphrase
|
local passphrase
|
||||||
# read passphrase
|
# read passphrase
|
||||||
passphrase="$(read_passphrase)"
|
passphrase="$(sh_read_passphrase)"
|
||||||
# warn
|
# warn
|
||||||
warn_wipe "${@}"
|
sh_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="$(read_passphrase)"
|
passphrase="$(sh_read_passphrase)"
|
||||||
# encrypt
|
# encrypt
|
||||||
sh_fs_luks_format "${passphrase}" "/dev/md/crypt"
|
sh_fs_luks_format "${passphrase}" "/dev/md/crypt"
|
||||||
# open
|
# open
|
||||||
|
|
|
@ -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="$(read_passphrase)"
|
passphrase="$(sh_read_passphrase)"
|
||||||
# warn
|
# warn
|
||||||
warn_wipe "${device}"
|
sh_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="$(read_passphrase)"
|
passphrase="$(sh_read_passphrase)"
|
||||||
# crypt / encrypt
|
# crypt / encrypt
|
||||||
sh_fs_luks_format "${passphrase}" "${device}1"
|
sh_fs_luks_format "${passphrase}" "${device}1"
|
||||||
# crypt / open
|
# crypt / open
|
||||||
|
|
49
sh/shell.sh
49
sh/shell.sh
|
@ -1,7 +1,3 @@
|
||||||
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
|
||||||
|
@ -23,14 +19,14 @@ _sh_shell_color() {
|
||||||
;;
|
;;
|
||||||
esac
|
esac
|
||||||
}
|
}
|
||||||
SH_BROWN="$(_sh_shell_color 33)"
|
SH_COLOR_BROWN="$(_sh_shell_color 33)"
|
||||||
SH_CYAN="$(_sh_shell_color 36)"
|
SH_COLOR_CYAN="$(_sh_shell_color 36)"
|
||||||
SH_DEFAULT="$(_sh_shell_color)"
|
SH_COLOR_DEFAULT="$(_sh_shell_color)"
|
||||||
SH_GREEN="$(_sh_shell_color 31)"
|
SH_COLOR_GREEN="$(_sh_shell_color 31)"
|
||||||
SH_MAGENTA="$(_sh_shell_color 35)"
|
SH_COLOR_MAGENTA="$(_sh_shell_color 35)"
|
||||||
SH_RED="$(_sh_shell_color 32)"
|
SH_COLOR_RED="$(_sh_shell_color 32)"
|
||||||
|
|
||||||
shell_configure() {
|
sh_shell_configure() {
|
||||||
case "${SH_SHELL}" in
|
case "${SH_SHELL}" in
|
||||||
"bash")
|
"bash")
|
||||||
# completion
|
# completion
|
||||||
|
@ -52,11 +48,14 @@ 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
|
||||||
}
|
}
|
||||||
shell_configure
|
sh_shell_configure
|
||||||
|
|
||||||
sh_shell_prompt() {
|
sh_shell_prompt() {
|
||||||
local date host id
|
local date host id
|
||||||
|
@ -70,48 +69,48 @@ sh_shell_prompt() {
|
||||||
local view="└ "
|
local view="└ "
|
||||||
# code
|
# code
|
||||||
if [ "${code}" -ne 0 ]; then
|
if [ "${code}" -ne 0 ]; then
|
||||||
view="${view}${SH_GREEN}"
|
view="${view}${SH_COLOR_GREEN}"
|
||||||
else
|
else
|
||||||
view="${view}${SH_RED}"
|
view="${view}${SH_COLOR_RED}"
|
||||||
fi
|
fi
|
||||||
view="${view}${code}"
|
view="${view}${code}"
|
||||||
# date
|
# date
|
||||||
view="${view}${SH_DEFAULT} @ "
|
view="${view}${SH_COLOR_DEFAULT} @ "
|
||||||
view="${view}${SH_BROWN}${date}"
|
view="${view}${SH_COLOR_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_DEFAULT} –${SH_MAGENTA}${git}"
|
view="${view}${SH_COLOR_DEFAULT} –${SH_COLOR_MAGENTA}${git}"
|
||||||
fi
|
fi
|
||||||
fi
|
fi
|
||||||
# new
|
# new
|
||||||
view="${view}\\n"
|
view="${view}\\n"
|
||||||
# path
|
# path
|
||||||
view="${view}${SH_CYAN}${path}"
|
view="${view}${SH_COLOR_CYAN}${path}"
|
||||||
# new
|
# new
|
||||||
view="${view}\\n"
|
view="${view}\\n"
|
||||||
# frame
|
# frame
|
||||||
view="${view}${SH_DEFAULT}┌ "
|
view="${view}${SH_COLOR_DEFAULT}┌ "
|
||||||
# user
|
# user
|
||||||
if [ "${id}" -eq 0 ]; then
|
if [ "${id}" -eq 0 ]; then
|
||||||
view="${view}${SH_GREEN}"
|
view="${view}${SH_COLOR_GREEN}"
|
||||||
else
|
else
|
||||||
view="${view}${SH_RED}"
|
view="${view}${SH_COLOR_RED}"
|
||||||
fi
|
fi
|
||||||
view="${view}${user}"
|
view="${view}${user}"
|
||||||
# host
|
# host
|
||||||
view="${view}${SH_DEFAULT} @ "
|
view="${view}${SH_COLOR_DEFAULT} @ "
|
||||||
view="${view}${SH_BROWN}${host}"
|
view="${view}${SH_COLOR_BROWN}${host}"
|
||||||
# new
|
# new
|
||||||
view="${view}\\n"
|
view="${view}\\n"
|
||||||
# prompt
|
# prompt
|
||||||
view="${view}${SH_DEFAULT}${PS2}"
|
view="${view}${SH_COLOR_DEFAULT}${PS2}"
|
||||||
# print
|
# print
|
||||||
printf "%b" "${view}"
|
printf "%b" "${view}"
|
||||||
}
|
}
|
||||||
|
|
||||||
shell_setup() {
|
sh_shell_setup() {
|
||||||
# shell
|
# shell
|
||||||
echo "export ENV=\"${ENV}\"" >"/etc/profile.d/sh.sh"
|
echo "export ENV=\"${ENV}\"" >"/etc/profile.d/sh.sh"
|
||||||
# bash
|
# bash
|
||||||
|
|
14
sh/util.sh
14
sh/util.sh
|
@ -1,10 +1,10 @@
|
||||||
list_block_devices() {
|
sh_list_block_devices() {
|
||||||
lsblk \
|
lsblk \
|
||||||
--noempty \
|
--noempty \
|
||||||
--output "NAME,SIZE,TYPE,FSTYPE,LABEL,MOUNTPOINTS"
|
--output "NAME,SIZE,TYPE,FSTYPE,LABEL,MOUNTPOINTS"
|
||||||
}
|
}
|
||||||
|
|
||||||
not() {
|
sh_not() {
|
||||||
case "${1}" in
|
case "${1}" in
|
||||||
"false") echo "true" ;;
|
"false") echo "true" ;;
|
||||||
"true") echo "false" ;;
|
"true") echo "false" ;;
|
||||||
|
@ -12,11 +12,11 @@ not() {
|
||||||
esac
|
esac
|
||||||
}
|
}
|
||||||
|
|
||||||
read_passphrase() {
|
sh_read_passphrase() {
|
||||||
read_secret "PassPhrase: "
|
sh_read_secret "PassPhrase: "
|
||||||
}
|
}
|
||||||
|
|
||||||
read_secret() {
|
sh_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 @@ read_secret() {
|
||||||
unset secret
|
unset secret
|
||||||
}
|
}
|
||||||
|
|
||||||
warn_wipe() {
|
sh_warn_wipe() {
|
||||||
local tmp
|
local tmp
|
||||||
list_block_devices
|
sh_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}"
|
||||||
|
|
Loading…
Reference in a new issue