-
Notifications
You must be signed in to change notification settings - Fork 88
/
TorBOX_Workstation
2571 lines (2090 loc) · 83.9 KB
/
TorBOX_Workstation
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
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
281
282
283
284
285
286
287
288
289
290
291
292
293
294
295
296
297
298
299
300
301
302
303
304
305
306
307
308
309
310
311
312
313
314
315
316
317
318
319
320
321
322
323
324
325
326
327
328
329
330
331
332
333
334
335
336
337
338
339
340
341
342
343
344
345
346
347
348
349
350
351
352
353
354
355
356
357
358
359
360
361
362
363
364
365
366
367
368
369
370
371
372
373
374
375
376
377
378
379
380
381
382
383
384
385
386
387
388
389
390
391
392
393
394
395
396
397
398
399
400
401
402
403
404
405
406
407
408
409
410
411
412
413
414
415
416
417
418
419
420
421
422
423
424
425
426
427
428
429
430
431
432
433
434
435
436
437
438
439
440
441
442
443
444
445
446
447
448
449
450
451
452
453
454
455
456
457
458
459
460
461
462
463
464
465
466
467
468
469
470
471
472
473
474
475
476
477
478
479
480
481
482
483
484
485
486
487
488
489
490
491
492
493
494
495
496
497
498
499
500
501
502
503
504
505
506
507
508
509
510
511
512
513
514
515
516
517
518
519
520
521
522
523
524
525
526
527
528
529
530
531
532
533
534
535
536
537
538
539
540
541
542
543
544
545
546
547
548
549
550
551
552
553
554
555
556
557
558
559
560
561
562
563
564
565
566
567
568
569
570
571
572
573
574
575
576
577
578
579
580
581
582
583
584
585
586
587
588
589
590
591
592
593
594
595
596
597
598
599
600
601
602
603
604
605
606
607
608
609
610
611
612
613
614
615
616
617
618
619
620
621
622
623
624
625
626
627
628
629
630
631
632
633
634
635
636
637
638
639
640
641
642
643
644
645
646
647
648
649
650
651
652
653
654
655
656
657
658
659
660
661
662
663
664
665
666
667
668
669
670
671
672
673
674
675
676
677
678
679
680
681
682
683
684
685
686
687
688
689
690
691
692
693
694
695
696
697
698
699
700
701
702
703
704
705
706
707
708
709
710
711
712
713
714
715
716
717
718
719
720
721
722
723
724
725
726
727
728
729
730
731
732
733
734
735
736
737
738
739
740
741
742
743
744
745
746
747
748
749
750
751
752
753
754
755
756
757
758
759
760
761
762
763
764
765
766
767
768
769
770
771
772
773
774
775
776
777
778
779
780
781
782
783
784
785
786
787
788
789
790
791
792
793
794
795
796
797
798
799
800
801
802
803
804
805
806
807
808
809
810
811
812
813
814
815
816
817
818
819
820
821
822
823
824
825
826
827
828
829
830
831
832
833
834
835
836
837
838
839
840
841
842
843
844
845
846
847
848
849
850
851
852
853
854
855
856
857
858
859
860
861
862
863
864
865
866
867
868
869
870
871
872
873
874
875
876
877
878
879
880
881
882
883
884
885
886
887
888
889
890
891
892
893
894
895
896
897
898
899
900
901
902
903
904
905
906
907
908
909
910
911
912
913
914
915
916
917
918
919
920
921
922
923
924
925
926
927
928
929
930
931
932
933
934
935
936
937
938
939
940
941
942
943
944
945
946
947
948
949
950
951
952
953
954
955
956
957
958
959
960
961
962
963
964
965
966
967
968
969
970
971
972
973
974
975
976
977
978
979
980
981
982
983
984
985
986
987
988
989
990
991
992
993
994
995
996
997
998
999
1000
#!/bin/bash
# Needs to be bash because we use "trap ERR".
# Save as /home/user/TorBOX_source/TorBOX_Workstation
# Homepage: https://trac.torproject.org/projects/tor/wiki/doc/TorBOX
# Version: TorBOX 0.2.1
# Copyright: proper
#
# License: GPL v3 or any later
#
# Any changes you pull changes into this source will be also licensed
# under GPL v3 or any later. Additionally you grant proper the right to
# re-license your work under a different license. If that is not acceptable,
# you can either fork this source under GPL v3 or any later or contact proper.
# Contact proper, if you require this source code under different license.
script_help() {
echo \
"
############################################################################
# INFO #
# Automatically transform a fresh minimal Ubuntu Server 12.04 into a #
# "TorBOX-Workstation" #
# #
# Development version, please test and leave feedback! #
# Read https://trac.torproject.org/projects/tor/wiki/doc/TorBOX/DISCLAIMER #
# #
# WARNING! #
# Only run on an unmodified Ubuntu installation inside a Virtual Machine. #
# WARNING! Currently only -install is tested! #
# #
# ASSUMPTIONS #
# 1) You use Ubuntu #
# 2) The main username is "user" #
# (search for HARDCODED! and check the variable "USERNAME") #
# 3) You are using following network settings: #
# Your primary (and only) network interface is eth0 #
# TorBOX-Workstation IP: 192.168.0.2 #
# TorBOX-Gateway IP: 192.168.0.1 #
# 4) TorBOX-Workstation's build environment has a working internet #
# connection to ubuntu mirrors #
# 5) you read and understood the script and verified all hardcoded gpg #
# fingerprints tagged with !!!VERIFY!!! #
# #
# CHOOSE ONE OF THE FOLLOWING FLAGS #
# Available options: #
# -install #
# #
# -update #
# WARNING! This will overwrite all your Browser settings #
# #
# -xchat #
# Use this, if you want to unlink your previous activities on IRC with #
# XChat. The XChat configuration folder with your old identity gets #
# deleted and you can create a new pseudonym. #
# WARNING This terminates XChat and deletes your old settings! #
# #
# -hiddenserver #
# Installs and configures lighttp. Hidden service has also to be activated #
# on TorBOX-Gateway, see TorBOX-Gateway script for more information. #
# You need to put your website into /var/www. #
# #
# -uwt #
# Installs the latest uwt wrapper script and the latest uwt wrappers and #
# updates extensions.torbutton.banned_ports. #
# https://trac.torproject.org/projects/tor/wiki/doc/torsocks #
# #
# -update-torbrowser #
# Note: you can run this without root. #
# Updates only Tor Browser. #
# If you are a TorBOX user, you should only run this if you recently #
# issues -update. Otherwise, if you just want to install/update #
# TorBrowser, do not use -update. #
# #
# -uninstall #
# undo *most* of the changes made by the script #
# WARNING! Make a backup of all files and settings you want to keep #
# This will probably delete important things, you have been warned. #
############################################################################
# NOTE FOR ADVANCED USERS
# NOTE FOR DEBUGGING
# NOTE FOR CONTRIBUTORS
# Same comments as under
# https://trac.torproject.org/projects/tor/wiki/doc/TorBOX/Dev/TGScript
# apply.
# Search for TODO in the script and help us fix them.
"
}
######################################################
# List of modified system files. Not all of them are backed up/restored by -uninstall
######################################################
# Modified:
# /etc/apt/sources.list
# /etc/localtime
# /etc/fonts/conf.d/10-sub-pixel-rgb.conf
# /etc/init/tty6.conf
# /etc/sudoers
# /etc/resolv.conf
# /etc/network/interfaces
# /etc/fstab
# - /etc/fstab.old Does not get restored. Would break boot, since uuids changed.
# /var/lib/dbus/machine-id
# - /etc/fstab.old Does not get restored. Would break boot, since uuids changed.
# .gnupg/gpg.conf
# ./tor-browser_en-US/Data/profile/user.js
#
# New:
# .config/openbox/menu.xml
# /etc/torboxfirewall.sh
# /usr/share/leaktest/
# /usr/local/bin/leaktest
# /usr/local/bin/torcheck
############################################################################
# SCRIPT STARTS HERE
############################################################################
# TODO [0.3]
# Items marked with SPLITOFF are subject to be moved in their own files.
# Open for discussion.
######################################################
# Variables
######################################################
# Set the linux username.
# "export USERNAME=$(whoami)" will not work, since the
# script gets, in most cases, started as root.
USERNAME="user"
# change to home dir so relative paths work correctly
cd /home/$USERNAME
# Unattended (un)installation of packages.
# Thanks to http://snowulf.com/2008/12/04/truly-non-interactive-unattended-apt-get-install/
export DEBIAN_FRONTEND=noninteractive
error_handler() {
echo "
##################################################
# TorBOX_Workstation script: ERROR detected. #
# Do not worry. Provable nothing serious. #
# The error_handler is still a toothless tiger. #
# In long term a trap function will be #
# implemented. This simply helps devs to add the #
# necessary overriding. After that is done, this #
# text will be changed and the script will #
# really stop. #
##################################################
"
}
trap "error_handler" ERR INT TERM
root_check() {
######################################################
# Checking script environment
######################################################
# Check if we are root
if [ "$(id -u)" != "0" ]; then
echo "ERROR: This must be run as root (sudo)!"
exit 1
else
echo "INFO: Script running as root."
fi
}
set_dbusmachineid() {
echo "
######################################################
# Set generic UUIDs
######################################################
"
echo "b08dfa6083e7567a1921a715000001fb" > /var/lib/dbus/machine-id
}
create_fix_sources_list() {
# This function is required because preseed without network connection will mess up
# /etc/apt/sources.list.
echo "
# See http://help.ubuntu.com/community/UpgradeNotes for how to upgrade to
# newer versions of the distribution.
deb http://us.archive.ubuntu.com/ubuntu/ precise main restricted
deb-src http://us.archive.ubuntu.com/ubuntu/ precise main restricted
## Major bug fix updates produced after the final release of the
## distribution.
deb http://us.archive.ubuntu.com/ubuntu/ precise-updates main restricted
deb-src http://us.archive.ubuntu.com/ubuntu/ precise-updates main restricted
## N.B. software from this repository is ENTIRELY UNSUPPORTED by the Ubuntu
## team. Also, please note that software in universe WILL NOT receive any
## review or updates from the Ubuntu security team.
deb http://us.archive.ubuntu.com/ubuntu/ precise universe
deb-src http://us.archive.ubuntu.com/ubuntu/ precise universe
deb http://us.archive.ubuntu.com/ubuntu/ precise-updates universe
deb-src http://us.archive.ubuntu.com/ubuntu/ precise-updates universe
## N.B. software from this repository is ENTIRELY UNSUPPORTED by the Ubuntu
## team, and may not be under a free licence. Please satisfy yourself as to
## your rights to use the software. Also, please note that software in
## multiverse WILL NOT receive any review or updates from the Ubuntu
## security team.
deb http://us.archive.ubuntu.com/ubuntu/ precise multiverse
deb-src http://us.archive.ubuntu.com/ubuntu/ precise multiverse
deb http://us.archive.ubuntu.com/ubuntu/ precise-updates multiverse
deb-src http://us.archive.ubuntu.com/ubuntu/ precise-updates multiverse
## N.B. software from this repository may not have been tested as
## extensively as that contained in the main release, although it includes
## newer versions of some applications which may provide useful features.
## Also, please note that software in backports WILL NOT receive any review
## or updates from the Ubuntu security team.
deb http://us.archive.ubuntu.com/ubuntu/ precise-backports main restricted universe multiverse
deb-src http://us.archive.ubuntu.com/ubuntu/ precise-backports main restricted universe multiverse
deb http://security.ubuntu.com/ubuntu precise-security main restricted
deb-src http://security.ubuntu.com/ubuntu precise-security main restricted
deb http://security.ubuntu.com/ubuntu precise-security universe
deb-src http://security.ubuntu.com/ubuntu precise-security universe
deb http://security.ubuntu.com/ubuntu precise-security multiverse
deb-src http://security.ubuntu.com/ubuntu precise-security multiverse
## Uncomment the following two lines to add software from Canonical's
## 'partner' repository.
## This software is not part of Ubuntu, but is offered by Canonical and the
## respective vendors as a service to Ubuntu users.
# deb http://archive.canonical.com/ubuntu precise partner
# deb-src http://archive.canonical.com/ubuntu precise partner
## Uncomment the following two lines to add software from Ubuntu's
## 'extras' repository.
## This software is not part of Ubuntu, but is offered by third-party
## developers who want to ship their latest software.
# deb http://extras.ubuntu.com/ubuntu precise main
# deb-src http://extras.ubuntu.com/ubuntu precise main
" > /etc/apt/sources.list
}
apt_get() {
echo "
######################################################
# Updating system, removing problematic software
######################################################
"
echo "INFO: Updating system..."
apt-get update && apt-get --yes dist-upgrade
echo "INFO: Removing problematic software..."
apt-get --yes remove --purge ntpdate popularity-contest resolvconf
# build-essential is required to patch torsocks.
echo "INFO: Installing required software..."
apt-get --yes install --no-install-recommends nano wget gnupg ed torsocks mingetty build-essential dbus
}
config_grub() {
echo "
######################################################
# config_grub
######################################################
"
echo "
GRUB_TERMINAL=console
" > /etc/default/grub
update-grub2
}
base_desktop() {
echo "
######################################################
# Installing base desktop
######################################################
"
apt-get --yes install --no-install-recommends xserver-xorg xinit openbox obmenu pcmanfm evince \
libasound2 file-roller xchat gpicview gnome-mplayer tint2 unrar-free alsa alsa-utils \
mplayer leafpad gnome-terminal zenity
# no longer needed: rxvt-unicode
# We should install the following at some later point...
# - Thunderbird with TorBirdy, once no longer experimental.
# - Pidgin, once torproject.org solved the remaining issues.
# - Pidgin OTR
# - Pidgin TorChat https://github.com/prof7bit/TorChat
}
config_audio() {
echo "
######################################################
# Set up audio
######################################################
"
usermod -a -G audio $USERNAME
amixer set Master 70 unmute
amixer set PCM 70 unmute
}
torsocks_patch() {
# TODO: Do we really need to keep the source folder?
# If yes, we would have to move it tor /home/$USERNAME/.torsocks-1.2.
# But what if the script gets executed again? Than we would have to delete
# the .torsocks-1.2 folder before. That may have unexpected side effects,
# if someone was really working on the source and everything where gone.
#
# If someone wants to issue sudo make uninstall, source can be downloaded
# again.
#
# If there are no objections, lets remove this todo.
# Will break if torsocks gets updated.
# Run as root, since T-W script also runs as root.
echo "
########################
# Get torsocks source
########################
"
# Get into temp folder.
cd /tmp
# Download torsocks source code.
echo "INFO: Trying to download torsocks source code..."
sudo -u $USERNAME apt-get source torsocks
# Get into torsocks source code folder.
cd /tmp/torsocks-1.2
# Check if we could cd into the torsocks source code folder.
# cd will return 0 if it was possible to get into that directory.
if [ "$?" != "0" ]; then
# Inform about failure.
echo "ERROR: Could not cd into torsocks-1.2 folder. torsocks got probable updated and torsocks_patch() is no longer necessary."
# Restore working folder.
cd /home/$USERNAME
# Exit this function.
return
fi
echo "INFO: Successfully joint the torsocks source code folder."
echo "
########################
# ./configure torsocks
########################
"
sudo -u $USERNAME ./configure
echo "
########################
# create torsocks patch
########################
"
# SPLITOFF /home/user/TorBOX_source/torsocks_patch
# Source: https://bugs.gentoo.org/show_bug.cgi?id=395953#c7
sudo -u $USERNAME echo '--- torsocks-1.2.orig//src/torsocks.c 2011-10-25 17:49:50.000000000 -0400
+++ torsocks-1.2/src/torsocks.c 2012-02-21 11:09:20.000000000 -0500
@@ -124,9 +124,9 @@
#define LOAD_ERROR(s,l) { \
const char *error; \
error = dlerror(); \
- show_msg(l, "The symbol %s() was not found in any shared " \
- "library. The error reported was: %s!\n", s, \
- (error)?error:"not found"); \
+ if (error) \
+ show_msg(l, "The symbol %s() was not found in any shared " \
+ "library. The error reported was: %s!\n", s, error); \
dlerror(); \
}
pthread_mutex_lock(&torsocks_init_mutex);
' > /tmp/torsocks-1.2/torsocks_patch
# Tee does not like the \n and converts them to new lines which breaks the patch.
# | sudo -u $USERNAME tee
# Correcting owner.
chown $USERNAME torsocks_patch
echo "
########################
# patching torsocks
########################
"
sudo -u $USERNAME patch -p1 < torsocks_patch
echo "
########################
# make torsocks
########################
"
sudo -u user make
echo "
########################
# make install torsocks
########################
"
# Install as root.
make install
# Leave that folder.
cd /home/$USERNAME
# Temporary files will be delted by the slim_down function.
}
install_uwt() {
echo "
######################################################
# Installing uwt...
######################################################
"
# Using this until the feature to add ip/port through command line
# reaches upstream torsocks, if ever. Source:
# https://trac.torproject.org/projects/tor/wiki/doc/torsocks
# If you make changes to uwt, please also add them "upstream"
# (link above).
# UPDATE 9
# SPLITOFF /home/user/TorBOX_source/TorBOX_Workstation/usr/local/bin/uwt
echo '
#! /bin/sh
# ***************************************************************************
# * *
# * Copyright (C) 2008-2011 Robert Hogan <[email protected]> *
# * *
# * This program is free software; you can redistribute it and/or modify *
# * it under the terms of the GNU General Public License as published by *
# * the Free Software Foundation; either version 2 of the License, or *
# * (at your option) any later version. *
# * *
# * This program is distributed in the hope that it will be useful, *
# * but WITHOUT ANY WARRANTY; without even the implied warranty of *
# * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the *
# * GNU General Public License for more details. *
# * *
# * You should have received a copy of the GNU General Public License *
# * along with this program; if not, write to the *
# * Free Software Foundation, Inc., *
#* 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA. *
# ***************************************************************************
# * *
# * This is a modified version of a source file from the Tor project. *
# * Original copyright notice from tsocks source file follows: *
# ***************************************************************************
# Wrapper script for use of the tsocks(8) transparent socksification library
# See the tsocks(1) and torify(1) manpages.
# Copyright (c) 2004, 2006 Peter Palfrader
# Modified by Jacob Appelbaum <[email protected]> April 16th 2006
# Modified by Marcus Griep <[email protected]> June 16 2009
# May be distributed under the same terms as Tor itself
# Note:
# -v (verbose) and the UWT_VERBOSE environment variable set to 1
# will break many graphical applications, which use applications,
# which will call applications, which we wrapped to use uwt.
# You can also type in shell:
# export UWT_VERBOSE="1"
# to enable verbose output.
# Note: When running applications as root, you also have to set and
# export that variable as root.
# Define and ensure we have tsocks
# XXX: what if we do not have which?
TORSOCKS="`which torsocks`"
PROG=
VERBOSE=
usage () {
echo "Usage: $0 [-h] [-v] [ <command> [<options>...]"
}
set_id () {
echo "ERROR: $1 is set${2}id. usewithtor will not work on a set${2}id executable." >&2
exit 1
}
# Check for any argument list
if [ "$#" = 0 ]; then
usage >&2
exit 1
fi
while [ "$1" ]; do
case "$1" in
-h|--h*)
usage
exit 0
;;
-v|--v*)
VERBOSE=YesPlease
shift
;;
*)
break;
esac
done
if [ -u `which "$1"` ]; then
set_id $1 u
elif [ -g `which "$1"` ]; then
set_id $1 g
fi
if [ -x "$TORSOCKS" ]; then
PROG=torsocks
else
echo "$0: Unable to find torsocks in PATH." >&2
echo " Perhaps you have not installed it?" >&2
exit 1
fi
if [ "$VERBOSE" ]; then
echo "We are armed with the following torsocks: $TORSOCKS"
echo "We are attempting to use $PROG for all tor action."
fi
if [ "$PROG" = "torsocks" ]; then
# Define our torsocks config file.
# In ~ to avoid permission conflicts with root.
# TODO: find a more elegant solutoin and revert back to sh script.
TORSOCKS_CONF_FILE=~
TORSOCKS_CONF_FILE="$TORSOCKS_CONF_FILE/.torsocks_temp"
export TORSOCKS_CONF_FILE
#echo "TORSOCKS_CONF_FILE: $TORSOCKS_CONF_FILE"
echo "
# Temporary torsocks configuration file created by uwt.
# Safe to delete.
local = 127.0.0.0/255.128.0.0
local = 127.128.0.0/255.192.0.0
local = 169.254.0.0/255.255.0.0
local = 172.16.0.0/255.240.0.0
local = 192.168.0.0/255.255.0.0
server = $ip
server_type = 5
server_port = $port
" > $TORSOCKS_CONF_FILE
# Check that we have got a torsocks config file
if [ -r "$TORSOCKS_CONF_FILE" ]; then
# echo "1 UWT_VERBOSE: $UWT_VERBOSE"
if [ -z $UWT_VERBOSE ]; then
# echo "UWT_VERBOSE: did not exist."
UWT_VERBOSE=0
else
if [ $UWT_VERBOSE -eq "1" ]; then
VERBOSE=YesPlease
fi
fi
# echo "2 UWT_VERBOSE: $UWT_VERBOSE"
if [ $VERBOSE ]; then
echo "uwt"
echo "ip: $ip port: $port"
fi
UWT_LOCALHOST="0"
case "$*" in
*127.0.0.1*)
UWT_LOCALHOST="1"
;;
*localhost*)
UWT_LOCALHOST="1"
;;
*)
# do nothing
sleep 0
;;
esac
if [ "$UWT_LOCALHOST" = "1" ]; then
if [ $VERBOSE ]; then
echo "UWT_LOCALHOST: $UWT_LOCALHOST NOT using torsocks."
echo "exec torsocks \"$@\""
fi
exec "$@"
else
if [ $VERBOSE ]; then
echo "UWT_LOCALHOST: $UWT_LOCALHOST USING torsocks."
echo "exec torsocks \"$@\""
fi
exec torsocks "$@"
fi
else
# Since identity corelation through circuit sharing is at risk,
# we should no longer let torsocks default to 9050.
echo "$0: Missing torsocks configuration file \"$TORSOCKS_CONF_FILE\."
exit 1
fi
fi
# We should have hit an exec. If we get here, we did not exec
echo "$0: failed to exec $PROG $@" >&2
exit 1
# End of uwt script.
' > /usr/local/bin/uwt
}
install_uwt_wrappers() {
######################################################
# Installing uwt wrappers
######################################################
# SPLITOFF? /home/user/TorBOX_source/TorBOX_Workstation/usr/local/bin/apt-get etc.
# SOCKS_PORT_TB="9100"
# - gui application with socks proxy settings
# - no wrapper required
# SOCKS_PORT_IRC="9101"
# - gui application with socks proxy settings
# - no wrapper required
# SOCKS_PORT_TORBIRDY="9102"
# - gui application with socks proxy settings
# - no wrapper required
# - not yet installed
# SOCKS_PORT_IM="9103"
# - gui application with socks proxy settings
# - no wrapper required
# SOCKS_PORT_APT_GET="9104"
echo '
#!/bin/bash
ip=192.168.0.1 port=9104 uwt /usr/bin/apt-get $*
' > /usr/local/bin/apt-get
# SOCKS_PORT_GPG="9105"
echo '
#!/bin/bash
ip=192.168.0.1 port=9105 uwt /usr/bin/gpg $*
' > /usr/local/bin/gpg
# SOCKS_PORT_SSH="9106"
echo '
#!/bin/bash
ip=192.168.0.1 port=9106 uwt /usr/bin/ssh $*
' > /usr/local/bin/ssh
# SOCKS_PORT_GIT="9107"
echo '
#!/bin/bash
ip=192.168.0.1 port=9107 uwt /usr/bin/git $*
' > /usr/local/bin/git
# SOCKS_PORT_HTPDATE="9108"
echo '
#!/bin/bash
ip=192.168.0.1 port=9108 uwt /usr/bin/htpdate $*
' > /usr/local/bin/htpdate
## SOCKS_PORT_WGET="9109"
#echo '
##!/bin/bash
#ip=192.168.0.1 port=9109 uwt /usr/bin/wget $*
#' > /usr/local/bin/wget
# SOCKS_PORT_TORCHECK="9110"
# - pointing uwt directly to this port
# - no wrapper required
# SOCKS_PORT_BITCOIN="9111"
# - gui application with socks proxy settings
# - not installed
# - no wrapper required
# SOCKS_PORT_PRIVOXY="9112"
# - not installed
# - no wrapper required
# SOCKS_PORT_POLIPO="9113"
# - not installed
# - no wrapper required
# More wrappers...
# should be safe
chmod +x /usr/local/bin/*
}
config_etc() {
echo "
######################################################
# /etc configs
######################################################
"
# in case we forgot to set the time during installation
cp /usr/share/zoneinfo/UTC /etc/localtime
# enable sub pixel rendering
cp -n /etc/fonts/conf.avail/10-sub-pixel-rgb.conf /etc/fonts/conf.d/
# Auto-login on tty6
cp -n /etc/init/tty6.conf /etc/init/tty6.conf.backup
# HARDCODED!
ed -s /etc/init/tty6.conf <<< $',s/exec \/sbin\/getty -8 38400 tty6/exec \/sbin\/mingetty --autologin user --noclear tty6/g\nw'
# Allow user to reboot and poweroff without having to supply a password.
# Privilege escalation through backup file should not be possible because owned by root.
# REVIEW: Is this OK? Race condition, syntax error detection do not apply here and we set correct permission just to make sure.
cp -n /etc/sudoers /etc/sudoers.backup
chmod 0440 /etc/sudoers.backup
chown root /etc/sudoers.backup
echo "
$USERNAME $HOSTNAME=NOPASSWD: /sbin/shutdown -h now,/sbin/reboot,/sbin/poweroff
" >> /etc/sudoers
chmod 0440 /etc/sudoers
}
config_home() {
echo "
######################################################
# General ~/ configs
######################################################
"
# Create a backup of filed modified by config_home().
sudo -u $USERNAME cp -n .bashrc .bashrc.backup
sudo -u $USERNAME cp -n .gtkrc-2.0 .gtkrc-2.0.backup
sudo -u $USERNAME cp -n .profile .profile.backup
sudo -u $USERNAME cp -n .gnupg/gpg.conf .gnupg/gpg.conf.backup
# Modify .bashrc to allow reboot and poweroff without sudo.
echo '
alias reboot="sudo reboot"
alias poweroff="sudo poweroff"
' | sudo -u $USERNAME tee -a .bashrc
# Set up icons for gtk2 (and theme, but I have not found a better theme yet that works both for gtk2 and 3)
# (Humanity gets installed with evince)
echo 'gtk-icon-theme-name="Humanity"' | sudo -u $USERNAME tee .gtkrc-2.0
# TODO
# Gtk3 - you probably need gnome-themes-standard
# Uncommented till we decide on a theme that works across gtk2 and gtk3 apps.
#sudo -u $USERNAME mkdir -p .config/gtk-3.0
#echo "
#[Settings]
#gtk-theme-name=Adwaita
#gtk-icon-theme-name=nuoveXT2
#"| sudo -u $USERNAME tee .config/gtk-3.0/settings.ini
# auto-start X, we do not need a display manager
echo '
# if logging into tty6 (which will autologin), run startx
if [ -z "$DISPLAY" ] && [ $(tty) = /dev/tty6 ] ; then
startx ;
fi
' | sudo -u $USERNAME tee -a .profile
# Fixing black on black for gnome-terminal.
# Not working: gconftool-2 --set "/apps/gnome-terminal/profiles/Default/use_theme_colors" --type bool false
# Thanks to: http://ubuntuforums.org/showthread.php?t=1513791
sudo -u $USERNAME gconftool-2 --type string --set /apps/gnome-terminal/profiles/Default/foreground_color "#FFFFFFFFFFFF"
# Run gpg at least once to create the GPG default files
# gpg.conf, pubring.gpg and trustdb.gpg.
# The --fingerprint option will do nothing and has been
# added to let GPG terminate itself after creating the
# configuration files. GPG run with no options would
# result in GPG running interactively.
sudo -u $USERNAME gpg --fingerprint --homedir /home/"$USERNAME"/.gnupg
# Stop GPG from adding the version information.
# Some further suggestions added from Debian.
# http://keyring.debian.org/creating-key.html
# TODO: needs review
sudo -u $USERNAME echo "
# TorBOX /home/user/.gnupg/gpg.conf changes.
# suggestions from TorBirdy extensions.enigmail.agentAdditionalParam
##################################################################
no-emit-version
no-comments
throw-keyids
display-charset utf-8
#no proxy because of uwt wrapper
#keyserver-options http-proxy=http://127.0.0.1:8118
keyserver hkp://2eghzlv2wwcq7u7y.onion
##################################################################
personal-digest-preferences SHA512
cert-digest-algo SHA512
default-preference-list SHA512 SHA384 SHA256 SHA224 AES256 AES192 AES CAST5 ZLIB BZIP2 ZIP Uncompressed
# End of TorBOX /home/user/.gnupg/gpg.conf changes.
" >> /home/"$USERNAME"/.gnupg/gpg.conf
}
config_openbox() {
echo "
######################################################
# OPENBOX+TINT2
######################################################
"
# prepare dirs
sudo -u $USERNAME mkdir -p .config/openbox
sudo -u $USERNAME mkdir .config/tint2
# copy default files to home. Tint2 example file is Ubuntu specific
sudo -u $USERNAME cp /usr/share/doc/tint2/examples/icon_and_text_1.tint2rc /home/$USERNAME/.config/tint2/tint2rc
sudo -u $USERNAME cp /etc/xdg/openbox/rc.xml .config/openbox/
# Autostart for GUI applications
echo "
tint2 &
torcheck &
exec openbox-session
" | sudo -u $USERNAME tee .xinitrc
# Fix ugly corners in tint2rc
sudo -u $USERNAME ed -s .config/tint2/tint2rc <<< $',s/rounded = 7/rounded = 0/g\nw'
# maximize TorBrowser windows
( echo '/<applications>/a'; echo '<application class="Tor*" role="browser"> <maximized>yes</maximized> </application>'; echo '.'; echo 'wq') | sudo -u $USERNAME ed -s .config/openbox/rc.xml
# Win+Space shows Openbox menu.
( echo '/<keyboard>/a'; echo '<keybind key="W-space"><action name="ShowMenu"><menu>root-menu</menu></action></keybind>'; echo '.'; echo 'wq') | sudo -u $USERNAME ed -s .config/openbox/rc.xml
# Configure the openbox right click menu.
# Note: echo may not insert a newline at the beginning,
# otherwise Openbox will complain about a phrasing error.
# How to create/modify this file:
# Actually very easy. Simply use obmenu from the Openbox
# right click menu. Make changes and paste here. There is
# no need to manually edit it.
# SPLITOFF /home/user/TorBOX_source/TorBOX_Workstation/home/user/.config/openbox/menu.xml
echo '<?xml version="1.0" encoding="utf-8"?>
<openbox_menu xmlns="http://openbox.org/" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xsi:schemaLocation="http://openbox.org/ file:///usr/share/openbox/menu.xsd">
<menu id="root-menu" label="Openbox 3">
<item label="Terminal">
<action name="Execute">
<execute>
x-terminal-emulator
</execute>
</action>
</item>
<item label="TorBrowser">
<action name="Execute">
<execute>
# HARDCODED!
/home/user/tor-browser_en-US/start-tor-browser
</execute>
</action>
</item>
<menu id="root-menu-25943" label="TorBOX">
<item label="Check your IP (takes few seconds)">
<action name="Execute">
<execute>torcheck</execute>
</action>
</item>
<item label="Tor Browser Update Check (takes few seconds)">
<action name="Execute">
<execute>torcheck</execute>
</action>
</item>
</menu>
<item label="File Manager">
<action name="Execute">
<execute>
pcmanfm
</execute>
</action>
</item>
<menu id="root-menu-1" label="Applications">
<item label="Archive Manager">
<action name="Execute">
<execute>
file-roller
</execute>
</action>
</item>
<item label="IRC Client">
<action name="Execute">
<execute>
xchat
</execute>
</action>
</item>
<item label="Media Player">
<action name="Execute">
<execute>
gnome-mplayer
</execute>
</action>
</item>
<item label="PDF Viewer">
<action name="Execute">
<execute>
evince
</execute>
</action>
</item>
<item label="Text Editor">
<action name="Execute">
<execute>
leafpad
</execute>
</action>
</item>
</menu>
<separator/>
<menu id="client-list-menu"/>
<separator/>
<item label="obmenu">
<action name="Execute">
<execute>
obmenu
</execute>
</action>
</item>
<item label="Reconfigure">
<action name="Reconfigure"/>
</item>
<item label="Restart">
<action name="Restart"/>
</item>
<separator/>
<item label="Exit">
<action name="Exit"/>
</item>
<item label="Shut down">
<action name="Execute">
<execute>
sudo /sbin/poweroff
</execute>
</action>
</item>
</menu>
</openbox_menu>
' | sudo -u $USERNAME tee .config/openbox/menu.xml
}
config_pcmanfm() {
echo "
######################################################
# PCMANFM
######################################################
"
sudo -u $USERNAME mkdir -p .config/libfm/
# SPLITOFF /home/user/TorBOX_source/TorBOX_Workstation/home/user/.config/libfm/libfm.conf
echo '
[config]