Skip to content
Snippets Groups Projects
Commit 2c6c2efe authored by Michal 'vorner' Vaner's avatar Michal 'vorner' Vaner
Browse files

Script to store certificates into separate partition

parent 108bd430
No related branches found
No related tags found
No related merge requests found
cert-backup
===========
A script that stores the given certificate onto a backup partition for the case
of full restart (eg. data wipe).
Call with list of files to store or remove. Each file to remove must be
preceded by -r.
For example, to add files /etc/a and /etc/b and remove /etc/c and /etc/d, you'd
call it as:
./cert-backup /etc/a /etc/b -r /etc/c -r /etc/d
#!/bin/sh
set -ex
PARTITION=/dev/mtdblock4
WORKDIR=/tmp/certstore
mkdir -p "$WORKDIR"
test -z "$(ls -A "$WORKDIR")"
mount -t jffs2 "$PARTITION" "$WORKDIR"
while [ "$1" ] ; do
if [ "$1" = '-r' ] ; then
# It should be removed, if it exists
shift
rm -f "$WORKDIR"/"$1"
elif cmp -s "$1" "$WORKDIR"/"$1" ; then
echo "$1" already stored, skipping
else
# It differs (or the backup doesn't exist) -> replace
mkdir -p "$WORKDIR"/"$(dirname "$1")"
cp -a "$1" "$WORKDIR"/"$1"
fi
shift
done
umount "$WORKDIR"
rm -r "$WORKDIR"
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment