Gentoo Archives: gentoo-commits

From: "Robin H. Johnson" <robbat2@g.o>
To: gentoo-commits@l.g.o
Subject: [gentoo-commits] proj/elections:master commit in: /
Date: Fri, 01 Jul 2022 19:13:02
Message-Id: 1656702766.6fb33c7d84a6e9fefe03ec6b0af77a01eaf1d421.robbat2@gentoo
1 commit: 6fb33c7d84a6e9fefe03ec6b0af77a01eaf1d421
2 Author: Robin H. Johnson <robbat2 <AT> gentoo <DOT> org>
3 AuthorDate: Fri Jul 1 19:12:46 2022 +0000
4 Commit: Robin H. Johnson <robbat2 <AT> gentoo <DOT> org>
5 CommitDate: Fri Jul 1 19:12:46 2022 +0000
6 URL: https://gitweb.gentoo.org/proj/elections.git/commit/?id=6fb33c7d
7
8 infra-schedule-countify-collect: new tool to schedule countify --collect
9
10 Signed-off-by: Robin H. Johnson <robbat2 <AT> gentoo.org>
11
12 README.md | 20 +++++++++++++++++--
13 infra-schedule-countify-collect | 44 +++++++++++++++++++++++++++++++++++++++++
14 2 files changed, 62 insertions(+), 2 deletions(-)
15
16 diff --git a/README.md b/README.md
17 index a59ed18..1afdba0 100644
18 --- a/README.md
19 +++ b/README.md
20 @@ -85,8 +85,24 @@ Trustees.
21 Just wait. `election-stats-count` runs every 30 minutes by cronjob, and prints
22 status files into the home directories of election officials: `voter-turnout-${election_name}`.
23
24 -4. Close of election:
25 ----------------------
26 +4.a. Automated "Close of election"
27 +----------------------------------
28 +Before the end of the election, run the script to schedule automated
29 +`countify --collect`:
30 +```
31 +$ sudo su
32 +# cd /etc/elections
33 +# ./infra-schedule-countify-collect ${election_name}
34 +````
35 +
36 +The job can be verified with:
37 +```
38 +# atq
39 +# at -c $JOB_ID
40 +```
41 +
42 +4.b. Manual "Close of election"
43 +-------------------------------
44 This is the only step where the infra contact is absolutely required.
45 The infra contact must run `countify --collect ${election_name}` as root,
46 which will write the master ballot & confirmation stub file to all officials:
47
48 diff --git a/infra-schedule-countify-collect b/infra-schedule-countify-collect
49 new file mode 100755
50 index 0000000..f44f343
51 --- /dev/null
52 +++ b/infra-schedule-countify-collect
53 @@ -0,0 +1,44 @@
54 +#!/bin/bash
55 +# This will schedule an at(1) job to run for countify --collect
56 +# Any special ballots must be in place before the end of the election.
57 +# Infra needs to run this script, and it will schedule the rest, so infra does
58 +# NOT need to be on hand at the end closing time.
59 +election_name=$1
60 +
61 +UID=$(id -u)
62 +if test $UID -ne 0; then
63 + echo "You must be root to run this" 1>&2
64 + exit 1
65 +fi
66 +
67 +# Find the dir, validate
68 +for d in /etc/elections/$election_name ./$election_name ; do
69 + files=( start stop voters ballot officials )
70 + good=1
71 + for f in ${files[@]}; do
72 + test -e $d/${f}-$election_name || good=0
73 + done
74 + if test $good -eq 1 ; then
75 + export election_dir=$d
76 + break
77 + fi
78 + unset good
79 +done
80 +
81 +if test -z "$election_dir" ; then
82 + echo "Could not find election $election_name in /etc/elections" 1>&2
83 + exit 1
84 +fi
85 +
86 +stopfile=$election_dir/stop-$election_name
87 +t=$(date -u +%Y%m%d%H%M.%S -d @$(<$stopfile) )
88 +
89 +cd /etc/elections
90 +unset MAIL PWD SSH_CLIENT SSH_CONNECTION SSH_TTY
91 +
92 +at -t $t <<-EOF
93 +#!/bin/sh
94 +# This was scheduled by $SUDO_USER at $(date -uR)
95 +cd /etc/elections
96 +./countify --collect ${election_name}
97 +EOF