This repository has been archived by the owner on Feb 4, 2024. It is now read-only.
-
Notifications
You must be signed in to change notification settings - Fork 0
/
apiutaller.py
418 lines (367 loc) · 23.3 KB
/
apiutaller.py
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
#!/usr/bin/env python3
# LICENSE !!!!!
## Copyright (C) 2022 MuKonqi (Muhammed Abdurrahman)
## Apiutaller 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 3 of the License, or
## (at your option) any later version.
## Apiutaller 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 Apiutaller. If not, see <https://www.gnu.org/licenses/>.
# README !
## Dear developer,
### You can make comment lines if you want skip some steps.
### You must set up variables in apiutaller.py.
### In the README.md you must specify that the user should run the Apiutaller with root user.
# BENİOKU !
## Sevgili geliştirici,
### Bazı adımları atlamak istersiziz yorum satırları yapabilirsiniz.
### apiutaller.py'de değişkenleri ayarlamalısınız.
### README.md'de, kullanıcının Apiutaller'ı root kullanıcı ile çalıştırması gerektiğini belirtmelisiniz.
# Import necessary modules for Apiutaller!
import os
import time
import sys
from sys import platform
args=sys.argv[1:] # Don't change this variable!
lang="default" # Don't change this variable!
# VARIABLES !!!!!
## Don't forget to change and control them!
## Warning! You must use "" when you don't use any.
appname="TEAf" # Don't forget to change this! This is necessary for Apiutaller.
appfolder="/usr/bin/" # Don't forget to change this! This is necessary for Apiutaller.
appfileold="teaf.py" # Don't forget to change this! This is necessary for Apiutaller.
appfilenew="teaf" # Don't forget to change this! This is necessary for Apiutaller.
policyfile=any # Options: policy file and any
appdesktopfile=any # Options: desktop file and any
mainappfolder="/usr/local/bin/" # Options: Your way for your main app folder or any
mainappfoldername="teaf" # Options your main app folder for icon, modules etc. or any
licensename="Apache 2.0" # Don't forget to change this! This is necessary for Apiutaller.
appdev="MuKonqi" # Don't forget to change this! This is necessary for Apiutaller.
debian_apt_support="true" # Options: true and false
debian_apt_dependencies="python3" # Options: "dependencies" and any
fedora_dnf_support="true" # Options: true and false
fedora_dnf_dependencies="python3" # Options: "dependencies" and any
arch_pacman_support="true" # Options: true and false
arch_pacman_dependencies="python3" # Options: "dependencies" and any
opensuse_zypper_support="true" # Options: true and false
opensuse_zypper_dependencies="python" # Options: "dependencies" and any
rhel_yum_support="true"
rhel_yum_dependencies="python3"
solus_eopkg_support="true" # Options: true and false
solus_eopkg_dependencies="python3" # Options: "dependencies" and any
void_xbps_support="true" # Options: true and false
void_xbps_dependencies="python3" # Options: "dependencies" and any
pisi_pisi_support="true" # Options: true and false
pisi_pisi_dependencies="python3" # Options: "dependencies" and any
other_gnulinux_support="true" # Options: true and false
python_pip_dependencies=any # Options: "dependencies" and any
python3_pip3_dependencies=any # Options: "dependencies" and any
# Below is the version of Apiutaller.
Apiutaller="v1.5.1"
if not os.getuid() == 0:
exit("\nOnly root can run Apiutaller!\nSadece kök Apiutaller'i çalıştırabilir.\nShutting down... / Kapatılıyor...")
def main_install():
if python_pip_dependencies != any:
os.system("pip install "+python_pip_dependencies)
elif python3_pip3_dependencies != any:
os.system("pip3 install "+python3_pip3_dependencies)
os.system("chmod +x *")
if os.path.isdir(appfolder):
pass
else:
os.system("mkdir "+appfolder)
os.system("cd app ; chmod +x "+appfileold+" ; cp "+appfileold+" "+appfolder+appfilenew)
if os.path.isfile(appfolder+appfilenew):
if policyfile == any and appdesktopfile == any and mainappfolder == any and mainappfoldername == any:
if lang == "default" or lang == "en":
exit("Successful! You have "+appname+" at the moment. Thank you for choosing us!")
if lang == "default" or lang == "tr":
exit("Başarılı! Siz artık "+appname+" programına sahipsiniz. Bizi seçtiğiniz için teşekkürler!")
else:
if lang == "default" or lang == "en":
print("Error! This step is first. Apiutaller is shutting down...")
if lang == "default" or lang == "tr":
print("Hata! Bu adım birinci. Apiutaller kapatılıyor...")
if policyfile != any:
if os.path.isdir("/usr/share/polkit-1/actions"):
pass
else:
os.system("mkdir /usr/share/polkit-1/actions")
os.system("cd app ; chmod +x "+policyfile+" ; cp "+policyfile+" /usr/share/polkit-1/actions/")
if os.path.isfile("/usr/share/polkit-1/actions/"+policyfile):
if appdesktopfile == any and mainappfolder == any and mainappfoldername == any:
if lang == "default" or lang == "en":
exit("Successful! You have "+appname+" at the moment. Thank you for choosing us!")
if lang == "default" or lang == "tr":
exit("Başarılı! Siz artık "+appname+" programına sahipsiniz. Bizi seçtiğiniz için teşekkürler!")
else:
if lang == "default" or lang == "en":
exit("Error! This step is second. Apiutaller is shutting down...")
if lang == "default" or lang == "tr":
exit("Hata! Bu adım ikinci. Apiutaller kapatılıyor...")
if appdesktopfile != any:
if os.path.isdir("/usr/share/applications"):
pass
else:
os.system("mkdir /usr/share/applications")
os.system("cd app ; cp "+appdesktopfile+" /usr/share/applications")
if os.path.isfile("/usr/share/applications/"+appdesktopfile):
if mainappfolder == any and mainappfoldername == any:
if lang == "default" or lang == "en":
exit("Successful! You have "+appname+" at the moment. Thank you for choosing us!")
if lang == "default" or lang == "tr":
exit("Başarılı! Siz artık "+appname+" programına sahipsiniz. Bizi seçtiğiniz için teşekkürler!")
else:
if lang == "default" or lang == "en":
exit("Error! This step is third. Apiutaller is shutting down...")
if lang == "default" or lang == "tr":
exit("Hata! Bu adım üçüncü. Apiutaller kapatılıyor...")
if mainappfolder != any and mainappfoldername != any:
if os.path.isdir(mainappfolder):
pass
else:
if mainappfolder == "/usr/local/bin":
os.system("mkdir /usr/local ; mkdir /usr/local/bin/")
else:
os.system("mkdir "+mainappfolder)
os.system("mkdir "+mainappfolder+mainappfoldername)
os.system("cd app ; cp -r * "+mainappfolder+mainappfoldername)
if policyfile != any:
os.system("cd "+mainappfolder+mainappfoldername+" ; rm "+policyfile)
if appdesktopfile != any:
os.system("cd "+mainappfolder+mainappfoldername+" ; rm "+appdesktopfile)
os.system("cd "+mainappfolder+mainappfoldername+" ; rm "+appfileold)
os.system("mkdir "+mainappfolder+mainappfoldername+"/apiutaller")
os.system("cp apiutaller.py "+mainappfolder+mainappfoldername+"/apiutaller")
if os.path.isdir(mainappfolder+mainappfoldername):
if lang == "default" or lang == "en":
exit("Successful! You have "+appname+" at the moment. Thank you for choosing us!")
if lang == "default" or lang == "tr":
exit("Başarılı! Siz artık "+appname+" programına sahipsiniz. Bizi seçtiğiniz için teşekkürler!")
else:
if lang == "default" or lang == "en":
exit("Error! This step is last. Apiutaller is shutting down...")
if lang == "default" or lang == "tr":
exit("Hata! Bu adım sonuncu. Apiutaller kapatılıyor...")
def control_and_install():
if os.path.isfile("/etc/debian_version"):
if debian_apt_dependencies != any and debian_apt_support == "true":
os.system("apt install -y "+debian_apt_dependencies)
main_install()
elif debian_apt_dependencies == any and debian_apt_support == "true":
main_install()
elif debian_apt_support == "false":
if lang == "default" or lang == "en":
exit("I'm sorry, you can't use "+appname+"! Because your distro not supported from "+appname+".\nApiutaller is shutting down...")
if lang == "default" or lang == "tr":
exit("Üzgünüm, siz "+appname+" uygulamasını kullanamazsınız! Çünkü sizin dağıtımınız "+appname+" tarafından desteklenmiyor.\nApiutaller kapatılıyor...")
elif os.path.isfile("/etc/fedora-release"):
if fedora_dnf_dependencies != any and fedora_dnf_support == "true":
os.system("dnf install -y "+fedora_dnf_dependencies)
main_install()
elif fedora_dnf_dependencies == any and fedora_dnf_support == "true":
main_install()
elif fedora_dnf_support == "false":
if lang == "default" or lang == "en":
exit("I'm sorry, you can't use "+appname+"! Because your distro not supported from "+appname+".\nApiutaller is shutting down...")
if lang == "default" or lang == "tr":
exit("Üzgünüm, siz "+appname+" uygulamasını kullanamazsınız! Çünkü sizin dağıtımınız "+appname+" tarafından desteklenmiyor.\nApiutaller kapatılıyor...")
elif os.path.isfile("/bin/pacman") or os.path.isfile("/usr/bin/pacman"):
if arch_pacman_dependencies != any and arch_pacman_support == "true":
os.system("pacman -S -y "+arch_pacman_dependencies+" --noconfirm")
main_install()
elif arch_pacman_dependencies == any and arch_pacman_support == "true":
main_install()
elif arch_pacman_support == "false":
if lang == "default" or lang == "en":
exit("I'm sorry, you can't use "+appname+"! Because your distro not supported from "+appname+".\nApiutaller is shutting down...")
if lang == "default" or lang == "tr":
exit("Üzgünüm, siz "+appname+" uygulamasını kullanamazsınız! Çünkü sizin dağıtımınız "+appname+" tarafından desteklenmiyor.\nApiutaller kapatılıyor...")
elif os.path.isfile("/usr/bin/yum"):
if rhel_yum_dependencies != any and rhel_yum_support == "true":
os.system("yum install -y "+rhel_yum_dependencies)
main_install()
elif rhel_yum_dependencies == any and rhel_yum_support == "true":
main_install()
elif rhel_yum_support == "false":
if lang == "default" or lang == "en":
exit("I'm sorry, you can't use "+appname+"! Because your distro not supported from "+appname+".\nApiutaller is shutting down...")
if lang == "default" or lang == "tr":
exit("Üzgünüm, siz "+appname+" uygulamasını kullanamazsınız! Çünkü sizin dağıtımınız "+appname+" tarafından desteklenmiyor.\nApiutaller kapatılıyor...")
elif os.path.isfile("/usr/bin/zypper"):
if opensuse_zypper_dependencies != any and opensuse_zypper_support == "true":
os.system("zypper install --non-interactive "+opensuse_zypper_dependencies)
main_install()
elif opensuse_zypper_dependencies == any and opensuse_zypper_support == "true":
main_install()
elif opensuse_zypper_support == "false":
if lang == "default" or lang == "en":
exit("I'm sorry, you can't use "+appname+"! Because your distro not supported from "+appname+".\nApiutaller is shutting down...")
if lang == "default" or lang == "tr":
exit("Üzgünüm, siz "+appname+" uygulamasını kullanamazsınız! Çünkü sizin dağıtımınız "+appname+" tarafından desteklenmiyor.\nApiutaller kapatılıyor...")
elif os.path.isfile("/etc/solus-release"):
if solus_eopkg_dependencies != any and solus_eopkg_support == "true":
os.system("eopkg install -y "+solus_eopkg_dependencies)
main_install()
elif solus_eopkg_dependencies == any and solus_eopkg_support == "true":
main_install()
elif solus_eopkg_support == "false":
if lang == "default" or lang == "en":
exit("I'm sorry, you can't use "+appname+"! Because your distro not supported from "+appname+".\nApiutaller is shutting down...")
if lang == "default" or lang == "tr":
exit("Üzgünüm, siz "+appname+" uygulamasını kullanamazsınız! Çünkü sizin dağıtımınız "+appname+" tarafından desteklenmiyor.\nApiutaller kapatılıyor...")
elif os.path.isfile("/etc/pisilinux-release"):
if pisi_pisi_dependencies != any and pisi_pisi_support == "true":
os.system("pisi install -y "+pisi_pisi_dependencies)
main_install()
elif pisi_pisi_dependencies == any and pisi_pisi_support == "true":
main_install()
elif pisi_pisi_support == "false":
if lang == "default" or lang == "en":
exit("I'm sorry, you can't use "+appname+"! Because your distro not supported from "+appname+".\nApiutaller is shutting down...")
if lang == "default" or lang == "tr":
exit("Üzgünüm, siz "+appname+" uygulamasını kullanamazsınız! Çünkü sizin dağıtımınız "+appname+" tarafından desteklenmiyor.\nApiutaller kapatılıyor...")
elif os.path.isdir("/etc/xbps.d"):
if void_xbps_dependencies != any and void_xbps_support == "true":
os.system("xbps-install -y "+void_xbps_dependencies)
main_install()
elif void_xbps_dependencies == any and void_xbps_support == "true":
main_install()
elif void_xbps_support == "false":
if lang == "default" or lang == "en":
exit("I'm sorry, you can't use "+appname+"! Because your distro not supported from "+appname+".\nApiutaller is shutting down...")
if lang == "default" or lang == "tr":
exit("Üzgünüm, siz "+appname+" uygulamasını kullanamazsınız! Çünkü sizin dağıtımınız "+appname+" tarafından desteklenmiyor.\nApiutaller kapatılıyor...")
elif platform == "linux":
if other_gnulinux_support == "true":
main_install()
else:
if lang == "default" or lang == "en":
exit("I'm sorry, you can't use "+appname+"! Because your distro not supported from "+appname+".\nApiutaller is shutting down...")
if lang == "default" or lang == "tr":
exit("Üzgünüm, siz "+appname+" uygulamasını kullanamazsınız! Çünkü sizin dağıtımınız "+appname+" tarafından desteklenmiyor.\nApiutaller kapatılıyor...")
else:
if lang == "default" or lang == "en":
exit("I'm sorry, you can't use "+appname+"! Because your OS not supported from "+appname+".\nApiutaller is shutting down...")
if lang == "default" or lang == "tr":
exit("Üzgünüm, siz "+appname+" uygulamasını kullanamazsınız! Çünkü sizin İS'niz "+appname+" tarafından desteklenmiyor.\nApiutaller kapatılıyor...")
def main_uninstall():
os.system("cd "+appfolder+" ; rm "+appfilenew)
if os.path.isfile(appfolder+appfilenew):
if lang == "default" or lang == "en":
exit("Error! This step is first. Apiutaller is shutting down...")
if lang == "default" or lang == "tr":
exit("Hata! Bu adım birinci. Apiutaller kapatılıyor...")
else:
if policyfile == any and appdesktopfile == any and mainappfolder == any and mainappfoldername == any:
if lang == "default" or lang == "en":
exit("Successful! You haven't "+appname+" at the moment. We will be happy if you share the uninstalling reason with "+appdev+".")
if lang == "default" or lang == "tr":
exit("Başarılı! Siz artık "+appname+" uygulamasına sahip değilsiniz. Kaldırma sebebinizi "+appdev+" ile paylaşırsanız biz mutlu olacağız.")
if policyfile != any:
os.system("cd /usr/share/polkit-1/actions ; rm "+policyfile)
if os.path.isfile("/usr/share/polkit-1/actions/"+policyfile):
if lang == "default" or lang == "en":
exit("Error! This step is second. Apiutaller is shutting down...")
if lang == "default" or lang == "tr":
exit("Hata! Bu adım ikinci. Apiutaller kapatılıyor...")
else:
if appdesktopfile == any and mainappfolder == any and mainappfoldername == any:
if lang == "default" or lang == "en":
exit("Successful! You haven't "+appname+" at the moment. We will be happy if you share the uninstalling reason with "+appdev+".")
if lang == "default" or lang == "tr":
exit("Başarılı! Siz artık "+appname+" uygulamasına sahip değilsiniz. Kaldırma sebebinizi "+appdev+" ile paylaşırsanız biz mutlu olacağız.")
if appdesktopfile != any:
os.system("cd /usr/share/applications ; rm "+appdesktopfile)
if os.path.isfile("/usr/share/applications/"+appdesktopfile):
if lang == "default" or lang == "en":
exit("Error! This step is third. Apiutaller is shutting down...")
if lang == "default" or lang == "tr":
exit("Hata! Bu adım üçüncü. Apiutaller kapatılıyor...")
else:
if mainappfolder == any and mainappfoldername == any:
if lang == "default" or lang == "en":
exit("Successful! You haven't "+appname+" at the moment. We will be happy if you share the uninstalling reason with "+appdev+".")
if lang == "default" or lang == "tr":
exit("Başarılı! Siz artık "+appname+" uygulamasına sahip değilsiniz. Kaldırma sebebinizi "+appdev+" ile paylaşırsanız biz mutlu olacağız.")
if mainappfolder != any and mainappfoldername != any:
os.system("cd "+mainappfolder+" ; rm -rf "+mainappfoldername)
if os.path.isdir(mainappfolder+mainappfoldername):
if lang == "default" or lang == "en":
exit("Error! This step is last. Apiutaller is shutting down...")
if lang == "default" or lang == "tr":
exit("Hata! Bu adım sonuncu. Apiutaller kapatılıyor...")
else:
if lang == "default" or lang == "en":
exit("Successful! You haven't "+appname+" at the moment. We will be happy if you share the uninstalling reason with "+appdev+".")
if lang == "default" or lang == "tr":
exit("Başarılı! Siz artık "+appname+" uygulamasına sahip değilsiniz. Kaldırma sebebinizi "+appdev+" ile paylaşırsanız biz mutlu olacağız.")
def info():
if lang == "default" or lang == "en":
print("Welcome to Apiutaller "+Apiutaller+"!\nApiutaller is under the GPLv3 license.\nDeveloper of Apiutaller is MuKonqi (Muhammed Abdurrahman).")
ioa=input("What do you want to do at the moment?\nOptions: install (for "+appname+"), uninstall (for "+appname+"), exit\nAnswer: ")
if lang == "default" or lang == "tr":
print("Apiutaller "+Apiutaller+" programına hoşgeldiniz!\nApiutaller GPLv3 lisansı altındadır.\nApiutaller programının geliştiricisi MuKonqi (Muhammed Abdurrahman) idir.")
ioa=input("Şuan ne yapmak istersiniz?\nSeçenekler: kur ("+appname+" için), sil ("+appname+" için), çıkış\nCevap: ")
if ioa == "install" or ioa == "kur":
control_and_install()
if ioa == "uninstall" or ioa == "sil":
main_uninstall()
if ioa == "exit" or ioa == "çıkış":
if lang == "default" or lang == "en":
exit("Apiutaller is shutting down...")
if lang == "default" or lang == "tr":
exit("Apiutaller kapatılıyor...")
def operation():
if lang == "default" or lang == "en":
oa=input("What do you want to do?\nOptions: install (for "+appname+"), uninstall (for "+appname+"), info (for Apiutaller), exit\nAnswer: ")
elif lang == "default" or lang == "tr":
oa=input("Ne yapmak istersiniz?\nSeçenekler: kur ("+appname+" için), sil ("+appname+" için), hakkında (Apiutaller için), çıkış\nCevap: ")
if oa == "install" or oa == "kur":
control_and_install()
if oa == "uninstall" or oa == "sil":
main_uninstall()
if oa == "info" or oa == "hakkında":
info()
if oa == "exit" or oa == "çıkış":
if lang == "default" or lang == "en":
exit("Apiutaller is shutting down...")
if lang == "default" or lang == "tr":
exit("Apiutaller kapatılıyor...")
def license():
if lang == "default" or lang == "en":
license=input("Hello! I try installing or uninstalling "+appname+".\nI'm licensed with GPLv3!\n"+appname+" is under the "+licensename+"!\nDo you agree them?\nOptions: y or n\nAnswer: ")
if license == "y":
operation()
if license == "n":
exit("I'm sorry, you can't use "+appname+" and Apiutaller, because you don't agree licenses!\nApiutaller is shutting down...")
if lang == "default" or lang == "tr":
license=input("Merhabalar! Ben "+appname+" uygulamasını kurmayı ya da silmeyi deneyeceğim.\nBen GPLv3 ile lisanslıyım!\n"+appname+" ise "+licensename+" ile lisanslı!\nBunları kabul ediyor musunuz?\nSeçenekler: e ya da h\nCevap: ")
if license == "e":
operation()
if license == "h":
exit("Üzgünüm, siz "+appname+" ile Apiutaller'i kullanamazsınız, çünkü siz lisansları kabul etmediniz!\napuitaller kapatılıyor...")
if "--install" in args or "--kur" in args:
print("Copyright (C) 2022 MuKonqi (Muhammed Abdurrahman)")
print("If you do not press Ctrl+C within 12 seconds, the installation will start and you will be deemed to have accepted both the GPLv3 license used by Apiutaller and the "+licensename+" license used by the "+appname+" program.")
time.sleep(12)
control_and_install()
if "--uninstall" in args or "--sil" in args:
print("Copyright (C) 2022 MuKonqi (Muhammed Abdurrahman)")
print("If you do not press Ctrl+C within 12 seconds, the uninstallation will start and you will be deemed to have accepted both the GPLv3 license used by Apiutaller and the "+licensename+" license used by the "+appname+" program.")
time.sleep(12)
main_uninstall()
print("Copyright (C) 2022 MuKonqi (Muhammed Abdurrahman)")
language=input("Choose English or Turkish as a language.\nLütfen İngilizce veya Türkçeyi bir dil olarak seçiniz.\nOptions / Seçenekler: en / tr\nLanguage / Dil: ")
if lang == "default" and language == 'en':
lang="en"
print("English selected.")
license()
if lang == "default" and language == 'tr':
lang="tr"
print("Türkçe seçildi.")
license()