... |
... |
@@ -9,9 +9,9 @@ complain_dialog_title="[% c('var/Project_Name') %]" |
9
|
9
|
|
10
|
10
|
# Make sure this script wasn't started as 'sh start-[% c('var/project-name') %]' or similar.
|
11
|
11
|
if [ "x$BASH" = "x" ]; then
|
12
|
|
- echo "$complain_dialog_title should be started as './start-[% c('var/project-name') %]'"
|
13
|
|
- echo "Exiting." >&2
|
14
|
|
- exit 1;
|
|
12
|
+ echo "$complain_dialog_title should be started as './start-[% c('var/project-name') %]'"
|
|
13
|
+ echo "Exiting." >&2
|
|
14
|
+ exit 1;
|
15
|
15
|
fi
|
16
|
16
|
|
17
|
17
|
# Do not (try to) connect to the session manager
|
... |
... |
@@ -21,84 +21,86 @@ unset SESSION_MANAGER |
21
|
21
|
# Usage: complain message
|
22
|
22
|
# message must not begin with a dash.
|
23
|
23
|
complain () {
|
24
|
|
- # Trim leading newlines, to avoid breaking formatting in some dialogs.
|
25
|
|
- complain_message="`echo "$1" | sed '/./,$!d'`"
|
26
|
|
-
|
27
|
|
- # If we're being run in debug/verbose mode, complain to stderr.
|
28
|
|
- if [ "$show_output" -eq 1 ]; then
|
29
|
|
- echo "$complain_message" >&2
|
30
|
|
- return
|
31
|
|
- fi
|
32
|
|
-
|
33
|
|
- # Otherwise, we're being run by a GUI program of some sort;
|
34
|
|
- # try to pop up a message in the GUI in the nicest way
|
35
|
|
- # possible.
|
36
|
|
- #
|
37
|
|
- # In mksh, non-existent commands return 127; I'll assume all
|
38
|
|
- # other shells set the same exit code if they can't run a
|
39
|
|
- # command. (xmessage returns 1 if the user clicks the WM
|
40
|
|
- # close button, so we do need to look at the exact exit code,
|
41
|
|
- # not just assume the command failed to display a message if
|
42
|
|
- # it returns non-zero.)
|
43
|
|
-
|
44
|
|
- # First, try zenity.
|
45
|
|
- zenity --error \
|
46
|
|
- --title="$complain_dialog_title" \
|
47
|
|
- --text="$complain_message"
|
48
|
|
- if [ "$?" -ne 127 ]; then
|
49
|
|
- return
|
50
|
|
- fi
|
51
|
|
-
|
52
|
|
- # Try kdialog.
|
53
|
|
- kdialog --title "$complain_dialog_title" \
|
54
|
|
- --error "$complain_message"
|
55
|
|
- if [ "$?" -ne 127 ]; then
|
56
|
|
- return
|
57
|
|
- fi
|
58
|
|
-
|
59
|
|
- # Try xmessage.
|
60
|
|
- xmessage -title "$complain_dialog_title" \
|
61
|
|
- -center \
|
62
|
|
- -buttons OK \
|
63
|
|
- -default OK \
|
64
|
|
- -xrm '*message.scrollVertical: Never' \
|
65
|
|
- "$complain_message"
|
66
|
|
- if [ "$?" -ne 127 ]; then
|
67
|
|
- return
|
68
|
|
- fi
|
69
|
|
-
|
70
|
|
- # Try gxmessage. This one isn't installed by default on
|
71
|
|
- # Debian with the default GNOME installation, so it seems to
|
72
|
|
- # be the least likely program to have available, but it might
|
73
|
|
- # be used by one of the 'lightweight' Gtk-based desktop
|
74
|
|
- # environments.
|
75
|
|
- gxmessage -title "$complain_dialog_title" \
|
76
|
|
- -center \
|
77
|
|
- -buttons GTK_STOCK_OK \
|
78
|
|
- -default OK \
|
79
|
|
- "$complain_message"
|
80
|
|
- if [ "$?" -ne 127 ]; then
|
81
|
|
- return
|
82
|
|
- fi
|
|
24
|
+ # Trim leading newlines, to avoid breaking formatting in some dialogs.
|
|
25
|
+ complain_message="`echo "$1" | sed '/./,$!d'`"
|
|
26
|
+
|
|
27
|
+ # If we're being run in debug/verbose mode, complain to stderr.
|
|
28
|
+ if [ "$show_output" -eq 1 ]; then
|
|
29
|
+ echo "$complain_message" >&2
|
|
30
|
+ return
|
|
31
|
+ fi
|
|
32
|
+
|
|
33
|
+ # Otherwise, we're being run by a GUI program of some sort;
|
|
34
|
+ # try to pop up a message in the GUI in the nicest way
|
|
35
|
+ # possible.
|
|
36
|
+ #
|
|
37
|
+ # In mksh, non-existent commands return 127; I'll assume all
|
|
38
|
+ # other shells set the same exit code if they can't run a
|
|
39
|
+ # command. (xmessage returns 1 if the user clicks the WM
|
|
40
|
+ # close button, so we do need to look at the exact exit code,
|
|
41
|
+ # not just assume the command failed to display a message if
|
|
42
|
+ # it returns non-zero.)
|
|
43
|
+
|
|
44
|
+ # First, try zenity.
|
|
45
|
+ zenity --error \
|
|
46
|
+ --title="$complain_dialog_title" \
|
|
47
|
+ --text="$complain_message"
|
|
48
|
+ if [ "$?" -ne 127 ]; then
|
|
49
|
+ return
|
|
50
|
+ fi
|
|
51
|
+
|
|
52
|
+ # Try kdialog.
|
|
53
|
+ kdialog --title "$complain_dialog_title" \
|
|
54
|
+ --error "$complain_message"
|
|
55
|
+ if [ "$?" -ne 127 ]; then
|
|
56
|
+ return
|
|
57
|
+ fi
|
|
58
|
+
|
|
59
|
+ # Try xmessage.
|
|
60
|
+ xmessage -title "$complain_dialog_title" \
|
|
61
|
+ -center \
|
|
62
|
+ -buttons OK \
|
|
63
|
+ -default OK \
|
|
64
|
+ -xrm '*message.scrollVertical: Never' \
|
|
65
|
+ "$complain_message"
|
|
66
|
+ if [ "$?" -ne 127 ]; then
|
|
67
|
+ return
|
|
68
|
+ fi
|
|
69
|
+
|
|
70
|
+ # Try gxmessage. This one isn't installed by default on
|
|
71
|
+ # Debian with the default GNOME installation, so it seems to
|
|
72
|
+ # be the least likely program to have available, but it might
|
|
73
|
+ # be used by one of the 'lightweight' Gtk-based desktop
|
|
74
|
+ # environments.
|
|
75
|
+ gxmessage -title "$complain_dialog_title" \
|
|
76
|
+ -center \
|
|
77
|
+ -buttons GTK_STOCK_OK \
|
|
78
|
+ -default OK \
|
|
79
|
+ "$complain_message"
|
|
80
|
+ if [ "$?" -ne 127 ]; then
|
|
81
|
+ return
|
|
82
|
+ fi
|
83
|
83
|
}
|
84
|
84
|
|
85
|
85
|
if [ "`id -u`" -eq 0 ]; then
|
86
|
|
- complain "The [% c('var/Project_Name') %] should not be run as root. Exiting."
|
87
|
|
- exit 1
|
|
86
|
+ complain "The [% c('var/Project_Name') %] should not be run as root. Exiting."
|
|
87
|
+ exit 1
|
88
|
88
|
fi
|
89
|
89
|
|
90
|
90
|
if test -r /proc/cpuinfo && ! grep -q '^flags\s*:.* sse2' /proc/cpuinfo; then
|
91
|
|
- complain "[% c('var/Project_Name') %] requires a CPU with SSE2 support. Exiting."
|
92
|
|
- exit 1
|
|
91
|
+ complain "[% c('var/Project_Name') %] requires a CPU with SSE2 support. Exiting."
|
|
92
|
+ exit 1
|
93
|
93
|
fi
|
94
|
94
|
|
95
|
95
|
print_usage () {
|
96
|
|
- printf "\n[% c('var/Project_Name') %] Script Options\n"
|
97
|
|
- printf " --verbose Display [% IF c("var/tor-browser") -%]Tor and [% END -%]the browser output in the terminal\n"
|
98
|
|
- printf " --log [file] Record [% IF c("var/tor-browser") -%]Tor and [% END -%]the browser output in file (default: [% c('var/project-name') %].log)\n"
|
99
|
|
- printf " --detach Detach from terminal and run [% c('var/Project_Name') %] in the background.\n"
|
|
96
|
+ printf "\n[% c('var/Project_Name') %] Script Options\n"
|
|
97
|
+ printf " --verbose Display [% IF c("var/tor-browser") -%]Tor and [% END -%]the browser output in the terminal\n"
|
|
98
|
+ printf " --log [file] Record [% IF c("var/tor-browser") -%]Tor and [% END -%]the browser output in file (default: [% c('var/project-name') %].log)\n"
|
|
99
|
+ printf " --detach Detach from terminal and run [% c('var/Project_Name') %] in the background.\n"
|
|
100
|
+ if test -z "$system_install"; then
|
100
|
101
|
printf " --register-app Register [% c('var/Project_Name') %] as a desktop app for this user\n"
|
101
|
102
|
printf " --unregister-app Unregister [% c('var/Project_Name') %] as a desktop app for this user\n"
|
|
103
|
+ fi
|
102
|
104
|
}
|
103
|
105
|
log_output=0
|
104
|
106
|
show_output=0
|
... |
... |
@@ -108,116 +110,122 @@ register_desktop_app=0 |
108
|
110
|
logfile=/dev/null
|
109
|
111
|
while :
|
110
|
112
|
do
|
111
|
|
- case "$1" in
|
112
|
|
- --detach)
|
113
|
|
- detach=1
|
114
|
|
- shift
|
115
|
|
- ;;
|
116
|
|
- -v | --verbose | -d | --debug)
|
117
|
|
- show_output=1
|
118
|
|
- verbose_arg="$2"
|
119
|
|
- shift
|
120
|
|
- ;;
|
121
|
|
- -h | "-?" | --help | -help)
|
122
|
|
- show_usage=1
|
123
|
|
- show_output=1
|
124
|
|
- shift
|
125
|
|
- ;;
|
126
|
|
- -l | --log)
|
127
|
|
- if [ -z "$2" -o "${2:0:1}" == "-" ]; then
|
128
|
|
- printf "Logging [% c('var/Project_Name') %] debug information to [% c('var/project-name') %].log\n"
|
129
|
|
- logfile="../[% c('var/project-name') %].log"
|
130
|
|
- elif [ "${2:0:1}" == "/" -o "${2:0:1}" == "~" ]; then
|
131
|
|
- printf "Logging [% c('var/Project_Name') %] debug information to %s\n" "$2"
|
132
|
|
- logfile="$2"
|
133
|
|
- shift
|
134
|
|
- else
|
135
|
|
- printf "Logging [% c('var/Project_Name') %] debug information to %s\n" "$2"
|
136
|
|
- logfile="../$2"
|
137
|
|
- shift
|
138
|
|
- fi
|
139
|
|
- log_output=1
|
140
|
|
- shift
|
141
|
|
- ;;
|
142
|
|
- --register-app)
|
143
|
|
- register_desktop_app=1
|
144
|
|
- show_output=1
|
145
|
|
- shift
|
146
|
|
- ;;
|
147
|
|
- --unregister-app)
|
148
|
|
- register_desktop_app=-1
|
149
|
|
- show_output=1
|
150
|
|
- shift
|
151
|
|
- ;;
|
152
|
|
- *) # No more options
|
153
|
|
- break
|
154
|
|
- ;;
|
155
|
|
- esac
|
|
113
|
+ case "$1" in
|
|
114
|
+ --detach)
|
|
115
|
+ detach=1
|
|
116
|
+ shift
|
|
117
|
+ ;;
|
|
118
|
+ -v | --verbose | -d | --debug)
|
|
119
|
+ show_output=1
|
|
120
|
+ verbose_arg="$2"
|
|
121
|
+ shift
|
|
122
|
+ ;;
|
|
123
|
+ -h | "-?" | --help | -help)
|
|
124
|
+ show_usage=1
|
|
125
|
+ show_output=1
|
|
126
|
+ shift
|
|
127
|
+ ;;
|
|
128
|
+ -l | --log)
|
|
129
|
+ if [ -z "$2" -o "${2:0:1}" == "-" ]; then
|
|
130
|
+ printf "Logging [% c('var/Project_Name') %] debug information to [% c('var/project-name') %].log\n"
|
|
131
|
+ logfile="../[% c('var/project-name') %].log"
|
|
132
|
+ elif [ "${2:0:1}" == "/" -o "${2:0:1}" == "~" ]; then
|
|
133
|
+ printf "Logging [% c('var/Project_Name') %] debug information to %s\n" "$2"
|
|
134
|
+ logfile="$2"
|
|
135
|
+ shift
|
|
136
|
+ else
|
|
137
|
+ printf "Logging [% c('var/Project_Name') %] debug information to %s\n" "$2"
|
|
138
|
+ logfile="../$2"
|
|
139
|
+ shift
|
|
140
|
+ fi
|
|
141
|
+ log_output=1
|
|
142
|
+ shift
|
|
143
|
+ ;;
|
|
144
|
+ --register-app)
|
|
145
|
+ register_desktop_app=1
|
|
146
|
+ show_output=1
|
|
147
|
+ shift
|
|
148
|
+ ;;
|
|
149
|
+ --unregister-app)
|
|
150
|
+ register_desktop_app=-1
|
|
151
|
+ show_output=1
|
|
152
|
+ shift
|
|
153
|
+ ;;
|
|
154
|
+ *) # No more options
|
|
155
|
+ break
|
|
156
|
+ ;;
|
|
157
|
+ esac
|
156
|
158
|
done
|
157
|
159
|
|
158
|
160
|
# We can't detach and show output at the same time..
|
159
|
161
|
if [ "$show_output" -eq 1 -a "$detach" -eq 1 ]; then
|
160
|
|
- detach=0
|
|
162
|
+ detach=0
|
161
|
163
|
fi
|
162
|
164
|
|
163
|
165
|
if [ "$show_output" -eq 0 ]; then
|
164
|
|
- # If the user hasn't requested 'debug mode' or --help, close stdout and stderr,
|
165
|
|
- # to keep Firefox and the stuff loaded by/for it (including the
|
166
|
|
- # system's shared-library loader) from printing messages to
|
167
|
|
- # $HOME/.xsession-errors or other files. (Users wouldn't have seen
|
168
|
|
- # messages there anyway.)
|
169
|
|
- exec > "$logfile"
|
170
|
|
- exec 2> "$logfile"
|
|
166
|
+ # If the user hasn't requested 'debug mode' or --help, close stdout and stderr,
|
|
167
|
+ # to keep Firefox and the stuff loaded by/for it (including the
|
|
168
|
+ # system's shared-library loader) from printing messages to
|
|
169
|
+ # $HOME/.xsession-errors or other files. (Users wouldn't have seen
|
|
170
|
+ # messages there anyway.)
|
|
171
|
+ exec > "$logfile"
|
|
172
|
+ exec 2> "$logfile"
|
171
|
173
|
fi
|
172
|
174
|
|
173
|
175
|
# If XAUTHORITY is unset, set it to its default value of $HOME/.Xauthority
|
174
|
176
|
# before we change HOME below. (See xauth(1) and #1945.) XDM and KDM rely
|
175
|
177
|
# on applications using this default value.
|
176
|
178
|
if [ -z "$XAUTHORITY" ]; then
|
177
|
|
- XAUTHORITY=~/.Xauthority
|
178
|
|
- export XAUTHORITY
|
|
179
|
+ XAUTHORITY=~/.Xauthority
|
|
180
|
+ export XAUTHORITY
|
179
|
181
|
fi
|
180
|
182
|
|
181
|
183
|
# If this script is being run through a symlink, we need to know where
|
182
|
184
|
# in the filesystem the script itself is, not where the symlink is.
|
183
|
185
|
myname="$0"
|
184
|
186
|
if [ -L "$myname" ]; then
|
185
|
|
- # XXX readlink is not POSIX, but is present in GNU coreutils
|
186
|
|
- # and on FreeBSD. Unfortunately, the -f option (which follows
|
187
|
|
- # a whole chain of symlinks until it reaches a non-symlink
|
188
|
|
- # path name) is a GNUism, so we have to have a fallback for
|
189
|
|
- # FreeBSD. Fortunately, FreeBSD has realpath instead;
|
190
|
|
- # unfortunately, that's also non-POSIX and is not present in
|
191
|
|
- # GNU coreutils.
|
192
|
|
- #
|
193
|
|
- # If this launcher were a C program, we could just use the
|
194
|
|
- # realpath function, which *is* POSIX. Too bad POSIX didn't
|
195
|
|
- # make that function accessible to shell scripts.
|
196
|
|
-
|
197
|
|
- # If realpath is available, use it; it Does The Right Thing.
|
198
|
|
- possibly_my_real_name="`realpath "$myname" 2>/dev/null`"
|
199
|
|
- if [ "$?" -eq 0 ]; then
|
200
|
|
- myname="$possibly_my_real_name"
|
201
|
|
- else
|
202
|
|
- # realpath is not available; hopefully readlink -f works.
|
203
|
|
- myname="`readlink -f "$myname" 2>/dev/null`"
|
204
|
|
- if [ "$?" -ne 0 ]; then
|
205
|
|
- # Ugh.
|
206
|
|
- complain "start-[% c('var/project-name') %] cannot be run using a symlink on this operating system."
|
207
|
|
- fi
|
208
|
|
- fi
|
|
187
|
+ # XXX readlink is not POSIX, but is present in GNU coreutils
|
|
188
|
+ # and on FreeBSD. Unfortunately, the -f option (which follows
|
|
189
|
+ # a whole chain of symlinks until it reaches a non-symlink
|
|
190
|
+ # path name) is a GNUism, so we have to have a fallback for
|
|
191
|
+ # FreeBSD. Fortunately, FreeBSD has realpath instead;
|
|
192
|
+ # unfortunately, that's also non-POSIX and is not present in
|
|
193
|
+ # GNU coreutils.
|
|
194
|
+ #
|
|
195
|
+ # If this launcher were a C program, we could just use the
|
|
196
|
+ # realpath function, which *is* POSIX. Too bad POSIX didn't
|
|
197
|
+ # make that function accessible to shell scripts.
|
|
198
|
+
|
|
199
|
+ # If realpath is available, use it; it Does The Right Thing.
|
|
200
|
+ possibly_my_real_name="`realpath "$myname" 2>/dev/null`"
|
|
201
|
+ if [ "$?" -eq 0 ]; then
|
|
202
|
+ myname="$possibly_my_real_name"
|
|
203
|
+ else
|
|
204
|
+ # realpath is not available; hopefully readlink -f works.
|
|
205
|
+ myname="`readlink -f "$myname" 2>/dev/null`"
|
|
206
|
+ if [ "$?" -ne 0 ]; then
|
|
207
|
+ # Ugh.
|
|
208
|
+ complain "start-[% c('var/project-name') %] cannot be run using a symlink on this operating system."
|
|
209
|
+ fi
|
|
210
|
+ fi
|
209
|
211
|
fi
|
210
|
212
|
|
211
|
|
-# Try to be agnostic to where we're being started from, chdir to where
|
212
|
|
-# the script is.
|
213
|
|
-mydir="`dirname "$myname"`"
|
214
|
|
-test -d "$mydir" && cd "$mydir"
|
|
213
|
+cd "$(dirname "$myname")"
|
|
214
|
+browser_dir="$(pwd)"
|
|
215
|
+if test -f "$browser_dir/is-packaged-app"; then
|
|
216
|
+ system_install=1
|
|
217
|
+ browser_home="$HOME/.[% pc('linux-packages', 'var/system_pkg/pkg_name') %]"
|
|
218
|
+ mkdir -p "$browser_home"
|
|
219
|
+ cd "$browser_home"
|
|
220
|
+else
|
|
221
|
+ browser_home="$browser_dir"
|
|
222
|
+fi
|
215
|
223
|
|
216
|
224
|
# If ${PWD} results in a zero length string, we can try something else...
|
217
|
225
|
if [ ! "${PWD}" ]; then
|
218
|
|
- # "hacking around some braindamage"
|
219
|
|
- PWD="`pwd`"
|
220
|
|
- surveysays="This system has a messed up shell.\n"
|
|
226
|
+ # "hacking around some braindamage"
|
|
227
|
+ PWD="`pwd`"
|
|
228
|
+ surveysays="This system has a messed up shell.\n"
|
221
|
229
|
fi
|
222
|
230
|
|
223
|
231
|
# This is a fix for an ibus issue on some Linux systems. See #9353 for more
|
... |
... |
@@ -227,46 +235,48 @@ if [ ! -d ".config/ibus" ]; then |
227
|
235
|
ln -nsf ~/.config/ibus/bus .config/ibus
|
228
|
236
|
fi
|
229
|
237
|
|
230
|
|
-# Fix up .desktop Icon and Exec Paths, and update the .desktop file from the
|
231
|
|
-# canonical version if it was changed by the updater.
|
232
|
|
-cp start-[% c('var/project-name') %].desktop ../
|
233
|
|
-sed -i -e "s,^Name=.*,Name=[% c('var/Project_Name') %],g" ../start-[% c('var/project-name') %].desktop
|
234
|
|
-sed -i -e "s,^Icon=.*,Icon=$PWD/browser/chrome/icons/default/default128.png,g" ../start-[% c('var/project-name') %].desktop
|
235
|
|
-sed -i -e "s,^Icon=.*,Icon=$PWD/browser/chrome/icons/default/default128.png,g" start-[% c('var/project-name') %].desktop
|
236
|
|
-sed -i -e "s,^Exec=.*,Exec=sh -c '\"$PWD/start-[% c('var/project-name') %]\" --detach || ([ ! -x \"$PWD/start-[% c('var/project-name') %]\" ] \&\& \"\$(dirname \"\$*\")\"/Browser/start-[% c('var/project-name') %] --detach)' dummy %k,g" ../start-[% c('var/project-name') %].desktop
|
237
|
|
-
|
238
|
|
-if [ "$register_desktop_app" -eq 1 ]; then
|
239
|
|
- mkdir -p "$HOME/.local/share/applications/"
|
240
|
|
- cp ../start-[% c('var/project-name') %].desktop "$HOME/.local/share/applications/"
|
241
|
|
- update-desktop-database "$HOME/.local/share/applications/"
|
242
|
|
- printf "[% c('var/Project_Name') %] has been registered as a desktop app for this user in ~/.local/share/applications/\n"
|
243
|
|
- exit 0
|
244
|
|
-fi
|
245
|
|
-
|
246
|
|
-if [ "$register_desktop_app" -eq -1 ]; then
|
247
|
|
- if [ -e "$HOME/.local/share/applications/start-[% c('var/project-name') %].desktop" ]; then
|
248
|
|
- rm -f "$HOME/.local/share/applications/start-[% c('var/project-name') %].desktop"
|
249
|
|
- update-desktop-database "$HOME/.local/share/applications/"
|
250
|
|
- printf "[% c('var/Project_Name') %] has been removed as a user desktop app (from ~/.local/share/applications/)\n"
|
251
|
|
- else
|
252
|
|
- printf "[% c('var/Project_Name') %] does not appear to be a desktop app (not present in ~/.local/share/applications/)\n"
|
253
|
|
- fi
|
254
|
|
- exit 0
|
|
238
|
+if test -z "$system_install"; then
|
|
239
|
+ # Fix up .desktop Icon and Exec Paths, and update the .desktop file from the
|
|
240
|
+ # canonical version if it was changed by the updater.
|
|
241
|
+ cp start-[% c('var/project-name') %].desktop ../
|
|
242
|
+ sed -i -e "s,^Name=.*,Name=[% c('var/Project_Name') %],g" ../start-[% c('var/project-name') %].desktop
|
|
243
|
+ sed -i -e "s,^Icon=.*,Icon=$PWD/browser/chrome/icons/default/default128.png,g" ../start-[% c('var/project-name') %].desktop
|
|
244
|
+ sed -i -e "s,^Icon=.*,Icon=$PWD/browser/chrome/icons/default/default128.png,g" start-[% c('var/project-name') %].desktop
|
|
245
|
+ sed -i -e "s,^Exec=.*,Exec=sh -c '\"$PWD/start-[% c('var/project-name') %]\" --detach || ([ ! -x \"$PWD/start-[% c('var/project-name') %]\" ] \&\& \"\$(dirname \"\$*\")\"/Browser/start-[% c('var/project-name') %] --detach)' dummy %k,g" ../start-[% c('var/project-name') %].desktop
|
|
246
|
+
|
|
247
|
+ if [ "$register_desktop_app" -eq 1 ]; then
|
|
248
|
+ mkdir -p "$HOME/.local/share/applications/"
|
|
249
|
+ cp ../start-[% c('var/project-name') %].desktop "$HOME/.local/share/applications/"
|
|
250
|
+ update-desktop-database "$HOME/.local/share/applications/"
|
|
251
|
+ printf "[% c('var/Project_Name') %] has been registered as a desktop app for this user in ~/.local/share/applications/\n"
|
|
252
|
+ exit 0
|
|
253
|
+ fi
|
|
254
|
+
|
|
255
|
+ if [ "$register_desktop_app" -eq -1 ]; then
|
|
256
|
+ if [ -e "$HOME/.local/share/applications/start-[% c('var/project-name') %].desktop" ]; then
|
|
257
|
+ rm -f "$HOME/.local/share/applications/start-[% c('var/project-name') %].desktop"
|
|
258
|
+ update-desktop-database "$HOME/.local/share/applications/"
|
|
259
|
+ printf "[% c('var/Project_Name') %] has been removed as a user desktop app (from ~/.local/share/applications/)\n"
|
|
260
|
+ else
|
|
261
|
+ printf "[% c('var/Project_Name') %] does not appear to be a desktop app (not present in ~/.local/share/applications/)\n"
|
|
262
|
+ fi
|
|
263
|
+ exit 0
|
|
264
|
+ fi
|
255
|
265
|
fi
|
256
|
266
|
|
257
|
267
|
export BB_ORIGINAL_HOME="$HOME"
|
258
|
|
-HOME="${PWD}"
|
|
268
|
+HOME="$browser_home"
|
259
|
269
|
export HOME
|
260
|
270
|
|
261
|
271
|
# Prevent disk leaks in $HOME/.local/share (tor-browser#17560)
|
262
|
272
|
function erase_leaky() {
|
263
|
|
- local leaky="$1"
|
264
|
|
- [ -e "$leaky" ] &&
|
265
|
|
- ( srm -r "$leaky" ||
|
266
|
|
- wipe -r "$leaky" ||
|
267
|
|
- find "$leaky" -type f -exec shred -u {} \; ;
|
268
|
|
- rm -rf "$leaky"
|
269
|
|
- ) > /dev/null 2>&1
|
|
273
|
+ local leaky="$1"
|
|
274
|
+ [ -e "$leaky" ] &&
|
|
275
|
+ ( srm -r "$leaky" ||
|
|
276
|
+ wipe -r "$leaky" ||
|
|
277
|
+ find "$leaky" -type f -exec shred -u {} \; ;
|
|
278
|
+ rm -rf "$leaky"
|
|
279
|
+ ) > /dev/null 2>&1
|
270
|
280
|
}
|
271
|
281
|
local_dir="$HOME/.local/"
|
272
|
282
|
share_dir="$local_dir/share"
|
... |
... |
@@ -275,14 +285,14 @@ share_dir="$local_dir/share" |
275
|
285
|
# We're not using realpath/readlink for consistency with the (possibly
|
276
|
286
|
# outdated) availability assumptions made elsewhere in this script.
|
277
|
287
|
if ! [ -L "$local_dir" -o -L "$share_dir" ]; then
|
278
|
|
- if [ -d "$share_dir" ]; then
|
279
|
|
- for leaky_path in "gvfs-metadata" "recently-used.xbel"; do
|
280
|
|
- erase_leaky "$share_dir/$leaky_path"
|
281
|
|
- done
|
282
|
|
- else
|
283
|
|
- mkdir -p "$local_dir"
|
284
|
|
- fi
|
285
|
|
- ln -fs /dev/null "$share_dir"
|
|
288
|
+ if [ -d "$share_dir" ]; then
|
|
289
|
+ for leaky_path in "gvfs-metadata" "recently-used.xbel"; do
|
|
290
|
+ erase_leaky "$share_dir/$leaky_path"
|
|
291
|
+ done
|
|
292
|
+ else
|
|
293
|
+ mkdir -p "$local_dir"
|
|
294
|
+ fi
|
|
295
|
+ ln -fs /dev/null "$share_dir"
|
286
|
296
|
fi
|
287
|
297
|
[ -L "$HOME/.cache" ] || erase_leaky "$HOME/.cache/nvidia"
|
288
|
298
|
|
... |
... |
@@ -291,8 +301,8 @@ SYSARCHITECTURE=$(getconf LONG_BIT) |
291
|
301
|
TORARCHITECTURE=$(expr "$(file TorBrowser/Tor/tor)" : '.*ELF \([[:digit:]]*\)')
|
292
|
302
|
|
293
|
303
|
if [ $SYSARCHITECTURE -ne $TORARCHITECTURE ]; then
|
294
|
|
- complain "Wrong architecture? 32-bit vs. 64-bit."
|
295
|
|
- exit 1
|
|
304
|
+ complain "Wrong architecture? 32-bit vs. 64-bit."
|
|
305
|
+ exit 1
|
296
|
306
|
fi
|
297
|
307
|
[% END -%]
|
298
|
308
|
|
... |
... |
@@ -305,27 +315,27 @@ export ASAN_OPTIONS |
305
|
315
|
|
306
|
316
|
[% IF c("var/tor-browser") -%]
|
307
|
317
|
function setControlPortPasswd() {
|
308
|
|
- local ctrlPasswd=$1
|
309
|
|
-
|
310
|
|
- if test -z "$ctrlPasswd" -o "$ctrlPasswd" = $'\"secret\"' ; then
|
311
|
|
- unset TOR_CONTROL_PASSWD
|
312
|
|
- return
|
313
|
|
- fi
|
314
|
|
-
|
315
|
|
- if test "${ctrlPasswd:0:1}" = $'\"'; then # First 2 chars were '"
|
316
|
|
- printf "Using system Tor process.\n"
|
317
|
|
- export TOR_CONTROL_PASSWD
|
318
|
|
- else
|
319
|
|
- complain "There seems to have been a quoting problem with your \
|
|
318
|
+ local ctrlPasswd=$1
|
|
319
|
+
|
|
320
|
+ if test -z "$ctrlPasswd" -o "$ctrlPasswd" = $'\"secret\"' ; then
|
|
321
|
+ unset TOR_CONTROL_PASSWD
|
|
322
|
+ return
|
|
323
|
+ fi
|
|
324
|
+
|
|
325
|
+ if test "${ctrlPasswd:0:1}" = $'\"'; then # First 2 chars were '"
|
|
326
|
+ printf "Using system Tor process.\n"
|
|
327
|
+ export TOR_CONTROL_PASSWD
|
|
328
|
+ else
|
|
329
|
+ complain "There seems to have been a quoting problem with your \
|
320
|
330
|
TOR_CONTROL_PASSWD environment variable."
|
321
|
|
- echo "The Tor ControlPort password should be given inside double"
|
322
|
|
- echo "quotes, inside single quotes. That is, if the ControlPort"
|
323
|
|
- echo 'password is “secret” (without curly quotes) then we must'
|
324
|
|
- echo "start this script after setting the environment variable"
|
325
|
|
- echo "exactly like this:"
|
326
|
|
- echo
|
327
|
|
- echo " \$ TOR_CONTROL_PASSWD='\"secret\"' $myname"
|
328
|
|
- fi
|
|
331
|
+ echo "The Tor ControlPort password should be given inside double"
|
|
332
|
+ echo "quotes, inside single quotes. That is, if the ControlPort"
|
|
333
|
+ echo 'password is “secret” (without curly quotes) then we must'
|
|
334
|
+ echo "start this script after setting the environment variable"
|
|
335
|
+ echo "exactly like this:"
|
|
336
|
+ echo
|
|
337
|
+ echo " \$ TOR_CONTROL_PASSWD='\"secret\"' $myname"
|
|
338
|
+ fi
|
329
|
339
|
}
|
330
|
340
|
|
331
|
341
|
# Using a system-installed Tor process with Tor Browser:
|
... |
... |
@@ -367,7 +377,7 @@ setControlPortPasswd ${TOR_CONTROL_PASSWD:='"secret"'} |
367
|
377
|
[% END -%]
|
368
|
378
|
|
369
|
379
|
# Set up custom bundled fonts. See fonts-conf(5).
|
370
|
|
-export FONTCONFIG_PATH="${HOME}/fontconfig"
|
|
380
|
+export FONTCONFIG_PATH="$browser_dir/fontconfig"
|
371
|
381
|
export FONTCONFIG_FILE="fonts.conf"
|
372
|
382
|
[% # tor-browser#41776: We cannot make the updater remove this file.
|
373
|
383
|
# So, let's remove it on this script, since we know that at this point the
|
... |
... |
@@ -397,19 +407,19 @@ cd "${HOME}" |
397
|
407
|
# prevent from mixing up with them).
|
398
|
408
|
|
399
|
409
|
if [ "$show_usage" -eq 1 ]; then
|
400
|
|
- # Display Firefox help, then our help
|
401
|
|
- [% IF c("var/tor-browser") %]TOR_CONTROL_PASSWD=${TOR_CONTROL_PASSWD}[% END %] ./[% c('var/exe_name') %] --help 2>/dev/null
|
402
|
|
- print_usage
|
|
410
|
+ # Display Firefox help, then our help
|
|
411
|
+ [% IF c("var/tor-browser") %]TOR_CONTROL_PASSWD=${TOR_CONTROL_PASSWD}[% END %] "$browser_dir"/[% c('var/exe_name') %] --help 2>/dev/null
|
|
412
|
+ print_usage
|
403
|
413
|
elif [ "$detach" -eq 1 ] ; then
|
404
|
|
- [% IF c("var/tor-browser") %]TOR_CONTROL_PASSWD=${TOR_CONTROL_PASSWD}[% END %] ./[% c('var/exe_name') %] "${@}" > "$logfile" 2>&1 </dev/null &
|
405
|
|
- disown "$!"
|
|
414
|
+ [% IF c("var/tor-browser") %]TOR_CONTROL_PASSWD=${TOR_CONTROL_PASSWD}[% END %] "$browser_dir"/[% c('var/exe_name') %] "${@}" > "$logfile" 2>&1 </dev/null &
|
|
415
|
+ disown "$!"
|
406
|
416
|
elif [ "$log_output" -eq 1 -a "$show_output" -eq 1 ]; then
|
407
|
|
- [% IF c("var/tor-browser") %]TOR_CONTROL_PASSWD=${TOR_CONTROL_PASSWD}[% END %] ./[% c('var/exe_name') %] "${@}" 2>&1 </dev/null | \
|
408
|
|
- tee "$logfile"
|
|
417
|
+ [% IF c("var/tor-browser") %]TOR_CONTROL_PASSWD=${TOR_CONTROL_PASSWD}[% END %] "$browser_dir"/[% c('var/exe_name') %] "${@}" 2>&1 </dev/null | \
|
|
418
|
+ tee "$logfile"
|
409
|
419
|
elif [ "$show_output" -eq 1 ]; then
|
410
|
|
- [% IF c("var/tor-browser") %]TOR_CONTROL_PASSWD=${TOR_CONTROL_PASSWD}[% END %] ./[% c('var/exe_name') %] "${@}" < /dev/null
|
|
420
|
+ [% IF c("var/tor-browser") %]TOR_CONTROL_PASSWD=${TOR_CONTROL_PASSWD}[% END %] "$browser_dir"/[% c('var/exe_name') %] "${@}" < /dev/null
|
411
|
421
|
else
|
412
|
|
- [% IF c("var/tor-browser") %]TOR_CONTROL_PASSWD=${TOR_CONTROL_PASSWD}[% END %] ./[% c('var/exe_name') %] "${@}" > "$logfile" 2>&1 </dev/null
|
|
422
|
+ [% IF c("var/tor-browser") %]TOR_CONTROL_PASSWD=${TOR_CONTROL_PASSWD}[% END %] "$browser_dir"/[% c('var/exe_name') %] "${@}" > "$logfile" 2>&1 </dev/null
|
413
|
423
|
fi
|
414
|
424
|
|
415
|
425
|
exit $? |