Verified Commit 5e4f7f7c authored by Erazem Kokot's avatar Erazem Kokot
Browse files

Add printlog function

parent c97201c7
......@@ -27,10 +27,10 @@ start_menu() {
# Update Arch packages and keyring
log "Updating pacman keys"
pacman-key --keyserver hkp://keyserver.ubuntu.com --init 2>&1 | log
pacman-key --keyserver hkp://keyserver.ubuntu.com --populate archlinux 2>&1 | log
pacman-key --keyserver hkp://keyserver.ubuntu.com --refresh-keys 2>&1 | log
pacman -Sy --noconfirm 2>&1 | log
pacman-key --keyserver hkp://keyserver.ubuntu.com --init 2>&1 | printlog
pacman-key --keyserver hkp://keyserver.ubuntu.com --populate archlinux 2>&1 | printlog
pacman-key --keyserver hkp://keyserver.ubuntu.com --refresh-keys 2>&1 | printlog
pacman -Sy --noconfirm 2>&1 | printlog
touch /root/.anarchy_updated
;;
Start) touch /root/.anarchy_updated ;; # Pretend user has updated
......
......@@ -6,7 +6,6 @@ LOG_FILE="/root/anarchy.log"
export LOG_FILE
# Logging library, that appends its arguments (log messages) to the LOG_FILE
# It logs messages and command output but also prints command output to stdout
log() {
if [ -n "$1" ]; then
# Manual logging
......@@ -16,12 +15,21 @@ log() {
# Command output
echo "*** COMMAND OUTPUT ***" >>"${LOG_FILE}"
while read -r message; do
echo "${message}" | tee -a "${LOG_FILE}"
echo "${message}" >>"${LOG_FILE}"
done
echo "*** END OF COMMAND OUTPUT ***" >>"${LOG_FILE}"
fi
}
printlog() {
# Save output of command to log but also print it to stdout
echo "*** COMMAND OUTPUT ***" >>"${LOG_FILE}"
while read -r message; do
echo "${message}" | tee -a "${LOG_FILE}"
done
echo "*** END OF COMMAND OUTPUT ***" >>"${LOG_FILE}"
}
# Enable systemd services
enable_service() {
arch-chroot "${ARCH}" systemctl enable "$1"
......
Markdown is supported
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment