/
upload_whonix_news_v4
executable file
·174 lines (137 loc) · 4.83 KB
/
upload_whonix_news_v4
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
#!/bin/bash
## This file is part of Whonix.
## Copyright (C) 2012 - 2014 Patrick Schleizer <adrelanos@riseup.net>
## See the file COPYING for copying conditions.
## Whonix News v4
## A deterministic tarball on
## http://sourceforge.net/projects/whonixdevelopermetafiles/files/internal/news_v4/whonix_news.tar.xz/download
## and a detached armored OpenPGP signature on
## http://sourceforge.net/projects/whonixdevelopermetafiles/files/internal/news_v4/whonix_news.tar.xz.asc/download
## Used by:
## - Whonix 7.x
## - Whonix 8.x
set -x
set -e
true "INFO: Currently running script: $BASH_SOURCE${1+"$@"}"
## disable cmd line parser, since not needed
export whonix_build_one_parsed="1"
export VMNAME="internalrun"
MYDIR="$( cd "$( dirname "${BASH_SOURCE[0]}" )" && pwd )"
cd "$MYDIR"
source ../../../help-steps/pre
source ../../../help-steps/colors
source ../../../help-steps/variables
if [ "$(id -u)" = "0" ]; then
echo "${red}${bold}ERROR: Do not run this script as root!${reset}"
exit 1
fi
[ -n "$whonix_news_gpg_sign_with_options" ] || whonix_news_gpg_sign_with_options="--sign-with 916B8D99C38EAF5E8ADC7A2A8D66066A2EEACCDA"
## Debugging.
"$WHONIX_SOURCE_HELP_STEPS_FOLDER/gpg_test_sign"
## sanity tests
required_tools="find sort tar rm mkdir basename touch sync gpg rsync sha512sum"
for tool in $required_tools; do
command -v "$tool" >/dev/null
done
unset tool
compress_news() {
find \
"." \
-print0 \
| tar \
--null \
--no-recursion \
--create \
--verbose \
--owner=0 --group=0 --numeric-owner \
--mode=go=rX,u+rw,a-s \
--sort=name \
--mtime='2015-10-21 00:00Z' \
--xz \
--file="$WHONIX_BINARY/news_v4/whonix_news.tar.xz" \
-T \
-
}
rm --force --recursive "$WHONIX_BINARY/news_v4_temp"
rm --force --recursive "$WHONIX_BINARY/news_v4"
mkdir --parents "$WHONIX_BINARY/news_v4_temp"
mkdir --parents "$WHONIX_BINARY/news_v4"
for i in "$whonix_dev_meta_files_folder/release/news/"*; do
if [ -f "$i" ]; then
## If the last character is a ~, ignore that file,
## because it was created by some editor,
## which creates backup files.
if [ "${i: -1}" = "~" ]; then
continue
fi
fi
filename="$(basename "$i")"
## --preserve to keep timestamps, to make it deterministic.
cp --preserve "$i" "$WHONIX_BINARY/news_v4_temp/$filename"
## Debugging.
#cat "$WHONIX_BINARY/news_v4_temp/$filename"
done
rm --force "$WHONIX_BINARY/news_v4_temp/.directory"
sync
## Explicitly set access time, so we end up with a deterministic archive.
shopt -s globstar
touch -t "201308151102.35" "$WHONIX_BINARY/news_v4_temp"
touch -t "201308151102.35" "$WHONIX_BINARY/news_v4_temp/"**
shopt -u globstar
## cd into temporary folder so we do not have the full path names in the archive.
cd "$WHONIX_BINARY/news_v4_temp"
compress_news
checksum_old="$(sha512sum "$WHONIX_BINARY/news_v4/whonix_news.tar.xz")"
rm --force "$WHONIX_BINARY/news_v4/whonix_news.tar.xz"
compress_news
checksum_new="$(sha512sum "$WHONIX_BINARY/news_v4/whonix_news.tar.xz")"
if [ ! "$checksum_new" = "$checksum_old" ]; then
error "Checksum mismatch. $WHONIX_BINARY/news_v4/whonix_news.tar.xz is non deterministic!"
else
true "${cyan}INFO $BASH_SOURCE: Checksum matched, ok.${reset}"
fi
sync
gpg \
$whonix_news_gpg_sign_with_options \
--set-notation "file@name"="$(basename "$WHONIX_BINARY/news_v4/whonix_news.tar.xz")" \
--detach-sign \
--armor \
--yes \
"$WHONIX_BINARY/news_v4/whonix_news.tar.xz"
sync
gpg \
--verify-options show-notations \
--verify "$WHONIX_BINARY/news_v4/whonix_news.tar.xz.asc"
ls -la "$WHONIX_BINARY/news_v4/"
true "${cyan}INFO $BASH_SOURCE: Please press enter to continue with --dry-run.${reset}"
read temp
[ -n "$whonix_news_rsync_target_lines" ] || whonix_news_rsync_target_lines='
root@whonix.org:/var/rsync/whonixdevelopermetafiles/internal/news_v4/
'
true "${cyan}INFO $BASH_SOURCE: Running with --dry-run...${reset}"
while read -r -d $'\n' rsync_target_line; do
if [ "$rsync_target_line" = "" ]; then
continue
fi
rsync \
--dry-run \
$rsync_opts \
--rsh ssh \
"$WHONIX_BINARY/news_v4/whonix_news.tar.xz.asc" \
"$WHONIX_BINARY/news_v4/whonix_news.tar.xz" \
"$rsync_target_line"
done < <( echo "$whonix_news_rsync_target_lines" )
true "${cyan}INFO $BASH_SOURCE: Please press enter to continue to upload.${reset}"
read temp
true "${cyan}INFO $BASH_SOURCE: Uploading...${reset}"
while read -r -d $'\n' rsync_target_line; do
if [ "$rsync_target_line" = "" ]; then
continue
fi
rsync \
$rsync_opts \
--rsh ssh \
"$WHONIX_BINARY/news_v4/whonix_news.tar.xz.asc" \
"$WHONIX_BINARY/news_v4/whonix_news.tar.xz" \
"$rsync_target_line"
done < <( echo "$whonix_news_rsync_target_lines" )