diff options
| author | Mike Gabriel <mike.gabriel@das-netzwerkteam.de> | 2018-11-07 15:20:54 +0100 | 
|---|---|---|
| committer | Mike Gabriel <mike.gabriel@das-netzwerkteam.de> | 2018-11-07 16:01:04 +0100 | 
| commit | 48bdf9bfc4ab5a949eadd41c48c67a7cbcd72e9d (patch) | |
| tree | 81871efcd859f4cbf42accb688a8f8e81ba32b17 | |
| parent | b69afb0895f7bf90803c4aaa9c8f6e649198f9f1 (diff) | |
| download | itzks-systems-48bdf9bfc4ab5a949eadd41c48c67a7cbcd72e9d.tar.gz itzks-systems-48bdf9bfc4ab5a949eadd41c48c67a7cbcd72e9d.tar.bz2 itzks-systems-48bdf9bfc4ab5a949eadd41c48c67a7cbcd72e9d.zip | |
scripts: Add itzks-update-disklserver-squashfs-images for automatic LTSP squashfs updates.
| -rwxr-xr-x | sbin/itzks-update-disklserver-squashfs-images | 47 | 
1 files changed, 47 insertions, 0 deletions
| diff --git a/sbin/itzks-update-disklserver-squashfs-images b/sbin/itzks-update-disklserver-squashfs-images new file mode 100755 index 0000000..ad2ebe3 --- /dev/null +++ b/sbin/itzks-update-disklserver-squashfs-images @@ -0,0 +1,47 @@ +#!/bin/bash + +# Copyright (C) 2018 Mike Gabriel <mike.gabriel@das-netzwerkteam.de> +# +# This script is free software; you can redistribute it and/or modify +# it under the terms of the GNU General Public License as published by +# the Free Software Foundation; either version 2 of the License, or +# (at your option) any later version. +# +# This script is distributed in the hope that it will be useful, +# but WITHOUT ANY WARRANTY; without even the implied warranty of +# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the +# GNU General Public License for more details. +# +# You should have received a copy of the GNU General Public License +# along with this program; if not, write to the +# Free Software Foundation, Inc., +# 51 Franklin St, Fifth Floor, Boston, MA 02110-1301, USA. + +LTSP_OPT="/srv/ltsp" + +ltsp_chroots=$(ls $LTSP_OPT | while read chroot_dir; do test ! -h $LTSP_OPT/$chroot_dir -a -x $LTSP_OPT/$chroot_dir/bin/bash && echo -n "$chroot_dir "; done) + +for chroot in ${ltsp_chroots}; do + +	if [ -e $LTSP_OPT/$chroot/chroot-upgrade-in-process ]; then +		echo "Chroot $LTSP_OPT/$chroot is currently being upgraded. Skipping..." +		continue +	fi + +	latest_upgrade=$(ls $LTSP_OPT/$chroot | grep -E 'chroot-updated_[0-9]{8}$' | sort | tail -n1) + +	if [ -z "${latest_upgrade}" ]; then +		echo "chroot $LTSP_OPT/$chroot lacks the chroot-updated_<date> file. Can't proceeed. Skipping..." +		continue +	fi + +	if [ -e "$LTSP_OPT/$chroot/${latest_upgrade}.squashfs-created" ]; then +		echo "chroot $LTSP_OPT/$chroot's squashfs image is up-to-date. Skipping..." +	else +		if ltsp-update-image $chroot; then  +			rm -f $LTSP_OPT/$chroot/$chroot-updated_*.squashfs-created +			touch $LTSP_OPT/$chroot/${latest_upgrade}.squashfs-created +		fi +	fi  + +done | 
