diff options
author | Florian Dold <florian@dold.me> | 2021-08-01 12:26:20 +0200 |
---|---|---|
committer | Florian Dold <florian@dold.me> | 2021-08-01 12:26:29 +0200 |
commit | 2032f3ce3ed0ed7a6c1c6fb9df6222d85758bf70 (patch) | |
tree | 075237a82cc24a4f36155eae82e894d76ed3074d /debian/gnunet.postinst | |
parent | f15deffc74ae9cb9ea9b32c14f55e4e125d0f4ba (diff) | |
download | gnunet-2032f3ce3ed0ed7a6c1c6fb9df6222d85758bf70.tar.gz gnunet-2032f3ce3ed0ed7a6c1c6fb9df6222d85758bf70.zip |
debian: compat level, removal of user units, tweaks
Diffstat (limited to 'debian/gnunet.postinst')
-rw-r--r-- | debian/gnunet.postinst | 178 |
1 files changed, 56 insertions, 122 deletions
diff --git a/debian/gnunet.postinst b/debian/gnunet.postinst index b6317f5be..091feb223 100644 --- a/debian/gnunet.postinst +++ b/debian/gnunet.postinst | |||
@@ -108,114 +108,63 @@ case "${1}" in | |||
108 | echo " done." | 108 | echo " done." |
109 | fi | 109 | fi |
110 | 110 | ||
111 | # Install GNUnet configuration for all users provided non exists | 111 | # # Change the proxy settings for Firefox and Chromium if desired |
112 | userlist=$(awk -F ':' '$3>=1000 && $3<2000 {print $1}' /etc/passwd) | 112 | # if ${_PROXY} |
113 | users=($userlist) | 113 | # then |
114 | homedirlist=$(awk -F ':' '$3>=1000 && $3<2000 {print $6}' /etc/passwd) | 114 | # mkdir -p /etc/X11/xinit/xinitrc.d/ |
115 | homedirs=($homedirlist) | 115 | #cat > "/etc/X11/xinit/xinitrc.d/80-gnunet-user-services" << "EOF" |
116 | 116 | ##!/bin/bash | |
117 | for (( i=0; i<${#users[@]}; i++ )); do | 117 | #systemctl --user daemon-reload |
118 | usermod -aG gnunet ${users[$i]} | 118 | #systemctl --user start gnunet-user |
119 | if [ -n "$i" ] && [ -d "${homedirs[$i]}" ]; then | 119 | #systemctl --user enable gnunet-user |
120 | mkdir -p ${homedirs[$i]}/.config/systemd/user/ | 120 | #user=$(whoami) |
121 | 121 | #gnunet_proxy=$(gnunet-config -c /etc/skel/.config/gnunet.conf -s gns-proxy | grep 'IMMEDIATE_START = YES') | |
122 | cat > "${homedirs[$i]}/.config/systemd/user/gnunet-user.service" << EOF | ||
123 | # Copyright (C) 2019 GNUnet e.V. | ||
124 | # | 122 | # |
125 | # Copying and distribution of this file, with or without modification, | 123 | ## Enable GNS proxy for new users informed by /etc/skel. |
126 | # are permitted in any medium without royalty provided the copyright | 124 | #if [ "$gnunet_proxy" ]; then |
127 | # notice and this notice are preserved. This file is offered as-is, | 125 | # |
128 | # without any warranty. | 126 | # # Calculate user specific port |
129 | 127 | # port=$((8000+$(id -u $user))) | |
130 | [Unit] | 128 | # |
131 | Description=Service that runs a GNUnet for the user gnunet | 129 | # gnunet-config -c $HOME/.config/gnunet.conf \ |
132 | After=network.target | 130 | # --section=gns-proxy \ |
133 | 131 | # --option=OPTIONS \ | |
134 | [Service] | 132 | # --value="-p $port" |
135 | Type=forking | 133 | # |
136 | ExecStart=/usr/bin/gnunet-arm -s -c ${homedirs[$i]}/.config/gnunet.conf | 134 | # # Firefox |
137 | ExecStop=/usr/bin/gnunet-arm -e -c ${homedirs[$i]}/.config/gnunet.conf | 135 | # defaultprofile=$(ls $HOME/.mozilla/firefox/*.default) |
138 | 136 | # if [ ! "$defaultprofile" ];then | |
139 | [Install] | 137 | # timeout 3s firefox --headless # dirty: create profile if not existent |
140 | WantedBy=multi-user.target | 138 | # fi |
141 | EOF | 139 | # for ffprofile in $HOME/.mozilla/firefox/*.*/; do |
142 | 140 | # js=$ffprofile/user.js | |
143 | chown "${users[$i]}":"${users[$i]}" "${homedirs[$i]}/.config/systemd/user/gnunet-user.service" | 141 | # if [ -f "$js" ]; then |
144 | if [ ! -f "${homedirs[$i]}/.config/gnunet.conf" ]; then | 142 | # sed -i '/Preferences for using the GNU Name System/d' "$js" |
145 | mkdir -p ${homedirs[$i]}/.config/ | 143 | # sed -i '/network.proxy.socks/d' "$js" |
146 | cp /etc/skel/.config/gnunet.conf "${homedirs[$i]}/.config/gnunet.conf" | 144 | # sed -i '/network.proxy.socks_port/d' "$js" |
147 | chmod 644 "${homedirs[$i]}/.config/gnunet.conf" | 145 | # sed -i '/network.proxy.socks_remote_dns/d' "$js" |
148 | fi | 146 | # sed -i '/network.proxy.type/d' "$js" |
149 | fi | 147 | # fi |
150 | port=$((8000+$(id -u "${users[$i]}"))) | 148 | # echo "// Preferences for using the GNU Name System" >> "$js" |
151 | gnunet-config -c "${homedirs[$i]}/.config/gnunet.conf" \ | 149 | # echo "user_pref(\"network.proxy.socks\", \"localhost\");" >> "$js" |
152 | --section=gns-proxy \ | 150 | # echo "user_pref(\"network.proxy.socks_port\", $port);" >> "$js" |
153 | --option=IMMEDIATE_START \ | 151 | # echo "user_pref(\"network.proxy.socks_remote_dns\", true);" >> "$js" |
154 | --value=YES | 152 | # echo "user_pref(\"network.proxy.type\", 1);" >> "$js" |
155 | gnunet-config -c "${homedirs[$i]}/.config/gnunet.conf" \ | 153 | # done |
156 | --section=gns-proxy \ | 154 | # |
157 | --option=OPTIONS \ | 155 | # # Chromium |
158 | --value="-p $port" | 156 | # profile="$HOME/.profile" |
159 | chown "${users[$i]}":"${users[$i]}" "${homedirs[$i]}/.config/gnunet.conf" | 157 | # if [ -f "$profile" ]; then |
160 | done | 158 | # sed -i '/CHROMIUM_USER_FLAGS/d' "$profile" |
161 | 159 | # fi | |
162 | # Change the proxy settings for Firefox and Chromium if desired | 160 | # echo "export CHROMIUM_USER_FLAGS=--proxy-server=socks5://localhost:$port" \ |
163 | if ${_PROXY} | 161 | # >> "$profile" |
164 | then | 162 | #fi |
165 | mkdir -p /etc/X11/xinit/xinitrc.d/ | 163 | # |
166 | cat > "/etc/X11/xinit/xinitrc.d/80-gnunet-user-services" << "EOF" | 164 | ## Create/Renew GNS certificate authority (CA) per user. |
167 | #!/bin/bash | 165 | #gnunet-gns-proxy-setup-ca |
168 | systemctl --user daemon-reload | 166 | #EOF |
169 | systemctl --user start gnunet-user | 167 | # fi |
170 | systemctl --user enable gnunet-user | ||
171 | user=$(whoami) | ||
172 | gnunet_proxy=$(gnunet-config -c /etc/skel/.config/gnunet.conf -s gns-proxy | grep 'IMMEDIATE_START = YES') | ||
173 | |||
174 | # Enable GNS proxy for new users informed by /etc/skel. | ||
175 | if [ "$gnunet_proxy" ]; then | ||
176 | |||
177 | # Calculate user specific port | ||
178 | port=$((8000+$(id -u $user))) | ||
179 | |||
180 | gnunet-config -c $HOME/.config/gnunet.conf \ | ||
181 | --section=gns-proxy \ | ||
182 | --option=OPTIONS \ | ||
183 | --value="-p $port" | ||
184 | |||
185 | # Firefox | ||
186 | defaultprofile=$(ls $HOME/.mozilla/firefox/*.default) | ||
187 | if [ ! "$defaultprofile" ];then | ||
188 | timeout 3s firefox --headless # dirty: create profile if not existent | ||
189 | fi | ||
190 | for ffprofile in $HOME/.mozilla/firefox/*.*/; do | ||
191 | js=$ffprofile/user.js | ||
192 | if [ -f "$js" ]; then | ||
193 | sed -i '/Preferences for using the GNU Name System/d' "$js" | ||
194 | sed -i '/network.proxy.socks/d' "$js" | ||
195 | sed -i '/network.proxy.socks_port/d' "$js" | ||
196 | sed -i '/network.proxy.socks_remote_dns/d' "$js" | ||
197 | sed -i '/network.proxy.type/d' "$js" | ||
198 | fi | ||
199 | echo "// Preferences for using the GNU Name System" >> "$js" | ||
200 | echo "user_pref(\"network.proxy.socks\", \"localhost\");" >> "$js" | ||
201 | echo "user_pref(\"network.proxy.socks_port\", $port);" >> "$js" | ||
202 | echo "user_pref(\"network.proxy.socks_remote_dns\", true);" >> "$js" | ||
203 | echo "user_pref(\"network.proxy.type\", 1);" >> "$js" | ||
204 | done | ||
205 | |||
206 | # Chromium | ||
207 | profile="$HOME/.profile" | ||
208 | if [ -f "$profile" ]; then | ||
209 | sed -i '/CHROMIUM_USER_FLAGS/d' "$profile" | ||
210 | fi | ||
211 | echo "export CHROMIUM_USER_FLAGS=--proxy-server=socks5://localhost:$port" \ | ||
212 | >> "$profile" | ||
213 | fi | ||
214 | |||
215 | # Create/Renew GNS certificate authority (CA) per user. | ||
216 | gnunet-gns-proxy-setup-ca | ||
217 | EOF | ||
218 | fi | ||
219 | 168 | ||
220 | # Update files and directories permissions. | 169 | # Update files and directories permissions. |
221 | # Assuming default values, this *should* not be changed. | 170 | # Assuming default values, this *should* not be changed. |
@@ -267,21 +216,6 @@ GNUNET_GROUP=${_GROUPNAME} | |||
267 | GNUNET_AUTOSTART="${_AUTOSTART}" | 216 | GNUNET_AUTOSTART="${_AUTOSTART}" |
268 | EOF | 217 | EOF |
269 | 218 | ||
270 | cat > "/etc/systemd/system/gnunet.service" <<EOF | ||
271 | [Unit] | ||
272 | Description=A framework for secure peer-to-peer networking | ||
273 | |||
274 | [Service] | ||
275 | EnvironmentFile=/etc/default/gnunet | ||
276 | User=${_USERNAME} | ||
277 | Type=forking | ||
278 | ExecStart=/usr/bin/gnunet-arm -s -c /etc/gnunet.conf | ||
279 | ExecStop=/usr/bin/gnunet-arm -e -c /etc/gnunet.conf | ||
280 | |||
281 | [Install] | ||
282 | WantedBy=multi-user.target | ||
283 | EOF | ||
284 | |||
285 | cp -f "${CONFIG_NEW}" "${CONFIG_FILE}" | 219 | cp -f "${CONFIG_NEW}" "${CONFIG_FILE}" |
286 | echo " done." | 220 | echo " done." |
287 | 221 | ||