Browse code

To the new folder "Apollia_Files/Java Policies", added the "Choose Default Version" app from an old version of APSK Runner. Didn't change it yet, just so when I do change it, GitList will better display the differences.

https://apollia.org/gitlist/APSK-Runner.git

Apollia authored on01/27/2021 01:11:46
Showing1 changed files
1 1
new file mode 100755
... ...
@@ -0,0 +1,247 @@
1
+#!/bin/bash
2
+#
3
+# Choose Default Version
4
+#
5
+# A modified version of the Choose Default Version script from APSK Apphoard Manager.
6
+#
7
+# by Apollia - http://apollia.org/
8
+#
9
+# 06:51:47 09/19/2018.  This version outputs a text file instead of a symlink,
10
+# to make it work even in non-GNU/Linux disks which can't handle symlinks.
11
+
12
+
13
+readonly App_Name="APSK Runner"
14
+	readonly Script_Title="Choose Default Version - $App_Name Edition"
15
+
16
+
17
+readonly Original_Working_Dir=$(pwd)
18
+
19
+readonly Fillepath____This_Script=$(realpath "${BASH_SOURCE[0]}")
20
+	readonly Follpath____This_Script=$(dirname "$Fillepath____This_Script")
21
+
22
+		readonly Foldername____This_Script=$(basename "$Follpath____This_Script")
23
+		readonly Follpath____App_Versions_Home=$(realpath "$Follpath____This_Script/..")
24
+			readonly Note_Fillepath____Default_Version="$Follpath____App_Versions_Home/Default-Version"
25
+
26
+
27
+echo
28
+echo
29
+echo "	--------------------------------------------"
30
+
31
+echo "	$Script_Title"
32
+
33
+echo "	--------------------------------------------"
34
+
35
+
36
+readonly GUI_Title="Choose Default Version of $App_Name"
37
+readonly GUI_Message="Which version of $App_Name should be the default?"
38
+
39
+
40
+readonly EOL=$'\n'
41
+
42
+echo "App_Name: $App_Name"
43
+
44
+readonly Arg____App_Version="$1"
45
+
46
+
47
+
48
+############
49
+# Function
50
+Possibly_Replace_Note____Default_Version()
51
+{
52
+	local folpath="$1"
53
+	local follpath
54
+	local folname
55
+	
56
+	follpath=$(readlink -m "$folpath")
57
+	folname=$(basename "$follpath")
58
+		retval="$folname"
59
+	
60
+	
61
+	cd "$Follpath____App_Versions_Home"
62
+	
63
+	if [ -d "$folname" ]
64
+	then
65
+		echo -n "$folname" > "$Note_Fillepath____Default_Version"
66
+		result_code="$?"
67
+		
68
+		
69
+		
70
+		#!!!!
71
+		return "$result_code"
72
+	fi
73
+	
74
+	
75
+	#!!!!
76
+	return 1
77
+}
78
+readonly -f Possibly_Replace_Note____Default_Version
79
+
80
+# End of
81
+# Function
82
+############
83
+
84
+
85
+
86
+############
87
+# Function
88
+Possibly_Switch_to_App_Version()
89
+{
90
+	local app_version="$1"
91
+	
92
+	if [ -f "$Note_Fillepath____Default_Version" ]
93
+	then
94
+		Folname____Current_Default_Version=$(cat "$Note_Fillepath____Default_Version")
95
+		
96
+		
97
+		if [ "$app_version" = "$Folname____Current_Default_Version" ]
98
+		then
99
+			echo
100
+			echo "Aborting - nothing to do, since the chosen default version was the same as the current default version:
101
+		
102
+	$app_version"
103
+			
104
+			
105
+			#!!!!
106
+			exit 3
107
+		fi
108
+	fi
109
+	
110
+	
111
+	Possibly_Replace_Note____Default_Version "$app_version"
112
+		result_code="$?"
113
+	
114
+	if [ "$result_code" = 0 ]
115
+	then
116
+		echo
117
+		echo
118
+		echo "$App_Name default version is now: $retval"
119
+		
120
+		
121
+		#!!!!
122
+		exit 0
123
+	else
124
+		echo "Wasn't able to change $App_Name default version to $retval!"
125
+	fi
126
+	
127
+	
128
+	#!!!!
129
+	exit 1
130
+}
131
+readonly -f Possibly_Switch_to_App_Version
132
+
133
+# End of
134
+# Function
135
+############
136
+
137
+
138
+
139
+if [ ! -z "$Arg____App_Version" ]
140
+then
141
+
142
+	
143
+	#!!!!
144
+	Possibly_Switch_to_App_Version "$Arg____App_Version"
145
+	
146
+	
147
+fi
148
+
149
+
150
+
151
+############
152
+# Function
153
+Find_Versions()
154
+{
155
+	find "$Follpath____App_Versions_Home" -mindepth 1 -maxdepth 1  -type d -not -name "*$EOL*" -not -name "$Foldername____This_Script" -printf "%f\n" | sort -h
156
+}
157
+readonly -f Find_Versions
158
+
159
+# End of
160
+# Function
161
+############
162
+
163
+
164
+
165
+############
166
+# Function
167
+Build_GUI_Window()
168
+{
169
+	GUI_BEING_BUILT='
170
+	<window default_height="300" default_width="800"'
171
+	GUI_BEING_BUILT+="title=\"$GUI_Title\""
172
+	GUI_BEING_BUILT+='resizable="true" decorated="true">
173
+	  <vbox>
174
+	  <text><label>'
175
+	  
176
+	GUI_BEING_BUILT+="$GUI_Message</label></text>"
177
+
178
+	GUI_BEING_BUILT+='
179
+		<list>
180
+		  <variable>VERSION</variable>'
181
+
182
+	GUI_BEING_BUILT+="<input>Find_Versions</input>"
183
+	GUI_BEING_BUILT+='<action>Possibly_Switch_to_App_Version "$VERSION"</action>'
184
+	GUI_BEING_BUILT+='<action>EXIT:ok</action>'
185
+	GUI_BEING_BUILT+='</list>'
186
+	
187
+		GUI_BEING_BUILT+='
188
+		<hbox>'
189
+
190
+	GUI_BEING_BUILT+='
191
+		 <button cancel></button>
192
+		</hbox>'
193
+
194
+	
195
+	GUI_BEING_BUILT+='</vbox>'
196
+	
197
+	Gtkdialog_Snippet____Ctrl_W_to_Quit='
198
+<action signal="key-press-event" condition="command_is_true([[ $(( $KEY_MOD & 4 )) = 4 && $KEY_SYM = [wW] ]] && echo true )">EXIT:quit</action>'
199
+
200
+	Gtkdialog_Snippet____Esc_to_Quit='
201
+<action signal="key-press-event" condition="command_is_true([ $KEY_VAL = 0xff1b ] && echo true )">EXIT:quit</action>'
202
+
203
+	GUI_BEING_BUILT+="$Gtkdialog_Snippet____Ctrl_W_to_Quit"
204
+	GUI_BEING_BUILT+="$Gtkdialog_Snippet____Esc_to_Quit"
205
+	
206
+
207
+	GUI_BEING_BUILT+='	</window>
208
+	'
209
+	retval="$GUI_BEING_BUILT"
210
+}
211
+readonly -f Build_GUI_Window
212
+
213
+# End of
214
+# Function
215
+############
216
+
217
+
218
+
219
+Build_GUI_Window
220
+
221
+GUI_Window="$retval"
222
+
223
+echo "$GUI_Window"
224
+
225
+
226
+
227
+List____Vars_to_Export=(
228
+		"Follpath____App_Versions_Home"
229
+		"EOL"
230
+		"Foldername____This_Script"
231
+		"App_Name"
232
+		"Note_Fillepath____Default_Version"
233
+)
234
+
235
+for string in "${List____Vars_to_Export[@]}"
236
+do
237
+	eval "export $string"
238
+done
239
+
240
+
241
+export -f Find_Versions
242
+export -f Possibly_Replace_Note____Default_Version
243
+export -f Possibly_Switch_to_App_Version
244
+
245
+export GUI_Window
246
+
247
+gtkdialog --center --program=GUI_Window
0 248
\ No newline at end of file