Small logging and nand-sata-install improvements

This commit is contained in:
Thomas Kaiser 2017-04-08 16:23:09 +02:00
parent 71d89e856d
commit c1f1c173c4
2 changed files with 24 additions and 7 deletions

View File

@ -678,7 +678,7 @@ CollectSupportInfo() {
;;
esac
echo -e "\n### Loaded modules:\n\n$(lsmod)"
[[ -f /boot/armbianEnv.txt ]] && echo -e "\n### armbianEnv.txt:\n\n$(cat /boot/armbianEnv.txt)"
[[ -f /var/log/nand-sata-install.log ]] && echo -e "\n### nand-sata-install.log:\n\n$(cat /var/log/nand-sata-install.log)"
echo -e "\n### Current sysinfo:\n\n$(iostat -p ALL | grep -v "^loop")\n\n$(vmstat -w)\n\n$(free -h)\n\n$(dmesg | tail -n 250)"
ls /tmp/armbianmonitor_checks_* >/dev/null 2>&1 || return
for file in /tmp/armbianmonitor_checks_* ; do

View File

@ -18,13 +18,12 @@
CWD="/usr/lib/nand-sata-install"
EX_LIST="${CWD}/exclude.txt"
nanddevice="/dev/nand"
logfile="/tmp/nand-sata-install.log"
rm -f $logfile
logfile="/var/log/nand-sata-install.log"
# read in board info
[[ -f /etc/armbian-release ]] && source /etc/armbian-release
backtitle="Armbian for $BOARD_NAME install script, http://www.armbian.com"
title="NAND, eMMC, SATA and USB Armbian installer v""$VERSION"
title="NAND, eMMC, SATA and USB Armbian installer v${VERSION}"
# exception
if cat /proc/cpuinfo | grep -q 'sun4i'; then DEVICE_TYPE="a10"; else DEVICE_TYPE="a20"; fi
@ -92,7 +91,10 @@ create_armbian()
fi
# write stuff to log
echo "SD uuid: $sduuid" >> $logfile
[ -f $logfile ] && echo -e "\n\n\n" >> $logfile
LANG=C echo -e "$(date): Start ${0##*/}. Files open for write:" >> $logfile
lsof / | awk 'NR==1 || $4~/[0-9][uw]/' >> $logfile
echo -e "\nSD uuid: $sduuid" >> $logfile
echo "Satauid: $satauuid" >> $logfile
echo "Emmcuuid: $emmcuuid $eMMCFilesystemChoosen" >> $logfile
echo "Boot: \$1 $1 $eMMCFilesystemChoosen" >> $logfile
@ -100,6 +102,11 @@ create_armbian()
echo "Usage: $USAGE" >> $logfile
echo "Dest: $DEST" >> $logfile
# stop running services
StopRunningServices "nfs-|smbd|nmbd|ftpd|netatalk|monit|cron|webmin|rrdcached" >> $logfile
StopRunningServices "log2ram|postgres|mariadb|mysql|postfix|mail|nginx|apache|snmpd" >> $logfile
echo -e "\n" >> $logfile
# count files is needed for progress bar
dialog --title "$title" --backtitle "$backtitle" --infobox "\n Counting files ... few seconds." 5 40
TODO=$(rsync -ahvrltDn --delete --stats --exclude-from=$EX_LIST / /mnt/rootfs | grep "Number of files:"|awk '{print $4}' | tr -d '.,')
@ -113,8 +120,6 @@ create_armbian()
dialog --title "$title" --backtitle "$backtitle" --infobox "\n Cleaning up ... few seconds." 5 40
rsync -avrltD --delete --exclude-from=$EX_LIST / /mnt/rootfs >/dev/null 2>&1
# creating fstab from scratch
rm -f /mnt/rootfs/etc/fstab
mkdir -p /mnt/rootfs/etc /mnt/rootfs/media/mmcboot /mnt/rootfs/media/mmcroot
@ -406,6 +411,15 @@ ShowWarning()
[[ $? -ne 0 ]] && exit 1
}
# try to stop running services
StopRunningServices()
{
systemctl --state=running | awk -F" " '/.service/ {print $1}' | sort -r | \
egrep -e "$1" | while read ; do
echo -e "\nStopping ${REPLY} \c"
systemctl stop ${REPLY} 2>&1
done
}
main()
{
@ -498,6 +512,9 @@ main()
esac
done
LANG=C echo -e "\n$(date): Finished. Files open for write:" >> $logfile
lsof / | awk 'NR==1 || $4~/[0-9][uw]/' >> $logfile
dialog --title "$title" --backtitle "$backtitle" --yes-label "$command" --no-label "Exit" --yesno "\nAll done. $command $REMOVESDTXT" 7 60
[[ $? -eq 0 ]] && "$(echo ${command,,} | sed 's/ //')"
} # main