#!/bin/sh # # ADD AN EVENT. # # Takes three arguments. Month Day Year. # If you don't have all three, it tells you to go away. # If one of them is a zero, it tells you to go away. # If the year is too small, it tells you to go away. # If the month is wrong, it tells you to go away. # It's very unfriendly. if [ -z "$1" ] then echo "[!] Format is $0 MONTH DAY YEAR." exit 1 fi if [ -z "$2" ] then echo "[!] Format is $0 MONTH DAY YEAR." exit 1 fi if [ -z "$3" ] then echo "[!] Format is $0 MONTH DAY YEAR." exit 1 fi if [ "$2" -lt 10 ] then DAY="0$2" else DAY=$2 fi if [ "$1" -lt 10 ] then MO="0$1" else MO=$1 fi if [ ! -d "$3" ] then echo "[!] First time we have an event in $3!" mkdir $3 fi if [ ! -d "$3/$MO" ] then echo "[!] First time we have an event in $MO/$3!" mkdir $3/$MO fi if [ ! -d "$3/$MO/$DAY" ] then echo "[!] First time we have an event in $MO/$DAY/$3!" mkdir $3/$MO/$DAY fi MONTH=`grep "^$MO " tables/months | cut -f2 -d" "` if [ "$2" -eq "0" ] then if [ "$1" -eq "0" ] then echo "[!] This event will be listed as being during $3." else echo "[!] This event will be listed as being during $MONTH $3." fi else echo "[!] This event will be listed as being during $MONTH $DAY, $3." fi echo " Enter the Text from the event." echo "" read ORANGEJUICE # Now, find the amount of things in that directory, and add one. COUNT="`ls $3/$MO/$DAY | wc -l `" COUNT=$(($COUNT + 1)) mkdir $3/$MO/$DAY/$COUNT echo "$ORANGEJUICE" >> $3/$MO/$DAY/$COUNT/NAME echo "" echo "$MONTH $DAY, $3: $ORANGEJUICE" echo "" echo "If there's a source for this, paste the URL here:" read SOURCE if [ "$SOURCE" ] then echo "$SOURCE" >$3/$MO/$DAY/$COUNT/SOURCE fi