|
@@ -69,9 +69,10 @@ public class LinuxInstaller extends Installer {
|
69
|
69
|
case DESKTOP:
|
70
|
70
|
// No desktop for root
|
71
|
71
|
return !isRoot();
|
|
72
|
+ case PROTOCOL:
|
72
|
73
|
case UNINSTALLER:
|
73
|
74
|
case MENU:
|
74
|
|
- // Both root and non-root have a menu and uninstaller
|
|
75
|
+ // Both root and non-root have a menu, uninstaller, and protocol
|
75
|
76
|
return true;
|
76
|
77
|
default:
|
77
|
78
|
// Anything else that gets added should be false until the relevent
|
|
@@ -94,7 +95,8 @@ public class LinuxInstaller extends Installer {
|
94
|
95
|
|
95
|
96
|
PrintWriter writer = null;
|
96
|
97
|
try {
|
97
|
|
- String filename;
|
|
98
|
+ String filename = "";
|
|
99
|
+ String command = "";
|
98
|
100
|
|
99
|
101
|
switch (shortcutType) {
|
100
|
102
|
case DESKTOP:
|
|
@@ -102,7 +104,7 @@ public class LinuxInstaller extends Installer {
|
102
|
104
|
break;
|
103
|
105
|
|
104
|
106
|
case MENU:
|
105
|
|
- if (CLIParser.getCLIParser().getParamNumber("-isroot") > 0) {
|
|
107
|
+ if (isRoot()) {
|
106
|
108
|
filename = "/usr/share/applications/DMDirc.desktop";
|
107
|
109
|
} else {
|
108
|
110
|
filename = System.getProperty("user.home")+"/.local/share/applications/DMDirc.desktop";
|
|
@@ -112,20 +114,144 @@ public class LinuxInstaller extends Installer {
|
112
|
114
|
case UNINSTALLER:
|
113
|
115
|
writer = new PrintWriter(location+"/uninstall.sh");
|
114
|
116
|
writer.println("#!/bin/sh");
|
|
117
|
+ writer.println("# DMDirc Uninstaller");
|
|
118
|
+ writer.println("ISKDE=`pidof -x -s kdeinit`");
|
|
119
|
+ writer.println("KDIALOG=`which kdialog`");
|
|
120
|
+ writer.println("ISGNOME=`pidof -x -s gnome-panel`");
|
|
121
|
+ writer.println("ZENITY=`which zenity`");
|
|
122
|
+ writer.println("DIALOG=`which dialog`");
|
|
123
|
+
|
|
124
|
+ if (isRoot()) {
|
|
125
|
+ writer.println("USER=`whoami`");
|
|
126
|
+ writer.println("if [ \"${USER}\" != \"root\" ]; then");
|
|
127
|
+ writer.println("if [ ${result} -eq 1 ]; then");
|
|
128
|
+ writer.println("\t\tif [ \"\" != \"${ISKDE}\" -a \"\" != \"${KDIALOG}\" -a \"\" != \"${DISPLAY}\" ]; then");
|
|
129
|
+ writer.println("\t\t ${KDIALOG} --title \"DMDirc Uninstaller\" --error \"Uninstall Aborted. Only root can use this script\"");
|
|
130
|
+ writer.println("\t\telif [ \"\" != \"${ISGNOME}\" -a \"\" != \"${ZENITY}\" -a \"\" != \"${DISPLAY}\" ]; then");
|
|
131
|
+ writer.println("\t\t ${ZENITY} --info --title \"DMDirc Uninstaller\" --text \"Uninstall Aborted. Only root can use this script\"");
|
|
132
|
+ writer.println("\t\tfi");
|
|
133
|
+ writer.println("\t\techo \"Uninstall Aborted. Only root can use this script\"");
|
|
134
|
+ writer.println("\tfi");
|
|
135
|
+ writer.println("exit 1;");
|
|
136
|
+ writer.println("fi");
|
|
137
|
+ }
|
|
138
|
+
|
|
139
|
+ writer.println("if [ \"\" != \"${ISKDE}\" -a \"\" != \"${KDIALOG}\" -a \"\" != \"${DISPLAY}\" ]; then");
|
|
140
|
+ writer.println(" echo \"Dialog Prompt on: ${DISPLAY}\"");
|
|
141
|
+ writer.println(" ${KDIALOG} --title \"DMDirc Uninstaller\" --yesno \"Are you sure you want to uninstall DMDirc?\"");
|
|
142
|
+ writer.println("elif [ \"\" != \"${ISGNOME}\" -a \"\" != \"${ZENITY}\" -a \"\" != \"${DISPLAY}\" ]; then");
|
|
143
|
+ writer.println(" echo \"Dialog Prompt on: ${DISPLAY}\"");
|
|
144
|
+ writer.println(" ${ZENITY} --question --title \"DMDirc Uninstaller\" --text \"Are you sure you want to uninstall DMDirc?\"");
|
|
145
|
+ writer.println("elif [ \"\" != \"${DIALOG}\" ]; then");
|
|
146
|
+ writer.println(" ${DIALOG} --title \"DMDirc Uninstaller\" --yesno \"Are you sure you want to uninstall DMDirc?\" 8 40");
|
|
147
|
+ writer.println("fi");
|
|
148
|
+
|
|
149
|
+ writer.println("if [ $? -ne 0 ]; then");
|
|
150
|
+ writer.println("\tif [ \"\" != \"${ISKDE}\" -a \"\" != \"${KDIALOG}\" -a \"\" != \"${DISPLAY}\" ]; then");
|
|
151
|
+ writer.println("\t ${KDIALOG} --title \"DMDirc Uninstaller\" --msgbox \"Uninstall Aborted\"");
|
|
152
|
+ writer.println("\telif [ \"\" != \"${ISGNOME}\" -a \"\" != \"${ZENITY}\" -a \"\" != \"${DISPLAY}\" ]; then");
|
|
153
|
+ writer.println("\t ${ZENITY} --info --title \"DMDirc Uninstaller\" --text \"Uninstall Aborted\"");
|
|
154
|
+ writer.println("\tfi");
|
|
155
|
+ writer.println("\techo \"Uninstall Aborted\"");
|
|
156
|
+ writer.println("\texit 1;");
|
|
157
|
+ writer.println("fi");
|
|
158
|
+
|
115
|
159
|
writer.println("echo \"Uninstalling dmdirc\"");
|
116
|
160
|
writer.println("echo \"Removing Shortcuts..\"");
|
117
|
|
- if (CLIParser.getCLIParser().getParamNumber("-isroot") > 0) {
|
|
161
|
+ if (isRoot()) {
|
|
162
|
+ command = "${TOOL} --config-source=`${TOOL} --get-default-source`";
|
|
163
|
+ filename = "/usr/share/services/irc.protocol";
|
118
|
164
|
writer.println("rm -Rfv /usr/share/applications/DMDirc.desktop");
|
119
|
165
|
} else {
|
|
166
|
+ command = "${TOOL}";
|
|
167
|
+ filename = "~/.kde/share/services/irc.protocol";
|
120
|
168
|
writer.println("rm -Rfv "+System.getProperty("user.home")+"/.local/share/applications/DMDirc.desktop");
|
121
|
169
|
writer.println("rm -Rfv "+System.getProperty("user.home")+"/Desktop/DMDirc.desktop");
|
122
|
170
|
}
|
|
171
|
+ writer.println("TOOL=`which gconftool-2`");
|
|
172
|
+ writer.println("if [ \"${TOOL}\" != \"\" ]; then");
|
|
173
|
+ writer.println("\tCURRENT=`"+command+" --get /desktop/gnome/url-handlers/irc/command`");
|
|
174
|
+ writer.println("\tif [ \"${CURRENT}\" = \"\\\""+location+"/DMDirc.sh\\\" -c %s\" ]; then");
|
|
175
|
+ writer.println("\t\techo \"Removing Gnome Protocol Handler\"");
|
|
176
|
+ writer.println("\t\t"+command+" --unset /desktop/gnome/url-handlers/irc/enabled");
|
|
177
|
+ writer.println("\t\t"+command+" --unset /desktop/gnome/url-handlers/irc/command");
|
|
178
|
+ writer.println("\telse");
|
|
179
|
+ writer.println("\t\techo \"Not Removing Gnome Protocol Handler\"");
|
|
180
|
+ writer.println("\tfi");
|
|
181
|
+ writer.println("fi");
|
|
182
|
+
|
|
183
|
+ writer.println("if [ -e \""+filename+"\" ]; then");
|
|
184
|
+ writer.println("\tCURRENT=`grep DMDirc "+filename+"`");
|
|
185
|
+ writer.println("\tif [ \"\" != \"${CURRENT}\" ]; then");
|
|
186
|
+ writer.println("\t\techo \"Removing KDE Protocol Handler\"");
|
|
187
|
+ writer.println("\t\trm -Rfv "+filename);
|
|
188
|
+ writer.println("\telse");
|
|
189
|
+ writer.println("\t\techo \"Not Removing KDE Protocol Handler\"");
|
|
190
|
+ writer.println("\tfi");
|
|
191
|
+ writer.println("fi");
|
|
192
|
+
|
123
|
193
|
writer.println("echo \"Removing Installation Directory\"");
|
124
|
|
- writer.println("rm -Rfv "+location);
|
|
194
|
+ writer.println("rm -Rfv \""+location+"\"");
|
|
195
|
+
|
|
196
|
+ writer.println("if [ \"\" != \"${ISKDE}\" -a \"\" != \"${KDIALOG}\" -a \"\" != \"${DISPLAY}\" ]; then");
|
|
197
|
+ writer.println(" ${KDIALOG} --title \"DMDirc Uninstaller\" --msgbox \"DMDirc Uninstalled Successfully\"");
|
|
198
|
+ writer.println("elif [ \"\" != \"${ISGNOME}\" -a \"\" != \"${ZENITY}\" -a \"\" != \"${DISPLAY}\" ]; then");
|
|
199
|
+ writer.println(" ${ZENITY} --info --title \"DMDirc Uninstaller\" --text \"DMDirc Uninstalled Successfully\"");
|
|
200
|
+ writer.println("fi");
|
|
201
|
+
|
125
|
202
|
writer.println("echo \"Done.\"");
|
126
|
203
|
|
127
|
204
|
(new File(location+"/uninstall.sh")).setExecutable(true);
|
128
|
205
|
return;
|
|
206
|
+
|
|
207
|
+ case PROTOCOL:
|
|
208
|
+ if (isRoot()) {
|
|
209
|
+ command = "${TOOL} --config-source=`${TOOL} --get-default-source`";
|
|
210
|
+ filename = "/usr/share/services/";
|
|
211
|
+ } else {
|
|
212
|
+ command = "${TOOL}";
|
|
213
|
+ filename = "~/.kde/share/services/";
|
|
214
|
+ }
|
|
215
|
+
|
|
216
|
+ writer = new PrintWriter(location+"/protocolHandlers.sh");
|
|
217
|
+ writer.println("#!/bin/sh");
|
|
218
|
+ writer.println("TOOL=`which gconftool-2`");
|
|
219
|
+ writer.println("if [ \"${TOOL}\" != \"\" ]; then");
|
|
220
|
+ writer.println("\t"+command+" --set --type=bool /desktop/gnome/url-handlers/irc/enabled true");
|
|
221
|
+ writer.println("\t"+command+" --set --type=string /desktop/gnome/url-handlers/irc/command \"\\\""+location+"/DMDirc.sh\\\" -c %s\"");
|
|
222
|
+ writer.println("fi");
|
|
223
|
+ writer.println("exit 0;");
|
|
224
|
+ writer.close();
|
|
225
|
+
|
|
226
|
+ (new File(location+"/protocolHandlers.sh")).setExecutable(true);
|
|
227
|
+
|
|
228
|
+ try {
|
|
229
|
+ final Process gconfProcess = Runtime.getRuntime().exec(new String[]{"/bin/sh", location+"/protocolHandlers.sh"});
|
|
230
|
+ new StreamReader(gconfProcess.getInputStream()).start();
|
|
231
|
+ new StreamReader(gconfProcess.getErrorStream()).start();
|
|
232
|
+ gconfProcess.waitFor();
|
|
233
|
+ (new File(location+"/protocolHandlers.sh")).delete();
|
|
234
|
+ } catch (Exception e) {
|
|
235
|
+ step.addText(" - Error adding gnome Protocol Handler: "+e.getMessage());
|
|
236
|
+ }
|
|
237
|
+
|
|
238
|
+ if (filename != "") {
|
|
239
|
+ if ((new File(filename)).exists()) {
|
|
240
|
+ writer = new PrintWriter(filename+"irc.protocol");
|
|
241
|
+ writer.println("[Protocol]");
|
|
242
|
+ writer.println("Exec="+location+"/DMDirc.sh -c %u");
|
|
243
|
+ writer.println("protocol=irc");
|
|
244
|
+ writer.println("input=none");
|
|
245
|
+ writer.println("output=none");
|
|
246
|
+ writer.println("helper=true");
|
|
247
|
+ writer.println("listing=false");
|
|
248
|
+ writer.println("reading=false");
|
|
249
|
+ writer.println("writing=false");
|
|
250
|
+ writer.println("makedir=false");
|
|
251
|
+ writer.println("deleting=false");
|
|
252
|
+ }
|
|
253
|
+ }
|
|
254
|
+ return;
|
129
|
255
|
|
130
|
256
|
default:
|
131
|
257
|
step.addText(" - Error creating shortcut. Not applicable to this Operating System");
|
|
@@ -168,4 +294,13 @@ public class LinuxInstaller extends Installer {
|
168
|
294
|
writer.println("TerminalOptions=");
|
169
|
295
|
writer.println("Type=Application");
|
170
|
296
|
}
|
|
297
|
+
|
|
298
|
+ /**
|
|
299
|
+ * Any post-install tasks should be done here.
|
|
300
|
+ *
|
|
301
|
+ * @param location Location where app was installed to.
|
|
302
|
+ */
|
|
303
|
+ public void postInstall(final String location) {
|
|
304
|
+ (new File(location+"/DMDirc.sh")).setExecutable(true);
|
|
305
|
+ }
|
171
|
306
|
}
|