-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathsetup.torbrowser.profile.sh
More file actions
109 lines (82 loc) · 4.29 KB
/
setup.torbrowser.profile.sh
File metadata and controls
109 lines (82 loc) · 4.29 KB
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
#!/bin/bash
# include tools
source "./src/tools.sh" || exit 1
# default arguments
cc_script_cfg_path_default="./src/cfg.torbrowser.sh"
cc_firejail_profile_name_default="default"
cc_firejail_default="firejail"
cc_proxychains_default="proxychains -q"
# include specific tool
source "./src/tools.torbrowser.firejail.sh" || exit 1
# showhelp is auto set by tools
tool_torbrowser_firejail_show_help
# handle arguments
cc_script_cfg_path=
cc_install_dir_path=
cc_firejail_profile_name=
cc_firejail=${cc_firejail_default}
cc_proxychains=${cc_proxychains_default}
cc_firejail_profile_template_path=
# process command line arguments
argc=$#
argv=("$@")
tool_torbrowser_firejail_process_arguments ${argc} ${argv}
# start measuring time
tool_time_start
tool_variable_info cc_firejail
tool_variable_info cc_proxychains
tool_variable_info cc_firejail_profile_name
# include main torbrowser cfg script IE: ./src/cfg.torbrowser.sh
tool_variable_check_load_default cc_script_cfg_path cc_script_cfg_path_default
tool_realpath cc_script_cfg_path "parameter #1 torbrowser cfg script path"
tool_check_version_and_include_script ${cc_script_cfg_path} "loading torbrowser cfg script"
# check included "./src/cfg.torbrowser.sh" cfg variables
tool_variable_check_load_default cc_install_dir_path_default "" "torbrowser default install dir path"
tool_variable_check_load_default cc_firejail_profile_name_default "" "torbrowser default firejail profile name"
# check included firejail template profile
tool_variable_check_load_default cc_firejail_profile_template_path cc_firejail_profile_template_path_default "torbworser firejail profile template"
tool_file_if_notexist_exit ${cc_firejail_profile_template_path} "torbworser firejail profile template"
# prepare install directory path
cc_install_dir_path_default_tmp=${cc_dexsetup_dir_path}"/../"${cc_install_dir_path_default}
tool_variable_check_load_default cc_install_dir_path cc_install_dir_path_default_tmp
tool_realpath cc_install_dir_path "cc install dir path"
tool_make_and_check_dir_path cc_install_dir_path "cc install dir path"
# firejail torbrowser profile name
tool_variable_check_load_default cc_firejail_profile_name cc_firejail_profile_name_default
# firejail torbrowser run script file path
cc_torbrowser_firejail_run_script_path=${cc_install_dir_path}"/firejail.torbrowser."${cc_firejail_profile_name}".sh"
tool_realpath cc_torbrowser_firejail_run_script_path "torbrowser firejail run script"
# prepare torbrowser profile data path
cc_profile_data_path=${cc_install_dir_path}"/data/profile/"${cc_firejail_profile_name}"/"
tool_make_and_check_dir_path cc_profile_data_path "torbrowser firejail profiles data path"
# prepare torbrowser profile data bin path
cc_profile_data_path_bin=${cc_profile_data_path}"/tor-browser/"
tool_realpath cc_profile_data_path_bin "torbrowser firejail profiles data bin path"
# firejail profile path
cc_firejail_profile_path=${cc_profile_data_path}"/firejail.torbrowser.profile"
tool_realpath cc_firejail_profile_path "torbrowser firejail profile path"
# prepare bin files path
cc_bin_path=${cc_install_dir_path}"/data/download/bin"
tool_realpath cc_bin_path "binary files path"
tool_dir_if_notexist_exit cc_bin_path "binary file path"
# generate firejail torbrowser run script
script_data="#!/bin/bash
# run script generated with ./setup.torbrowser.firejail.sh --help
cd ./data/profile/${cc_firejail_profile_name}/tor-browser/ || exit 1
firejail --profile=\`pwd\`/../firejail.torbrowser.profile \\
--name=torbrowser.${cc_firejail_profile_name} \\
--whitelist=\`pwd\` \\
./start-tor-browser.desktop
"
tool_make_and_chmod_script_or_exit cc_torbrowser_firejail_run_script_path script_data "create torbrowser firejail run script"
# copy predefined firejail profile for torbrowser
tool_cp ${cc_firejail_profile_template_path} ${cc_firejail_profile_path}
# copy all data needed newly created profile
tool_cp_dir_recursive cc_bin_path cc_profile_data_path_bin "copy torbrowser bin files"
# prepare download data path to make it accessible easy by symlink
cc_download_data_path=${cc_profile_data_path_bin}"/Browser/Downloads"
tool_make_and_check_dir_path cc_download_data_path "torbrowser profile Downloads data path"
cc_download_data_ln_path=${cc_install_dir_path}"/downloads."${cc_firejail_profile_name}
ln -s ${cc_download_data_path} ${cc_download_data_ln_path}
tool_time_finish_print
exit 0