uboot configuration uimage file
scp <file(s)> hadaq@http://jspc29.x-matter.uni-frankfurt.de:/srv/www/htdocs/bitfiles uimage file, ≈3 MB: http://jspc29.x-matter.uni-frankfurt.de/bitfiles/dreamplug-uimage-04112013.tar.xz
system tar ball, ≈1 GB: http://jspc29.x-matter.uni-frankfurt.de/bitfiles/dreamplug-system-01032016.tar.xz uimage and the system tar ball
mkfs.vfat and mkfs.ext3 " " as name
dreamplugCreateBootDeviceFunctionSet.sh createBootDevicePartition
uimage into the first partition
root
dev/sda, there should be: /dev/sda: createBootDevicePartition source ~/dreamplugCreateBootDeviceFunctionSet.sh && target=<target> createBootDevicePartition
~/dreamplugCreateBootDeviceFunctionSet.sh
~/dreamplugRestoreLocalSystemFromExternal.sh
/proc/cmdline root mustn't be the internal /dev/sda2
/ as source for the system source to be different
/dev/sda1 and /dev/sda2
/dev/sdX1
uimage
-d: rsync with option --delete, any other content on the target system will be erased
-v: rsync with option --verbose, (much) more output
-n: rsync with option --dryRun, do nothing, just simulate
target=<span style="font-style:italic;font-variant:small-caps;"><Your Target Device, e.g. </span>sdd> &&
cd $(mktemp -d) &&
wget -N http://jspc29.x-matter.uni-frankfurt.de/bitfiles/dreamplug-uimage-04112013.tar.xz &&
wget -N http://jspc29.x-matter.uni-frankfurt.de/bitfiles/dreamplug-system-01032016.tar.xz &&
scr=$(tar atf dreamplug-system-01032016.tar.xz | grep -w dreamplugCreateBootDeviceFunctionSet.sh) &&
tar axf dreamplug-system-01032016.tar.xz $scr &&
mv $scr $(basename $scr) && unset scr &&
. ./dreamplugCreateBootDeviceFunctionSet.sh &&
createBootDevicePartition &&
createBootDeviceMounts &&
tar Jxvf dreamplug-uimage-04112013.tar.xz -C /mnt/${target}1 &&
tar Jxvf dreamplug-system-01032016.tar.xz -C /mnt/${target}2 &&
createBootDeviceUnmounts
#optional: cd && rm -rf $OLDPWD
root
#if you want to get the newest/or dreamplugRestoreLocalSystemFromExternal.sh is not on the system
wget -N https://wiki.gsi.de/pub/Epics/DreamplugRollbackSystemAndUImage/dreamplugRestoreLocalSystemFromExternal.sh
#optional source
source=<Your source Device, e.g. sdb>
chmod u+x ./dreamplugRestoreLocalSystemFromExternal.sh &&
./dreamplugRestoreLocalSystemFromExternal.sh
#!/bin/bash
function dreamplugRestoreUsage()
{
echo -e "usage:"
echo -e " $0 [ options ] "
echo -e "$0 restores local file system from the source via rsync"
echo -e " $0 -h : this help"
echo -e " $0 -d : performs rsync with the option '--delete'"
echo -e " $0 -n : performs rsync with the option '--dryRun'"
echo -e " $0 -v : performs rsync with the option '--verbose'"
echo -e " $0 -s : source device"
echo -e "\nsetting the environment variable 'clearSystem' to a not empty value"
echo -e " performes the rsync with the option '--delete'"
echo
exit
}
function dreamplugRestoreSetSource()
{
source=${source:=$(basename $(cat /proc/cmdline | tr " " "\n" | grep root= | cut -d "=" -f 2 | sed -e 's/\(.*\)[1-9]/\1/'))}
echo source: $source
}
function dreamplugRestoreChecks ()
{
cat /proc/cmdline | grep -q root=/dev/$target
if [ $? -eq 0 ]
then
echo "you MUST NOT sync to the running system on /dev/$target, reboot using an external device"
return 1;
fi
}
function dreamplugRestoreMounts()
{
for item in ${source}1 ${source}2 ${target}1 ${target}2
do
if [ -b /dev/${item} ];
then
mkdir -p /mnt/${item} &&
echo mounting: /dev/${item} '->' /mnt/${item} &&
mount /dev/${item} /mnt/${item} ||
return 1;
else
echo "\"/dev/$item\" is not an available (block) device"
return 1;
fi
done
}
function dreamplugRestoreRsyncs()
{
{ TIMEFORMAT=$'real\t%1lR';
time { grep -q /mnt/${source}1 /etc/mtab &&
grep -q /mnt/${target}1 /etc/mtab &&
echo syncing: /mnt/${source}1 /mnt/${target}1"
rsync ${dryRun} ${verbose} --stats --one-file-system --archive --hard-links --acls --xattrs ${clearSystem} /mnt/${source}1/ /mnt/${target}1";
eval rsync ${dryRun} ${verbose} --stats --one-file-system --archive --hard-links --acls --xattrs ${clearSystem} /mnt/${source}1/ /mnt/${target}1;
echo;
} || return 1;
echo;
time { grep -q /mnt/${source}2 /etc/mtab &&
grep -q /mnt/${target}2 /etc/mtab &&
echo syncing: /mnt/${source}2/ /mnt/${target}2"
rsync ${dryRun} ${verbose} --stats --one-file-system --archive --hard-links --acls --xattrs ${clearSystem} /mnt/${source}2/ /mnt/${target}2" ;
eval rsync ${dryRun} ${verbose} --stats --one-file-system --archive --hard-links --acls --xattrs ${clearSystem} /mnt/${source}2/ /mnt/${target}2;
echo;
} || return 1;
echo;
}
}
function dreamplugRestoreUmounts()
{
cd /
for item in ${source}1 ${source}2 ${target}1 ${target}2
do
if [ -d /mnt/${item} ];
then
grep -q /mnt/${item} /etc/mtab &&
echo unmounting: /mnt/${item} &&
umount /mnt/${item}
fi
done
}
function dreamplugRestoreEvaluateOptions()
{
# evaluate options and assign
OPTIND=1
while getopts ":hs:t:dnv" arg
do
case $arg in
\? | h ) Help=TRUE; ;;
s ) source=$OPTARG;;
d ) clearSystem=TRUE;;
n ) dryRun=TRUE;;
v ) verbose=TRUE;
esac
done
shift $(($OPTIND - 1))
}
function dreamplugRestoreMain()
{
dreamplugRestoreEvaluateOptions $*
# Help?
if [ 'TRUE' = "$Help" ]; then dreamplugRestoreUsage; return 0; fi
clearSystem=${clearSystem:+--delete}
dryRun=${dryRun:+--dry-run}
verbose=${verbose:+--verbose}
echo -n -e ${clearSystem:+"NOTE: 'rsync ${clearSystem}' in use\n"}
echo -n -e ${dryRun:+"NOTE: 'rsync ${dryRun}' in use\n"}
echo -n -e ${verbose:+"NOTE: 'rsync ${verbose}' in use\n"}
target=sda;
echo target: $target
dreamplugRestoreSetSource $* &&
dreamplugRestoreChecks &&
dreamplugRestoreMounts &&
dreamplugRestoreRsyncs
dreamplugRestoreUmounts
unset source target
}
#main
dreamplugRestoreMain $*
unset main dreamplugRestoreSetSource dreamplugRestoreChecks dreamplugRestoreMounts dreamplugRestoreRsyncs dreamplugRestoreUmounts verbose dryRun clearSystem Help
| I | Attachment | Action | Size | Date | Who | Comment |
|---|---|---|---|---|---|---|
| |
dreamplugRestoreLocalSystemFromExternal.sh | manage | 4 K | 2014-10-15 - 17:15 | PeterZumbruch | restore shell script: restoring system from usb image |
Copyright © by the contributing authors. All material on this collaboration platform is the property of the contributing authors.