From 65a68fcba0461bea0633be720020297b8469ba22 Mon Sep 17 00:00:00 2001 From: Comrade Ubergeek Date: Sun, 21 Apr 2019 05:53:51 +0200 Subject: [PATCH] adding script --- ballot | 56 ++++++++++++++++++++++++++++++++++++++++++++++++++++++++ 1 file changed, 56 insertions(+) create mode 100755 ballot diff --git a/ballot b/ballot new file mode 100755 index 0000000..b621c63 --- /dev/null +++ b/ballot @@ -0,0 +1,56 @@ +#!/bin/bash + +BALLOT_LOCATION=/tmp/ballots/ +CLOSED_BALLOTS=/tmp/close_ballots/ + +[ -d $BALLOT_LOCATION ] || mkdir $BALLOT_LOCATION + +[ -d $CLOSED_BALLOTS ] || mkdir $CLOSED_BALLOTS + +ACTION=$1 + +case $ACTION in + "create") + echo "What is being voted on? (Keep short, and concise):" + read line + mkdir -p $BALLOT_LOCATION/$line + echo "Ballot $line created. You and others can now vote on it." + exit 0 + ;; + "cast") + echo "What are you wanting for vote on?" + read ballot + echo "What is your ballot?" + read vote + echo "You are going to vote: $vote for the ballot question: $ballot." + touch $BALLOT_LOCATION/$ballot/`whoami`.$vote + exit 0 + ;; + "count") + echo "What ballot to count?" + read ballot + ls $BALLOT_LOCATION/$ballot/* | sort | awk -F"." '{print $2}' | uniq -c + echo "Total members: `members comrade | wc -w`" + exit 0 + ;; + "close") + echo "What ballot to close?" + read ballot + mv $BALLOT_LOCATION/$ballot /tmp/close_ballots/$ballot + echo "$ballot closed." + exit 0 + ;; + "show") + if [ `ls $BALLOT_LOCATION | wc -l` -ne 0 ]; then + echo "Open ballots:" + for i in `ls $BALLOT_LOCATION`; do echo $i; done + else + echo "No open ballots at this time." + fi + exit 0 + ;; + *) + echo "$0 {create|cast|count|close|show}" + exit 0 + ;; +esac