adding script
parent
cff6797c5b
commit
65a68fcba0
|
@ -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
|
Loading…
Reference in New Issue