log
This commit is contained in:
parent
b68d4746e6
commit
69dac56a26
6 changed files with 29 additions and 29 deletions
|
@ -35,8 +35,8 @@ apt_install_target() {
|
|||
shift
|
||||
local package
|
||||
for package in "${@}"; do
|
||||
log_info
|
||||
log_info "${package} ← ${target}"
|
||||
sh_log_info
|
||||
sh_log_info "${package} ← ${target}"
|
||||
apt-get \
|
||||
install \
|
||||
--assume-yes \
|
||||
|
|
|
@ -5,11 +5,11 @@ sh_gnome_workspaces_primary() {
|
|||
local var="${group}/${name}"
|
||||
# get
|
||||
bool="$(gsettings get "${group}" "${name}")"
|
||||
log_debug "${var}: ${bool}"
|
||||
sh_log_debug "${var}: ${bool}"
|
||||
# not
|
||||
bool="$(not "${bool}")"
|
||||
log_debug "bool: ${bool}"
|
||||
sh_log_debug "bool: ${bool}"
|
||||
# set
|
||||
gsettings set "${group}" "${name}" "${bool}"
|
||||
log_info "${var}: ${bool}"
|
||||
sh_log_info "${var}: ${bool}"
|
||||
}
|
||||
|
|
12
sh/log.sh
12
sh/log.sh
|
@ -7,37 +7,37 @@ SH_LOG_LEVEL_TRACE=5
|
|||
|
||||
SH_LOG_LEVEL=${SH_LOG_LEVEL_INFO}
|
||||
|
||||
log_debug() {
|
||||
sh_log_debug() {
|
||||
if [ "${SH_LOG_LEVEL}" -ge "${SH_LOG_LEVEL_DEBUG}" ]; then
|
||||
echo "[DEBUG]" "${@}"
|
||||
fi
|
||||
}
|
||||
|
||||
log_error() {
|
||||
sh_log_error() {
|
||||
if [ "${SH_LOG_LEVEL}" -ge "${SH_LOG_LEVEL_ERROR}" ]; then
|
||||
echo "[ERROR]" "${@}"
|
||||
fi
|
||||
}
|
||||
|
||||
log_fatal() {
|
||||
sh_log_fatal() {
|
||||
if [ "${SH_LOG_LEVEL}" -ge "${SH_LOG_LEVEL_FATAL}" ]; then
|
||||
echo "[FATAL]" "${@}"
|
||||
fi
|
||||
}
|
||||
|
||||
log_info() {
|
||||
sh_log_info() {
|
||||
if [ "${SH_LOG_LEVEL}" -ge "${SH_LOG_LEVEL_INFO}" ]; then
|
||||
echo "${@}"
|
||||
fi
|
||||
}
|
||||
|
||||
log_trace() {
|
||||
sh_log_trace() {
|
||||
if [ "${SH_LOG_LEVEL}" -ge "${SH_LOG_LEVEL_TRACE}" ]; then
|
||||
echo "[TRACE]" "${@}"
|
||||
fi
|
||||
}
|
||||
|
||||
log_warn() {
|
||||
sh_log_warn() {
|
||||
if [ "${SH_LOG_LEVEL}" -ge "${SH_LOG_LEVEL_WARN}" ]; then
|
||||
echo " [WARN]" "${@}"
|
||||
fi
|
||||
|
|
|
@ -44,8 +44,8 @@ main_source_directory() {
|
|||
fi
|
||||
done
|
||||
IFS="${ifs}"
|
||||
log_info
|
||||
log_info "${CMD}"
|
||||
sh_log_info
|
||||
sh_log_info "${CMD}"
|
||||
else
|
||||
echo "Not a directory: ${path}"
|
||||
return 1
|
||||
|
|
30
sh/mount.sh
30
sh/mount.sh
|
@ -1,36 +1,36 @@
|
|||
mo() {
|
||||
local root="${1}"
|
||||
if [ -z "${root}" ]; then
|
||||
log_error "No root target directory"
|
||||
sh_log_error "No root target directory"
|
||||
return 1
|
||||
fi
|
||||
root="$(realpath "${root}")"
|
||||
if ! mkdir "overlay"; then
|
||||
log_error "Unable to make overlay directory"
|
||||
sh_log_error "Unable to make overlay directory"
|
||||
return 2
|
||||
fi
|
||||
(
|
||||
if ! cd "overlay"; then
|
||||
log_error "Unable to move into overlay directory"
|
||||
sh_log_error "Unable to move into overlay directory"
|
||||
return 3
|
||||
fi
|
||||
local directory
|
||||
for directory in "lower" "upper" "work" "mount"; do
|
||||
if ! mkdir --parents "${directory}"; then
|
||||
log_error "Unable to make directory: ${directory}"
|
||||
sh_log_error "Unable to make directory: ${directory}"
|
||||
return 4
|
||||
fi
|
||||
done
|
||||
local file="${root}/filesystem.squashfs"
|
||||
if ! mount "${file}" "lower"; then
|
||||
log_error "Unable to lower mount: ${file}"
|
||||
sh_log_error "Unable to lower mount: ${file}"
|
||||
return 5
|
||||
fi
|
||||
if ! mount \
|
||||
-o "lowerdir=lower,upperdir=upper,workdir=work" \
|
||||
-t "overlay" \
|
||||
"overlay" "mount"; then
|
||||
log_error "Unable to overlay mount"
|
||||
sh_log_error "Unable to overlay mount"
|
||||
return 6
|
||||
fi
|
||||
)
|
||||
|
@ -39,35 +39,35 @@ mo() {
|
|||
uo() {
|
||||
(
|
||||
if ! cd "overlay"; then
|
||||
log_error "Unable to move into overlay directory"
|
||||
sh_log_error "Unable to move into overlay directory"
|
||||
return 1
|
||||
fi
|
||||
if ! umount "mount"; then
|
||||
log_error "Unable to unmount mount directory"
|
||||
sh_log_error "Unable to unmount mount directory"
|
||||
return 2
|
||||
fi
|
||||
if ! rmdir "mount"; then
|
||||
log_error "Unable to remove mount directory"
|
||||
sh_log_error "Unable to remove mount directory"
|
||||
return 3
|
||||
fi
|
||||
local directory
|
||||
for directory in "upper" "work"; do
|
||||
if ! rm --force --recursive "${directory}"; then
|
||||
log_error "Unable to remove directory: ${directory}"
|
||||
sh_log_error "Unable to remove directory: ${directory}"
|
||||
return 4
|
||||
fi
|
||||
done
|
||||
if ! umount "lower"; then
|
||||
log_error "Unable to unmount lower directory"
|
||||
sh_log_error "Unable to unmount lower directory"
|
||||
return 5
|
||||
fi
|
||||
if ! rmdir "lower"; then
|
||||
log_error "Unable to remove lower directory"
|
||||
sh_log_error "Unable to remove lower directory"
|
||||
return 6
|
||||
fi
|
||||
)
|
||||
if ! rmdir "overlay"; then
|
||||
log_error "Unable to remove overlay directory"
|
||||
sh_log_error "Unable to remove overlay directory"
|
||||
return 7
|
||||
fi
|
||||
}
|
||||
|
@ -76,7 +76,7 @@ mr() {
|
|||
local directory
|
||||
for directory in "dev" "dev/pts" "proc" "sys"; do
|
||||
if ! mount --bind "/${directory}" "overlay/mount/${directory}"; then
|
||||
log_error "Unable to bind mount directory: ${directory}"
|
||||
sh_log_error "Unable to bind mount directory: ${directory}"
|
||||
return 1
|
||||
fi
|
||||
done
|
||||
|
@ -97,7 +97,7 @@ ur() {
|
|||
local directory
|
||||
for directory in "sys" "proc" "dev/pts" "dev"; do
|
||||
if ! umount --lazy "overlay/mount/${directory}"; then
|
||||
log_error "Unable to bind unmount directory: ${directory}"
|
||||
sh_log_error "Unable to bind unmount directory: ${directory}"
|
||||
return 1
|
||||
fi
|
||||
done
|
||||
|
|
|
@ -33,5 +33,5 @@ warn_wipe() {
|
|||
list_block_devices
|
||||
printf "%s" "WIPE ${*} /?\\ OR CANCEL /!\\"
|
||||
read -r tmp
|
||||
log_trace "${tmp}"
|
||||
sh_log_trace "${tmp}"
|
||||
}
|
||||
|
|
Loading…
Reference in a new issue