forked from WLAN-Pi/pkg-admin-tools
-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathpkg_admin.py
executable file
·193 lines (146 loc) · 4.9 KB
/
pkg_admin.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
#!/usr/bin/python3
# pylint: disable=line-too-long
from modules.wconsole import *
from modules.profiler import *
from modules.wlanpihotspot import *
from modules.installer_utils import *
from modules.wiperf import *
from modules.fpms import *
from modules.updater import *
from modules.bakebit import *
from modules.misc_build_files import *
import argparse
import requests
import sys
if not os.geteuid() == 0:
print("\n---------------------------------------------")
print(" You must be root to run this script")
print(" (use 'sudo script_installer.py') - exiting")
print("---------------------------------------------\n")
exit()
# read version file
this_version = read_file(updater_params['install_dir'] + "/version.txt")
# create parser args
parse_descr = "Package install utility for the WLAN Pi. \n"
parser = argparse.ArgumentParser(description=parse_descr)
# check we have passed args of some type
if len(sys.argv) < 2:
parser.print_usage()
sys.exit(1)
# setup parse args
parser.add_argument("-i", dest='install', type=str, metavar=('module'), choices=['bakebit', 'hotspot', 'profiler', 'wconsole', 'wiperf', 'fpms', 'pkg_admin', 'misc'], help="install module")
parser.add_argument("-r", dest='roll_back', type=str, metavar=('module'), choices=['bakebit', 'hotspot', 'profiler', 'wconsole', 'wiperf', 'fpms', 'pkg_admin', 'misc'], help="rollback module")
parser.add_argument("-d", dest='dev', action='store_true', help="install dev branch (used with -i option)")
parser.add_argument("-b", dest='branch', type=str, metavar=('branch_name'), help="install branch specific branch/release (used with -i option)")
parser.add_argument("-u", dest='update', action='store_true', help="update this utility with latest version")
parser.add_argument("-e", dest='empty_bin', action='store_true', help="empty recycle bin folder")
parser.add_argument("-v", action='version', version=this_version)
args = parser.parse_args()
print()
print("-" * 50)
print("Installer script started...")
branch = "master"
if args.dev:
branch = "dev"
if args.branch:
branch = args.branch
# empty recycle bin
if (args.empty_bin):
if not empty_recycle_bin():
exit()
# update util
if (args.update):
if updater_install(branch):
print("pkg-admin installed.")
else:
print("pkg-admin install failed.")
# hotspot
if (args.install == "hotspot"):
if hotspot_install(branch):
print("Hotspot installed.")
else:
print("Hotspot install failed.")
if (args.roll_back == "hotspot"):
if hotspot_rollback():
print("Hotspot rolled back.")
else:
print("Hotspot rollback failed.")
# profiler
if (args.install == "profiler"):
if profiler_install(branch):
print("Profiler installed.")
else:
print("Profiler install failed.")
if (args.roll_back == "profiler"):
if profiler_rollback():
print("Profiler rolled back.")
else:
print("Profiler rollback failed.")
# wconsole
if (args.install == "wconsole"):
if wconsole_install(branch):
print("wconsole installed.")
else:
print("wconsole install failed.")
if (args.roll_back == "wconsole"):
if wconsole_rollback():
print("wconsole rolled back.")
else:
print("wconsole rollback failed.")
# wiperf
if (args.install == "wiperf"):
if wiperf_install(branch):
print("wiperf installed.")
else:
print("wiperf install failed.")
if (args.roll_back == "wiperf"):
if wiperf_rollback():
print("wiperf rolled back.")
else:
print("wiperf rollback failed.")
# bakebit
if (args.install == "bakebit"):
if bakebit_install(branch):
print("bakebit installed.")
else:
print("bakebit install failed.")
if (args.roll_back == "bakebit"):
if bakebit_rollback():
print("bakebit rolled back.")
else:
print("bakebit rollback failed.")
# fpms
if (args.install == "fpms"):
if fpms_install(branch):
print("fpms installed.")
else:
print("fpms install failed.")
if (args.roll_back == "fpms"):
if fpms_rollback():
print("fpms rolled back.")
else:
print("fpms rollback failed.")
# misc_build_files
if (args.install == "misc"):
if misc_build_files_install(branch):
print("misc_build_files installed.")
else:
print("misc_build_files install failed.")
if (args.roll_back == "misc_build_files"):
if misc_build_files_rollback():
print("misc_build_files rolled back. (manual restoration of files to etc is required)")
else:
print("misc_build_files rollback failed.")
# pkg_admin
if (args.install == "pkg_admin"):
if updater_install(branch):
print("pkg_admin installed.")
else:
print("pkg_admin install failed.")
if (args.roll_back == "pkg_admin"):
if updater_rollback():
print("pkg_admin rolled back.")
else:
print("pkg_admin rollback failed.")
# end
print("-" * 50)