Commit Diff
Diff:
55c8f6917ae46dd1e14d5d991995a5fc0a372668
4ea91ad1abddd4143fe7ff794b10d03c306d974d
Commit:
4ea91ad1abddd4143fe7ff794b10d03c306d974d
Tree:
78b6d5376bccf9a696d4a152ff7266322e0d4b37
Author:
Fred. Galusik <f@galusik.xyz>
Committer:
Fred. Galusik <f@galusik.xyz>
Date:
Wed May 6 20:16:28 2015 UTC
Message:
add logs and cli parser
blob - bdf610ec21f6821ade3b4d88ffb9e5be0a50908d
blob + 457ff838b4ebf717befaaf78714f50f39e0523db
--- snaps
+++ snaps
@@ -54,18 +54,46 @@ SIGNPUB=/etc/signify/openbsd-$RL-base.pub
GET='ftp -m -C'
REBOOT='/sbin/reboot'
+LOGF=/var/log/snaps.log
+NOW='date \"+ %Y-%m-%d %R\"'
+
###
###
###
+function usage {
+ echo "snaps - Download, check and install bsd.rd from snapshot"
+ echo "Usage: snaps [-g|-G|-l|-h]"
+ echo " -g Just Download and check bsd.rd from snapshot"
+ echo " -G Download, check and install bsd.rd"
+ echo " -l Show the 3 last times you have upgraded your OS to snapshot"
+ echo " -h Print this message and exit."
+ exit
+}
+
+
function power {
if [[ $(id -u) != "0" ]];then
- echo "This script must be run as root" 1>&2
+ echo "You need to be root to do this." 1>&2
exit 1
fi
}
+function log {
+ echo "$NOW FROM $URL" >> $LOGF
+}
+
+
+function getlog {
+ if [[ -f $LOGF ]];then
+ tail -n 3 $LOGF
+ else
+ echo "No $LOGF file. Seems you have not yet played with snaps."
+ exit
+ fi
+}
+
function get_rd {
echo "\n=== FETCHING FILES ==="
set -A fich $BSDRD $SHAF $SIGF
@@ -145,8 +173,23 @@ function move {
##
## Run
##
-
-power
-get_rd
-check
-move
+case $1 in
+ -g)
+ get_rd
+ check
+ ;;
+ -G)
+ power
+ log
+ get_rd
+ check
+ move
+ ;;
+ -l)
+ getlog
+ ;;
+ -h|*)
+ usage
+ exit 1
+ ;;
+esac
Frédéric Galusik