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