InPanel 1.2.1__py3-none-any.whl

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (198) hide show
  1. inpanel/__init__.py +29 -0
  2. inpanel/acme.py +289 -0
  3. inpanel/aliyuncs.py +269 -0
  4. inpanel/app.py +514 -0
  5. inpanel/apt.py +223 -0
  6. inpanel/base.py +200 -0
  7. inpanel/config.py +139 -0
  8. inpanel/data/config.ini +29 -0
  9. inpanel/data/history +5 -0
  10. inpanel/data/runlogs.ini +12 -0
  11. inpanel/data/update_info.ini +4 -0
  12. inpanel/dnf.py +225 -0
  13. inpanel/lib/__init__.py +9 -0
  14. inpanel/lib/async_process.py +98 -0
  15. inpanel/lib/filelock.py +82 -0
  16. inpanel/lib/magic.py +233 -0
  17. inpanel/lib/pxssh.py +310 -0
  18. inpanel/lib/pyDes.py +867 -0
  19. inpanel/mod/__init__.py +0 -0
  20. inpanel/mod/apt.py +316 -0
  21. inpanel/mod/certificate.py +268 -0
  22. inpanel/mod/config.py +372 -0
  23. inpanel/mod/cron.py +315 -0
  24. inpanel/mod/disk.py +322 -0
  25. inpanel/mod/dnf.py +239 -0
  26. inpanel/mod/file.py +722 -0
  27. inpanel/mod/firewall.py +199 -0
  28. inpanel/mod/firewall_base.py +137 -0
  29. inpanel/mod/firewall_firewalld.py +170 -0
  30. inpanel/mod/firewall_iptables.py +176 -0
  31. inpanel/mod/firewall_macos.py +213 -0
  32. inpanel/mod/firewall_ufw.py +128 -0
  33. inpanel/mod/ftp.py +231 -0
  34. inpanel/mod/httpd.py +1205 -0
  35. inpanel/mod/lighttpd.py +26 -0
  36. inpanel/mod/login.py +98 -0
  37. inpanel/mod/mysql.py +577 -0
  38. inpanel/mod/named.py +26 -0
  39. inpanel/mod/nginx.py +2327 -0
  40. inpanel/mod/package.py +33 -0
  41. inpanel/mod/package_apt.py +62 -0
  42. inpanel/mod/package_base.py +77 -0
  43. inpanel/mod/package_dnf.py +62 -0
  44. inpanel/mod/package_map.py +366 -0
  45. inpanel/mod/package_yum.py +64 -0
  46. inpanel/mod/php.py +289 -0
  47. inpanel/mod/process.py +291 -0
  48. inpanel/mod/proftpd.py +26 -0
  49. inpanel/mod/pureftpd.py +26 -0
  50. inpanel/mod/query.py +108 -0
  51. inpanel/mod/server.py +1319 -0
  52. inpanel/mod/service.py +262 -0
  53. inpanel/mod/setting.py +228 -0
  54. inpanel/mod/shell.py +78 -0
  55. inpanel/mod/ssh.py +280 -0
  56. inpanel/mod/system.py +220 -0
  57. inpanel/mod/task.py +1337 -0
  58. inpanel/mod/ufw.py +14 -0
  59. inpanel/mod/user.py +306 -0
  60. inpanel/mod/vsftpd.py +67 -0
  61. inpanel/mod/yum.py +243 -0
  62. inpanel/plugins/__init__.py +10 -0
  63. inpanel/plugins/__pycache__/__init__.cpython-313.pyc +0 -0
  64. inpanel/plugins/acme/static/index.html +10 -0
  65. inpanel/plugins/acme/static/index.js +13 -0
  66. inpanel/plugins/shadowsocks-libev/__pycache__/info.cpython-313.pyc +0 -0
  67. inpanel/plugins/shadowsocks-libev/info.py +73 -0
  68. inpanel/plugins/shadowsocks-libev/static/index.html +70 -0
  69. inpanel/plugins/shadowsocks-libev/static/index.js +18 -0
  70. inpanel/public/css/global.css +138 -0
  71. inpanel/public/favicon.ico +0 -0
  72. inpanel/public/images/alipay.jpg +0 -0
  73. inpanel/public/images/loading.gif +0 -0
  74. inpanel/public/images/weixin.jpg +0 -0
  75. inpanel/public/index.html +94 -0
  76. inpanel/public/js/controllers/controllers.js +566 -0
  77. inpanel/public/js/controllers/database.js +590 -0
  78. inpanel/public/js/controllers/ecs.js +624 -0
  79. inpanel/public/js/controllers/file.js +940 -0
  80. inpanel/public/js/controllers/plugins.js +105 -0
  81. inpanel/public/js/controllers/service.js +1460 -0
  82. inpanel/public/js/controllers/site.js +1241 -0
  83. inpanel/public/js/controllers/utils.js +2319 -0
  84. inpanel/public/js/core.js +221 -0
  85. inpanel/public/js/directives.js +784 -0
  86. inpanel/public/js/filters.js +395 -0
  87. inpanel/public/js/services.js +257 -0
  88. inpanel/public/lib/angular/1.0.2/angular-resource.min.js +10 -0
  89. inpanel/public/lib/angular/1.0.2/angular.min.js +158 -0
  90. inpanel/public/lib/bootstrap/css/bootstrap-theme.css +587 -0
  91. inpanel/public/lib/bootstrap/css/bootstrap-theme.css.map +1 -0
  92. inpanel/public/lib/bootstrap/css/bootstrap-theme.min.css +6 -0
  93. inpanel/public/lib/bootstrap/css/bootstrap-theme.min.css.map +1 -0
  94. inpanel/public/lib/bootstrap/css/bootstrap.css +6757 -0
  95. inpanel/public/lib/bootstrap/css/bootstrap.css.map +1 -0
  96. inpanel/public/lib/bootstrap/css/bootstrap.min.css +6 -0
  97. inpanel/public/lib/bootstrap/css/bootstrap.min.css.map +1 -0
  98. inpanel/public/lib/bootstrap/fonts/glyphicons-halflings-regular.eot +0 -0
  99. inpanel/public/lib/bootstrap/fonts/glyphicons-halflings-regular.svg +288 -0
  100. inpanel/public/lib/bootstrap/fonts/glyphicons-halflings-regular.ttf +0 -0
  101. inpanel/public/lib/bootstrap/fonts/glyphicons-halflings-regular.woff +0 -0
  102. inpanel/public/lib/bootstrap/fonts/glyphicons-halflings-regular.woff2 +0 -0
  103. inpanel/public/lib/bootstrap/img/glyphicons-halflings-white.png +0 -0
  104. inpanel/public/lib/bootstrap/img/glyphicons-halflings.png +0 -0
  105. inpanel/public/lib/bootstrap/js/bootstrap.js +2377 -0
  106. inpanel/public/lib/bootstrap/js/bootstrap.min.js +7 -0
  107. inpanel/public/lib/bootstrap/js/npm.js +13 -0
  108. inpanel/public/lib/codemirror/codemirror-compressed.js +1 -0
  109. inpanel/public/lib/codemirror/codemirror.css +173 -0
  110. inpanel/public/lib/jquery/jquery-1.12.4.min.js +5 -0
  111. inpanel/public/lib/md5/md5.js +379 -0
  112. inpanel/public/lib/md5/md5.min.js +1 -0
  113. inpanel/public/partials/database/index.html +172 -0
  114. inpanel/public/partials/database/mysql/dbedit.html +462 -0
  115. inpanel/public/partials/database/mysql/dbnew.html +348 -0
  116. inpanel/public/partials/database/mysql/useredit.html +310 -0
  117. inpanel/public/partials/database/mysql/usernew.html +97 -0
  118. inpanel/public/partials/directives/message.html +20 -0
  119. inpanel/public/partials/directives/navbar.html +25 -0
  120. inpanel/public/partials/directives/selector.html +57 -0
  121. inpanel/public/partials/directives/srvbase.html +72 -0
  122. inpanel/public/partials/directives/srvext.html +34 -0
  123. inpanel/public/partials/directives/srvfile.html +23 -0
  124. inpanel/public/partials/directives/srvinstall.html +34 -0
  125. inpanel/public/partials/directives/srvlog.html +23 -0
  126. inpanel/public/partials/directives/srvminiop.html +28 -0
  127. inpanel/public/partials/directives/srvuninstall.html +38 -0
  128. inpanel/public/partials/directives/srvupdate.html +30 -0
  129. inpanel/public/partials/ecs/account.html +156 -0
  130. inpanel/public/partials/ecs/ecs.html +198 -0
  131. inpanel/public/partials/ecs/index.html +40 -0
  132. inpanel/public/partials/ecs/setings.html +459 -0
  133. inpanel/public/partials/file/file.html +501 -0
  134. inpanel/public/partials/file/trash.html +95 -0
  135. inpanel/public/partials/ftp.html +36 -0
  136. inpanel/public/partials/log.html +83 -0
  137. inpanel/public/partials/login.html +79 -0
  138. inpanel/public/partials/logout.html +22 -0
  139. inpanel/public/partials/main.html +534 -0
  140. inpanel/public/partials/plugins/index.html +55 -0
  141. inpanel/public/partials/plugins/plugins.html +13 -0
  142. inpanel/public/partials/secure.html +13 -0
  143. inpanel/public/partials/service/apache.html +147 -0
  144. inpanel/public/partials/service/cron.html +71 -0
  145. inpanel/public/partials/service/index.html +293 -0
  146. inpanel/public/partials/service/iptables.html +40 -0
  147. inpanel/public/partials/service/lighttpd.html +63 -0
  148. inpanel/public/partials/service/mariadb.html +113 -0
  149. inpanel/public/partials/service/memcache.html +36 -0
  150. inpanel/public/partials/service/minio.html +44 -0
  151. inpanel/public/partials/service/mongodb.html +44 -0
  152. inpanel/public/partials/service/mysql.html +113 -0
  153. inpanel/public/partials/service/named.html +61 -0
  154. inpanel/public/partials/service/nginx.html +296 -0
  155. inpanel/public/partials/service/ntp.html +40 -0
  156. inpanel/public/partials/service/php.html +250 -0
  157. inpanel/public/partials/service/proftpd.html +59 -0
  158. inpanel/public/partials/service/pureftpd.html +59 -0
  159. inpanel/public/partials/service/redis.html +40 -0
  160. inpanel/public/partials/service/samba.html +58 -0
  161. inpanel/public/partials/service/sendmail.html +40 -0
  162. inpanel/public/partials/service/ssh.html +186 -0
  163. inpanel/public/partials/service/tomcat.html +65 -0
  164. inpanel/public/partials/service/vsftpd.html +195 -0
  165. inpanel/public/partials/setting.html +299 -0
  166. inpanel/public/partials/site/apache/site.html +277 -0
  167. inpanel/public/partials/site/index.html +344 -0
  168. inpanel/public/partials/site/nginx/site.html +558 -0
  169. inpanel/public/partials/sorry.html +19 -0
  170. inpanel/public/partials/storage/autofm.html +103 -0
  171. inpanel/public/partials/storage/backup.html +42 -0
  172. inpanel/public/partials/storage/index.html +360 -0
  173. inpanel/public/partials/storage/migrate.html +93 -0
  174. inpanel/public/partials/storage/movedata.html +98 -0
  175. inpanel/public/partials/storage/remote.html +77 -0
  176. inpanel/public/partials/utils/cron.html +486 -0
  177. inpanel/public/partials/utils/firewall.html +266 -0
  178. inpanel/public/partials/utils/index.html +193 -0
  179. inpanel/public/partials/utils/network.html +118 -0
  180. inpanel/public/partials/utils/process.html +239 -0
  181. inpanel/public/partials/utils/repository.html +373 -0
  182. inpanel/public/partials/utils/shell.html +28 -0
  183. inpanel/public/partials/utils/ssl.html +319 -0
  184. inpanel/public/partials/utils/time.html +109 -0
  185. inpanel/public/partials/utils/user.html +359 -0
  186. inpanel/public/robots.txt +2 -0
  187. inpanel/remote.py +109 -0
  188. inpanel/templates/file/preview.html +34 -0
  189. inpanel/templates/index.html +93 -0
  190. inpanel/utils.py +282 -0
  191. inpanel/web.py +1811 -0
  192. inpanel/yum.py +756 -0
  193. inpanel-1.2.1.dist-info/METADATA +399 -0
  194. inpanel-1.2.1.dist-info/RECORD +198 -0
  195. inpanel-1.2.1.dist-info/WHEEL +5 -0
  196. inpanel-1.2.1.dist-info/entry_points.txt +2 -0
  197. inpanel-1.2.1.dist-info/licenses/LICENSE +30 -0
  198. inpanel-1.2.1.dist-info/top_level.txt +1 -0
@@ -0,0 +1,1460 @@
1
+ var ServiceCtrl = [
2
+ '$scope', '$routeParams', 'Module', 'Timeout', 'Request', 'Backend',
3
+ function ($scope, $routeParams, Module, Timeout, Request, Backend) {
4
+ var module = 'service';
5
+ Module.init(module, '服务管理');
6
+ Module.initSection('http');
7
+ $scope.scope = $scope;
8
+ $scope.info = null;
9
+
10
+ $scope.loaded = false;
11
+ $scope.waiting = true;
12
+
13
+ $scope.loadInfo = function () {
14
+ Request.get('/api/query/server.virt,service.**', function (res) {
15
+ if (!$scope.loaded) $scope.loaded = true;
16
+ if ($scope.info == null) {
17
+ $scope.info = res;
18
+ } else {
19
+ deepUpdate($scope.info, res);
20
+ }
21
+ $scope.waiting = false;
22
+ //Timeout($scope.loadInfo, 1000, module);
23
+ });
24
+ };
25
+ $scope.toggleAutostart = function (name, service) {
26
+ var autostart = $scope.info['service.' + service]['autostart'];
27
+ Request.post('/api/operation/service', {
28
+ 'action': 'chkconfig',
29
+ 'name': name,
30
+ 'service': service,
31
+ 'autostart': !autostart
32
+ }, function () {
33
+ $scope.loadInfo();
34
+ });
35
+ };
36
+
37
+ var serviceop = function (action) {
38
+ return function (name, service) {
39
+ Backend.call(
40
+ $scope,
41
+ module,
42
+ '/api/backend/service_' + action,
43
+ '/api/backend/service_' + action + '_' + service, {
44
+ 'name': name,
45
+ 'service': service
46
+ },
47
+ $scope.loadInfo
48
+ );
49
+ };
50
+ };
51
+
52
+ $scope.start = serviceop('start');
53
+ $scope.stop = serviceop('stop');
54
+ $scope.restart = serviceop('restart');
55
+ }
56
+ ];
57
+
58
+ var ServiceNginxCtrl = [
59
+ '$scope', '$routeParams', 'Module', 'Request',
60
+ function ($scope, $routeParams, Module, Request) {
61
+ var module = 'service.nginx';
62
+ Module.init(module, 'Nginx');
63
+ Module.initSection('base');
64
+ $scope.scope = $scope;
65
+ $scope.info = null;
66
+ $scope.loaded = false;
67
+
68
+ $scope.installed = false;
69
+ $scope.waiting = true;
70
+ $scope.checking = false;
71
+
72
+ $scope.checkInstalled = function () {
73
+ $scope.checking = true;
74
+ Request.get('/api/query/service.nginx', function (res) {
75
+ var info = res['service.nginx'];
76
+ if (info) {
77
+ $scope.installed = true;
78
+ $scope.autostart = info.autostart;
79
+ $scope.status = info.status;
80
+ if ($scope.checkVersion) $scope.checkVersion();
81
+ $scope.getsettings();
82
+ $scope.getcachesettings();
83
+ } else {
84
+ $scope.installed = false;
85
+ }
86
+ $scope.loaded = true;
87
+ $scope.waiting = false;
88
+ $scope.checking = false;
89
+ });
90
+ Request.get('/api/client/ip', function (res) {
91
+ $scope.ip = res;
92
+ });
93
+ };
94
+
95
+ $scope.setting = {
96
+ 'limit_rate': '',
97
+ 'limit_conn': '',
98
+ 'limit_conn_zone': '',
99
+ 'client_max_body_size': '',
100
+ 'keepalive_timeout': '',
101
+ 'access_status': 'off',
102
+ 'allow': '',
103
+ 'deny': '',
104
+ 'gzip': ''
105
+ };
106
+
107
+ $scope.getsettings = function () {
108
+ if (!$scope.installed) return;
109
+ Request.post('/api/operation/nginx', {
110
+ 'action': 'gethttpsettings',
111
+ 'items': 'limit_rate,limit_conn,limit_conn_zone,client_max_body_size,keepalive_timeout,allow[],deny[],gzip'
112
+ }, function (res) {
113
+ if (res.code == 0) {
114
+ $scope.setting = res.data;
115
+ var s = $scope.setting;
116
+ if (s.allow && s.allow.length > 0) s.access_status = 'white';
117
+ else if (s.deny && s.deny.length > 0) s.access_status = 'black';
118
+ else s.access_status = 'off';
119
+ if (s.allow) s.allow = s.allow.join('\n');
120
+ if (s.deny) s.deny = s.deny.join('\n');
121
+ }
122
+ }, false, true);
123
+ };
124
+
125
+ $scope.savesettings = function () {
126
+ var data = angular.copy($scope.setting);
127
+ data.action = 'sethttpsettings';
128
+ data.version = $scope.pkginfo.version;
129
+ Request.post('/api/operation/nginx', data, function (res) {
130
+ if (res.code == 0) {
131
+ $scope.getsettings();
132
+ }
133
+ });
134
+ };
135
+
136
+ var cache_tmpl = {
137
+ 'name': 'newcache',
138
+ 'mem': '10',
139
+ 'path': '/var/www/cache',
140
+ 'path_level_1': '1',
141
+ 'path_level_2': '2',
142
+ 'path_level_3': '0',
143
+ 'inactive': '10',
144
+ 'inactive_unit': 'm',
145
+ 'max_size': '100',
146
+ 'max_size_unit': 'm',
147
+ 'autocreate': true
148
+ };
149
+ $scope.proxy_caches = [];
150
+ $scope.curcache = -1;
151
+ $scope.setcache = function (i) {
152
+ $scope.curcache = i;
153
+ };
154
+
155
+ $scope.getcachesettings = function () {
156
+ if (!$scope.installed) return;
157
+ Request.post('/api/operation/nginx', {
158
+ 'action': 'gethttpsettings',
159
+ 'items': 'proxy_cache_path[]'
160
+ }, function (res) {
161
+ if (res.code == 0) {
162
+ $scope.proxy_caches = [];
163
+ var ps = res.data.proxy_cache_path;
164
+ if (ps) {
165
+ for (var i = 0; i < ps.length; i++) {
166
+ var p = angular.copy(cache_tmpl);
167
+ angular.extend(p, ps[i]);
168
+ $scope.proxy_caches.push(p);
169
+ }
170
+ $scope.curcache = 0;
171
+ }
172
+ }
173
+ }, false, true);
174
+ };
175
+
176
+ $scope.deletecache = function (i) {
177
+ $scope.proxy_caches.splice(i, 1);
178
+ $scope.curcache--;
179
+ if ($scope.curcache < 0 && $scope.proxy_caches.length > 0) $scope.curcache = 0;
180
+ };
181
+ $scope.addcache = function () {
182
+ var caches = $scope.proxy_caches;
183
+ caches.splice($scope.curcache + 1, 0, angular.copy(cache_tmpl));
184
+ $scope.curcache++;
185
+ };
186
+ $scope.selectcachefolder = function (i) {
187
+ $scope.selector_title = '请选择缓存目录';
188
+ $scope.selector.onlydir = true;
189
+ $scope.selector.onlyfile = false;
190
+ $scope.selector.load($scope.proxy_caches[i].path);
191
+ $scope.selector.selecthandler = function (path) {
192
+ $('#selector').modal('hide');
193
+ $scope.proxy_caches[i].path = path;
194
+ };
195
+ $('#selector').modal();
196
+ };
197
+ $scope.savecaches = function () {
198
+ var data = {
199
+ 'action': 'setproxycachesettings',
200
+ 'proxy_caches': angular.toJson($scope.proxy_caches)
201
+ };
202
+ Request.post('/api/operation/nginx', data, function (res) {
203
+ if (res.code == 0) {
204
+ $scope.getcachesettings();
205
+ }
206
+ });
207
+ };
208
+ }
209
+ ];
210
+
211
+ var ServiceApacheCtrl = [
212
+ '$scope', '$routeParams', 'Module', 'Request',
213
+ function ($scope, $routeParams, Module, Request) {
214
+ var module = 'service.apache';
215
+ Module.init(module, 'Apache');
216
+ Module.initSection('base');
217
+ $scope.scope = $scope;
218
+ $scope.info = null;
219
+ $scope.loaded = false;
220
+
221
+ $scope.installed = false;
222
+ $scope.waiting = true;
223
+ $scope.checking = false;
224
+
225
+ $scope.checkInstalled = function () {
226
+ $scope.checking = true;
227
+ Request.get('/api/query/service.httpd', function (res) {
228
+ var info = res['service.httpd'];
229
+ if (info) {
230
+ $scope.installed = true;
231
+ $scope.autostart = info.autostart;
232
+ $scope.status = info.status;
233
+ if ($scope.checkVersion) $scope.checkVersion();
234
+ $scope.getSettings();
235
+ } else {
236
+ $scope.installed = false;
237
+ }
238
+ $scope.loaded = true;
239
+ $scope.waiting = false;
240
+ $scope.checking = false;
241
+ });
242
+ };
243
+
244
+ $scope.settings = {
245
+ 'Listen': 80,
246
+ 'ServerAdmin': 'root@localhost',
247
+ 'server_name': 'localhost:80',
248
+ 'DocumentRoot': '/var/www/html',
249
+ 'DirectoryIndex': 'index.html index.htm',
250
+ 'AddDefaultCharset': 'UTF-8',
251
+ 'limit_rate': '',
252
+ 'limit_conn': '',
253
+ 'limit_conn_zone': '',
254
+ 'client_max_body_size': '',
255
+ 'keepalive_timeout': '',
256
+ 'access_status': 'off',
257
+ 'allow': '',
258
+ 'deny': '',
259
+ 'Gzip': ''
260
+ };
261
+
262
+ $scope.getSettings = function () {
263
+ if (!$scope.installed) return;
264
+ Request.post('/api/operation/apache', {
265
+ 'action': 'get_settings',
266
+ 'items': 'limit_rate,limit_conn,limit_conn_zone,client_max_body_size,keepalive_timeout,allow[],deny[],gzip'
267
+ }, function (res) {
268
+ if (res.code == 0) {
269
+ $scope.settings = res.data;
270
+ var s = $scope.settings;
271
+ if (s.allow && s.allow.length > 0) s.access_status = 'white';
272
+ else if (s.deny && s.deny.length > 0) s.access_status = 'black';
273
+ else s.access_status = 'off';
274
+ if (s.allow) s.allow = s.allow.join('\n');
275
+ if (s.deny) s.deny = s.deny.join('\n');
276
+ }
277
+ }, false, true);
278
+ };
279
+
280
+ $scope.updateSettings = function () {
281
+ console.log('updateSettings Apache')
282
+ // var data = angular.copy($scope.settings);
283
+ // data.action = 'sethttpsettings';
284
+ // data.version = $scope.pkginfo.version;
285
+ // Request.post('/api/operation/apache', data, function (res) {
286
+ // if (res.code == 0) {
287
+ // $scope.getSettings();
288
+ // }
289
+ // });
290
+ };
291
+ }
292
+ ];
293
+
294
+ var ServiceTomcatCtrl = [
295
+ '$scope', '$routeParams', 'Module', 'Request',
296
+ function ($scope, $routeParams, Module, Request) {
297
+ var module = 'service.tomcat';
298
+ Module.init(module, 'Tomcat');
299
+ Module.initSection('base');
300
+ $scope.scope = $scope;
301
+ $scope.info = null;
302
+ $scope.loaded = false;
303
+
304
+ $scope.installed = false;
305
+ $scope.waiting = true;
306
+ $scope.checking = false;
307
+
308
+ $scope.checkInstalled = function () {
309
+ $scope.checking = true;
310
+ Request.get('/api/query/service.tomcat', function (res) {
311
+ var info = res['service.tomcat'];
312
+ if (info) {
313
+ $scope.installed = true;
314
+ $scope.autostart = info.autostart;
315
+ $scope.status = info.status;
316
+ if ($scope.checkVersion) $scope.checkVersion();
317
+ $scope.getsettings();
318
+ } else {
319
+ $scope.installed = false;
320
+ }
321
+ $scope.loaded = true;
322
+ $scope.waiting = false;
323
+ $scope.checking = false;
324
+ });
325
+ };
326
+
327
+ $scope.setting = {
328
+ 'limit_rate': '',
329
+ 'limit_conn': '',
330
+ 'limit_conn_zone': '',
331
+ 'client_max_body_size': '',
332
+ 'keepalive_timeout': '',
333
+ 'access_status': 'off',
334
+ 'allow': '',
335
+ 'deny': '',
336
+ 'gzip': ''
337
+ };
338
+
339
+ $scope.getsettings = function () {
340
+ if (!$scope.installed) return;
341
+ Request.post('/api/operation/apache', {
342
+ 'action': 'gethttpsettings',
343
+ 'items': 'limit_rate,limit_conn,limit_conn_zone,client_max_body_size,keepalive_timeout,allow[],deny[],gzip'
344
+ }, function (res) {
345
+ if (res.code == 0) {
346
+ $scope.setting = res.data;
347
+ }
348
+ }, false, true);
349
+ };
350
+
351
+ $scope.savesettings = function () {
352
+ var data = angular.copy($scope.setting);
353
+ data.action = 'sethttpsettings';
354
+ data.version = $scope.pkginfo.version;
355
+ Request.post('/api/operation/nginx', data, function (res) {
356
+ if (res.code == 0) {
357
+ $scope.getsettings();
358
+ }
359
+ });
360
+ };
361
+ }
362
+ ];
363
+
364
+ var ServiceVsftpdCtrl = [
365
+ '$scope', '$routeParams', 'Module', 'Request',
366
+ function ($scope, $routeParams, Module, Request) {
367
+ var module = 'service.vsftpd';
368
+ Module.init(module, 'vsftpd');
369
+ Module.initSection('base');
370
+ $scope.scope = $scope;
371
+ $scope.info = null;
372
+ $scope.loaded = false;
373
+
374
+ $scope.installed = false;
375
+ $scope.waiting = true;
376
+ $scope.checking = false;
377
+
378
+ $scope.checkInstalled = function () {
379
+ $scope.checking = true;
380
+ Request.get('/api/query/service.vsftpd', function (res) {
381
+ var info = res['service.vsftpd'];
382
+ if (info) {
383
+ $scope.installed = true;
384
+ $scope.autostart = info.autostart;
385
+ $scope.status = info.status;
386
+ $scope.getsettings();
387
+ if ($scope.checkVersion) {
388
+ $scope.checkVersion();
389
+ }
390
+ } else {
391
+ $scope.installed = false;
392
+ }
393
+ $scope.loaded = true;
394
+ $scope.waiting = false;
395
+ $scope.checking = false;
396
+ });
397
+ };
398
+
399
+ $scope.getsettings = function () {
400
+ Request.post('/api/operation/vsftpd', {
401
+ 'action': 'getsettings'
402
+ }, function (data) {
403
+ if (data.code == 0) {
404
+ $scope.baseconfigs = data.data;
405
+ }
406
+ });
407
+ };
408
+
409
+ $scope.savesettings = function () {
410
+ $scope.processing = true;
411
+ Request.post('/api/operation/vsftpd', {
412
+ 'action': 'savesettings',
413
+ 'anonymous_enable': $scope.baseconfigs.anonymous_enable,
414
+ 'local_enable': $scope.baseconfigs.local_enable,
415
+ 'local_umask': $scope.baseconfigs.local_umask,
416
+ 'anon_upload_enable': $scope.baseconfigs.anon_upload_enable,
417
+ 'anon_mkdir_write_enable': $scope.baseconfigs.anon_mkdir_write_enable,
418
+ 'dirmessage_enable': $scope.baseconfigs.dirmessage_enable,
419
+ 'xferlog_enable': $scope.baseconfigs.xferlog_enable,
420
+ 'connect_from_port_20': $scope.baseconfigs.connect_from_port_20,
421
+ 'chown_upload': $scope.baseconfigs.chown_upload,
422
+ 'chown_username': $scope.baseconfigs.chown_username,
423
+ 'xferlog_file': $scope.baseconfigs.xferlog_file,
424
+ 'xferlog_std_format': $scope.baseconfigs.xferlog_std_format,
425
+ 'idle_session_timeout': $scope.baseconfigs.idle_session_timeout,
426
+ 'data_connection_timeout': $scope.baseconfigs.data_connection_timeout,
427
+ 'nopriv_user': $scope.baseconfigs.nopriv_user,
428
+ 'async_abor_enable': $scope.baseconfigs.async_abor_enable,
429
+ 'ascii_upload_enable': $scope.baseconfigs.ascii_upload_enable,
430
+ 'ascii_download_enable': $scope.baseconfigs.ascii_download_enable,
431
+ 'ftpd_banner': $scope.baseconfigs.ftpd_banner,
432
+ 'deny_email_enable': $scope.baseconfigs.deny_email_enable,
433
+ 'banned_email_file': $scope.baseconfigs.banned_email_file,
434
+ 'chroot_list_enable': $scope.baseconfigs.chroot_list_enable,
435
+ 'chroot_list_file': $scope.baseconfigs.chroot_list_file,
436
+ 'max_clients': $scope.baseconfigs.max_clients,
437
+ 'message_file': $scope.baseconfigs.message_file
438
+ }, function (data) {
439
+ if (data.code == 0) {
440
+ $scope.getsettings();
441
+ }
442
+ $scope.processing = false;
443
+ });
444
+ };
445
+ }
446
+ ];
447
+
448
+ var ServiceMySQLCtrl = [
449
+ '$scope', '$rootScope', '$routeParams', 'Module', 'Message', 'Request', 'Backend',
450
+ function ($scope, $rootScope, $routeParams, Module, Message, Request, Backend) {
451
+ var module = 'service.mysqld';
452
+ Module.init(module, 'MySQL');
453
+ Module.initSection('base');
454
+ $scope.scope = $scope;
455
+ $scope.info = null;
456
+ $scope.loaded = false;
457
+
458
+ $scope.installed = false;
459
+ $scope.waiting = true;
460
+ $scope.checking = false;
461
+ $scope.processing = false;
462
+
463
+ $scope.checkInstalled = function () {
464
+ $scope.checking = true;
465
+ Request.get('/api/query/service.mysqld', function (res) {
466
+ var info = res['service.mysqld'];
467
+ if (info) {
468
+ $scope.installed = true;
469
+ $scope.autostart = info.autostart;
470
+ $scope.status = info.status;
471
+ if ($scope.checkVersion) $scope.checkVersion();
472
+ } else {
473
+ $scope.installed = false;
474
+ }
475
+ $scope.loaded = true;
476
+ $scope.waiting = false;
477
+ $scope.checking = false;
478
+ });
479
+ };
480
+
481
+ $scope.updatepwd = function () {
482
+ if ($scope.status != 'running') {
483
+ Message.setError('MySQL还未启动,无法修改密码!');
484
+ return;
485
+ }
486
+ $scope.processing = true;
487
+ Request.post('/api/operation/mysql', {
488
+ 'action': 'updatepwd',
489
+ 'newpassword': $scope.root_passwd,
490
+ 'newpasswordc': $scope.root_passwdc,
491
+ 'password': $scope.root_opasswd
492
+ }, function (res) {
493
+ if (res.code == 0) {
494
+ $scope.root_passwd = '';
495
+ $scope.root_passwdc = '';
496
+ $scope.root_opasswd = '';
497
+ // reset cached mysql password
498
+ $rootScope.$mysql = {
499
+ 'password': '',
500
+ 'password_validated': false
501
+ };
502
+ }
503
+ $scope.processing = false;
504
+ });
505
+ };
506
+
507
+ $scope.fupdatepwd = function () {
508
+ $scope.processing = true;
509
+ Backend.call(
510
+ $scope,
511
+ module,
512
+ '/api/backend/mysql_fupdatepwd',
513
+ '/api/backend/mysql_fupdatepwd', {
514
+ 'password': $scope.root_passwd,
515
+ 'passwordc': $scope.root_passwdc
516
+ },
517
+ function (res) {
518
+ if (res.code == 0) {
519
+ $scope.root_passwd = '';
520
+ $scope.root_passwdc = '';
521
+ // reset cached mysql password
522
+ $rootScope.$mysql = {
523
+ 'password': '',
524
+ 'password_validated': false
525
+ };
526
+ }
527
+ $scope.processing = false;
528
+ }
529
+ );
530
+ };
531
+ }
532
+ ];
533
+
534
+ var ServiceMariaDBCtrl = [
535
+ '$scope', '$rootScope', '$routeParams', 'Module', 'Message', 'Request', 'Backend',
536
+ function ($scope, $rootScope, $routeParams, Module, Message, Request, Backend) {
537
+ var module = 'service.mariadb';
538
+ Module.init(module, 'MariaDB');
539
+ Module.initSection('base');
540
+ $scope.scope = $scope;
541
+ $scope.info = null;
542
+ $scope.loaded = false;
543
+
544
+ $scope.installed = false;
545
+ $scope.waiting = true;
546
+ $scope.checking = false;
547
+ $scope.processing = false;
548
+
549
+ $scope.checkInstalled = function () {
550
+ $scope.checking = true;
551
+ Request.get('/api/query/service.mariadb', function (res) {
552
+ var info = res['service.mariadb'];
553
+ if (info) {
554
+ $scope.installed = true;
555
+ $scope.autostart = info.autostart;
556
+ $scope.status = info.status;
557
+ if ($scope.checkVersion) $scope.checkVersion();
558
+ } else {
559
+ $scope.installed = false;
560
+ }
561
+ $scope.loaded = true;
562
+ $scope.waiting = false;
563
+ $scope.checking = false;
564
+ });
565
+ };
566
+
567
+ $scope.updatepwd = function () {
568
+ if ($scope.status != 'running') {
569
+ Message.setError('MariaDB 还未启动,无法修改密码!');
570
+ return;
571
+ }
572
+ $scope.processing = true;
573
+ Request.post('/api/operation/mariadb', {
574
+ 'action': 'updatepwd',
575
+ 'newpassword': $scope.root_passwd,
576
+ 'newpasswordc': $scope.root_passwdc,
577
+ 'password': $scope.root_opasswd
578
+ }, function (res) {
579
+ if (res.code == 0) {
580
+ $scope.root_passwd = '';
581
+ $scope.root_passwdc = '';
582
+ $scope.root_opasswd = '';
583
+ // reset cached mariadb password
584
+ $rootScope.$mariadb = {
585
+ 'password': '',
586
+ 'password_validated': false
587
+ };
588
+ }
589
+ $scope.processing = false;
590
+ });
591
+ };
592
+
593
+ $scope.fupdatepwd = function () {
594
+ $scope.processing = true;
595
+ Backend.call(
596
+ $scope,
597
+ module,
598
+ '/api/backend/mysql_fupdatepwd',
599
+ '/api/backend/mysql_fupdatepwd', {
600
+ 'password': $scope.root_passwd,
601
+ 'passwordc': $scope.root_passwdc
602
+ },
603
+ function (res) {
604
+ if (res.code == 0) {
605
+ $scope.root_passwd = '';
606
+ $scope.root_passwdc = '';
607
+ // reset cached mysql password
608
+ $rootScope.$mariadb = {
609
+ 'password': '',
610
+ 'password_validated': false
611
+ };
612
+ }
613
+ $scope.processing = false;
614
+ }
615
+ );
616
+ };
617
+ }
618
+ ];
619
+
620
+ var ServiceRedisCtrl = [
621
+ '$scope', '$routeParams', 'Module', 'Request',
622
+ function ($scope, $routeParams, Module, Request) {
623
+ var module = 'service.redis';
624
+ Module.init(module, 'Redis');
625
+ Module.initSection('base');
626
+ $scope.scope = $scope;
627
+ $scope.info = null;
628
+ $scope.loaded = false;
629
+
630
+ $scope.installed = false;
631
+ $scope.waiting = true;
632
+ $scope.checking = false;
633
+
634
+ $scope.checkInstalled = function () {
635
+ $scope.checking = true;
636
+ Request.get('/api/query/service.redis', function (res) {
637
+ var info = res['service.redis'];
638
+ if (info) {
639
+ $scope.installed = true;
640
+ $scope.autostart = info.autostart;
641
+ $scope.status = info.status;
642
+ if ($scope.checkVersion) $scope.checkVersion();
643
+ } else {
644
+ $scope.installed = false;
645
+ }
646
+ $scope.loaded = true;
647
+ $scope.waiting = false;
648
+ $scope.checking = false;
649
+ });
650
+ };
651
+ }
652
+ ];
653
+
654
+ var ServiceMemcacheCtrl = [
655
+ '$scope', '$routeParams', 'Module', 'Request',
656
+ function ($scope, $routeParams, Module, Request) {
657
+ var module = 'service.memcache';
658
+ Module.init(module, 'Memcache');
659
+ Module.initSection('base');
660
+ $scope.scope = $scope;
661
+ $scope.info = null;
662
+ $scope.loaded = false;
663
+
664
+ $scope.installed = false;
665
+ $scope.waiting = true;
666
+ $scope.checking = false;
667
+
668
+ $scope.checkInstalled = function () {
669
+ $scope.checking = true;
670
+ Request.get('/api/query/service.memcached', function (res) {
671
+ var info = res['service.memcached'];
672
+ if (info) {
673
+ $scope.installed = true;
674
+ $scope.autostart = info.autostart;
675
+ $scope.status = info.status;
676
+ if ($scope.checkVersion) $scope.checkVersion();
677
+ } else {
678
+ $scope.installed = false;
679
+ }
680
+ $scope.loaded = true;
681
+ $scope.waiting = false;
682
+ $scope.checking = false;
683
+ });
684
+ };
685
+ }
686
+ ];
687
+
688
+ var ServiceMongoDBCtrl = [
689
+ '$scope', '$routeParams', 'Module', 'Request',
690
+ function ($scope, $routeParams, Module, Request) {
691
+ var module = 'service.mongodb';
692
+ Module.init(module, 'MongoDB');
693
+ Module.initSection('base');
694
+ $scope.scope = $scope;
695
+ $scope.info = null;
696
+ $scope.loaded = false;
697
+
698
+ $scope.installed = false;
699
+ $scope.waiting = true;
700
+ $scope.checking = false;
701
+
702
+ $scope.checkInstalled = function () {
703
+ $scope.checking = true;
704
+ Request.get('/api/query/service.mongod', function (res) {
705
+ var info = res['service.mongod'];
706
+ if (info) {
707
+ $scope.installed = true;
708
+ $scope.autostart = info.autostart;
709
+ $scope.status = info.status;
710
+ if ($scope.checkVersion) $scope.checkVersion();
711
+ } else {
712
+ $scope.installed = false;
713
+ }
714
+ $scope.loaded = true;
715
+ $scope.waiting = false;
716
+ $scope.checking = false;
717
+ });
718
+ };
719
+ }
720
+ ];
721
+ var ServiceMinIOCtrl = [
722
+ '$scope', '$routeParams', 'Module', 'Request',
723
+ function ($scope, $routeParams, Module, Request) {
724
+ var module = 'service.minio';
725
+ Module.init(module, 'MinIO');
726
+ Module.initSection('base');
727
+ $scope.scope = $scope;
728
+ $scope.info = null;
729
+ $scope.loaded = false;
730
+
731
+ $scope.installed = false;
732
+ $scope.waiting = true;
733
+ $scope.checking = false;
734
+
735
+ $scope.checkInstalled = function () {
736
+ $scope.checking = true;
737
+ Request.get('/api/query/service.minio', function (res) {
738
+ var info = res['service.minio'];
739
+ if (info) {
740
+ $scope.installed = true;
741
+ $scope.autostart = info.autostart;
742
+ $scope.status = info.status;
743
+ if ($scope.checkVersion) $scope.checkVersion();
744
+ } else {
745
+ $scope.installed = false;
746
+ }
747
+ $scope.loaded = true;
748
+ $scope.waiting = false;
749
+ $scope.checking = false;
750
+ });
751
+ };
752
+ }
753
+ ];
754
+ var ServicePHPCtrl = [
755
+ '$scope', '$routeParams', 'Module', 'Request',
756
+ function ($scope, $routeParams, Module, Request) {
757
+ var module = 'service.php';
758
+ Module.init(module, 'PHP');
759
+ Module.initSection('base');
760
+ $scope.scope = $scope;
761
+ $scope.info = null;
762
+ $scope.loaded = false;
763
+
764
+ $scope.installed = false;
765
+ $scope.waiting = true;
766
+ $scope.checking = false;
767
+
768
+ $scope.checkInstalled = function () {
769
+ $scope.checking = true;
770
+ Request.get('/api/query/service.php-fpm', function (res) {
771
+ var info = res['service.php-fpm'];
772
+ if (info) {
773
+ $scope.installed = true;
774
+ $scope.autostart = info.autostart;
775
+ $scope.status = info.status;
776
+ if ($scope.checkVersion) $scope.checkVersion();
777
+ $scope.getphpsettings();
778
+ $scope.getfpmsettings();
779
+ } else {
780
+ $scope.installed = false;
781
+ }
782
+ $scope.loaded = true;
783
+ $scope.waiting = false;
784
+ $scope.checking = false;
785
+ });
786
+ };
787
+
788
+ $scope.setting = {
789
+ 'php': {
790
+ 'short_open_tag': false,
791
+ 'expose_php': false,
792
+ 'max_execution_time': '',
793
+ 'memory_limit': '',
794
+ 'display_errors': false,
795
+ 'post_max_size': '',
796
+ 'upload_max_filesize': '',
797
+ 'date.timezone': ''
798
+ },
799
+ 'fpm': {
800
+ 'listen': '',
801
+ 'pm': false,
802
+ 'pm.max_children': '',
803
+ 'pm.start_servers': '',
804
+ 'pm.min_spare_servers': '',
805
+ 'pm.max_spare_servers': '',
806
+ 'pm.max_requests': '',
807
+ 'request_terminate_timeout': '',
808
+ 'request_slowlog_timeout': ''
809
+ }
810
+ };
811
+
812
+ var _toint = function (v) {
813
+ v = parseInt(v);
814
+ if (isNaN(v))
815
+ v = '';
816
+ else
817
+ v += '';
818
+ return v;
819
+ };
820
+
821
+ $scope.getphpsettings = function () {
822
+ if (!$scope.installed) return;
823
+ Request.post('/api/operation/php', {
824
+ 'action': 'getphpsettings'
825
+ }, function (res) {
826
+ if (res.code == 0) {
827
+ var s = res.data;
828
+ var d = $scope.setting['php'];
829
+ d['short_open_tag'] = (s['short_open_tag'] && s['short_open_tag'].toLowerCase() == 'on');
830
+ d['expose_php'] = (s['expose_php'] && s['expose_php'].toLowerCase() == 'on');
831
+ d['max_execution_time'] = s['max_execution_time'] ? s['max_execution_time'] : '';
832
+ d['memory_limit'] = s['memory_limit'] ? _toint(s['memory_limit']) : '';
833
+ d['display_errors'] = (s['display_errors'] && s['display_errors'].toLowerCase() == 'on');
834
+ d['post_max_size'] = s['post_max_size'] ? _toint(s['post_max_size']) : '';
835
+ d['upload_max_filesize'] = s['upload_max_filesize'] ? _toint(s['upload_max_filesize']) : '';
836
+ d['date.timezone'] = s['date.timezone'] ? s['date.timezone'] : '';
837
+ }
838
+ }, false, true);
839
+ };
840
+
841
+ $scope.getfpmsettings = function () {
842
+ if (!$scope.installed) return;
843
+ Request.post('/api/operation/php', {
844
+ 'action': 'getfpmsettings'
845
+ }, function (res) {
846
+ if (res.code == 0) {
847
+ var s = res.data;
848
+ var d = $scope.setting['fpm'];
849
+ d['listen'] = s['listen'] ? s['listen'] : '';
850
+ d['pm'] = (s['pm'] && s['pm'].toLowerCase() == 'dynamic');
851
+ d['pm.max_children'] = s['pm.max_children'] ? _toint(s['pm.max_children']) : '';
852
+ d['pm.start_servers'] = s['pm.start_servers'] ? _toint(s['pm.start_servers']) : '';
853
+ d['pm.min_spare_servers'] = s['pm.min_spare_servers'] ? _toint(s['pm.min_spare_servers']) : '';
854
+ d['pm.max_spare_servers'] = s['pm.max_spare_servers'] ? _toint(s['pm.max_spare_servers']) : '';
855
+ d['pm.max_requests'] = s['pm.max_requests'] ? _toint(s['pm.max_requests']) : '';
856
+ d['request_terminate_timeout'] = s['request_terminate_timeout'] ? _toint(s['request_terminate_timeout']) : '';
857
+ d['request_slowlog_timeout'] = s['request_slowlog_timeout'] ? _toint(s['request_slowlog_timeout']) : '';
858
+ }
859
+ }, false, true);
860
+ };
861
+
862
+ $scope.updatephpsettings = function () {
863
+ var data = angular.copy($scope.setting.php);
864
+ data.action = 'updatephpsettings';
865
+ Request.post('/api/operation/php', data, $scope.getphpsettings);
866
+ };
867
+ $scope.updatefpmsettings = function () {
868
+ var data = angular.copy($scope.setting.fpm);
869
+ data.action = 'updatefpmsettings';
870
+ Request.post('/api/operation/php', data, $scope.getfpmsettings);
871
+ };
872
+ }
873
+ ];
874
+
875
+ var ServiceSendmailCtrl = [
876
+ '$scope', '$routeParams', 'Module', 'Request',
877
+ function ($scope, $routeParams, Module, Request) {
878
+ var module = 'service.sendmail';
879
+ Module.init(module, 'Sendmail');
880
+ Module.initSection('base');
881
+ $scope.scope = $scope;
882
+ $scope.info = null;
883
+ $scope.loaded = false;
884
+
885
+ $scope.installed = false;
886
+ $scope.waiting = true;
887
+ $scope.checking = false;
888
+
889
+ $scope.checkInstalled = function () {
890
+ $scope.checking = true;
891
+ Request.get('/api/query/service.sendmail', function (res) {
892
+ var info = res['service.sendmail'];
893
+ if (info) {
894
+ $scope.installed = true;
895
+ $scope.autostart = info.autostart;
896
+ $scope.status = info.status;
897
+ if ($scope.checkVersion) $scope.checkVersion();
898
+ } else {
899
+ $scope.installed = false;
900
+ }
901
+ $scope.loaded = true;
902
+ $scope.waiting = false;
903
+ $scope.checking = false;
904
+ });
905
+ };
906
+ }
907
+ ];
908
+
909
+ var ServiceSSHCtrl = [
910
+ '$scope', '$routeParams', 'Module', 'Request', 'Backend', 'Message',
911
+ function ($scope, $routeParams, Module, Request, Backend, Message) {
912
+ var module = 'service.ssh';
913
+ Module.init(module, 'SSH');
914
+ Module.initSection('base');
915
+ $scope.scope = $scope;
916
+ $scope.info = null;
917
+ $scope.loaded = false;
918
+
919
+ $scope.installed = false;
920
+ $scope.waiting = true;
921
+ $scope.checking = false;
922
+
923
+ $scope.checkInstalled = function () {
924
+ $scope.checking = true;
925
+ Request.get('/api/query/service.sshd', function (res) {
926
+ var info = res['service.sshd'];
927
+ if (info) {
928
+ $scope.installed = true;
929
+ $scope.autostart = info.autostart;
930
+ $scope.status = info.status;
931
+ $scope.getsettings();
932
+ if ($scope.checkVersion) $scope.checkVersion();
933
+ } else {
934
+ $scope.installed = false;
935
+ }
936
+ $scope.loaded = true;
937
+ $scope.waiting = false;
938
+ $scope.checking = false;
939
+ });
940
+ };
941
+
942
+ $scope.setting = {};
943
+ $scope.getsettings = function () {
944
+ if (!$scope.installed) return;
945
+ Request.post('/api/operation/ssh', {
946
+ 'action': 'getsettings'
947
+ }, function (res) {
948
+ if (res.code == 0) {
949
+ $scope.setting = res.data;
950
+ $scope.setting.disable_pwdauth = !$scope.setting.enable_pwdauth;
951
+ }
952
+ }, false, true);
953
+ };
954
+ $scope.savesettings = function () {
955
+ var data = {};
956
+ data.action = 'savesettings';
957
+ data.port = $scope.setting.port;
958
+ data.enable_pwdauth = $scope.setting.enable_pwdauth;
959
+ data.enable_sftp = $scope.setting.enable_sftp;
960
+ Request.post('/api/operation/ssh', data, function (res) {
961
+ if (res.code == 0) {
962
+ $scope.getsettings();
963
+ }
964
+ });
965
+ };
966
+ $scope.savepksettings = function () {
967
+ var data = {};
968
+ data.action = 'savesettings';
969
+ data.pubkey = $scope.setting.pubkey;
970
+ data.enable_pubkauth = $scope.setting.enable_pubkauth;
971
+ data.enable_pwdauth = !$scope.setting.disable_pwdauth;
972
+ Request.post('/api/operation/ssh', data, function (res) {
973
+ if (res.code == 0) {
974
+ $scope.getsettings();
975
+ }
976
+ });
977
+ };
978
+ $scope.gensshkey = function () {
979
+ if ($scope.setting.pubkey || $scope.setting.prvkey) {
980
+ $scope.confirm_title = '重新生成公钥/私钥对';
981
+ $scope.confirm_body = '公钥/私钥已存在,是否覆盖原文件?';
982
+ $('#confirm').modal();
983
+ $scope.confirm = $scope.dogenkey;
984
+ return;
985
+ }
986
+ $scope.dogenkey();
987
+ };
988
+ $scope.dogenkey = function () {
989
+ Backend.call(
990
+ $scope,
991
+ module,
992
+ '/api/backend/ssh_genkey',
993
+ '/api/backend/ssh_genkey', {}, {
994
+ 'success': function () {
995
+ $scope.getsettings();
996
+ }
997
+ }
998
+ );
999
+ };
1000
+ $scope.chpasswd = function () {
1001
+ $('#chpasswd').modal();
1002
+ };
1003
+ $scope.dochpasswd = function () {
1004
+ if ($scope.newpassword != $scope.newpasswordc) {
1005
+ Message.setError('新密码和确认密码不一致!');
1006
+ return;
1007
+ }
1008
+ Backend.call(
1009
+ $scope,
1010
+ module,
1011
+ '/api/backend/ssh_chpasswd',
1012
+ '/api/backend/ssh_chpasswd', {
1013
+ 'path': $scope.setting.prvkey,
1014
+ 'oldpassword': $scope.oldpassword,
1015
+ 'newpassword': $scope.newpassword
1016
+ }, {
1017
+ 'success': function () {
1018
+ $scope.oldpassword = $scope.newpassword = $scope.newpasswordc = '';
1019
+ }
1020
+ }
1021
+ );
1022
+ };
1023
+ }
1024
+ ];
1025
+
1026
+ var ServiceIPTablesCtrl = [
1027
+ '$scope', '$routeParams', 'Module', 'Request',
1028
+ function ($scope, $routeParams, Module, Request) {
1029
+ var module = 'service.iptables';
1030
+ Module.init(module, 'IPTables');
1031
+ Module.initSection('base');
1032
+ $scope.scope = $scope;
1033
+ $scope.info = null;
1034
+ $scope.loaded = false;
1035
+
1036
+ $scope.installed = false;
1037
+ $scope.waiting = true;
1038
+ $scope.checking = false;
1039
+
1040
+ $scope.checkInstalled = function () {
1041
+ $scope.checking = true;
1042
+ Request.get('/api/query/service.iptables', function (res) {
1043
+ var info = res['service.iptables'];
1044
+ if (info) {
1045
+ $scope.installed = true;
1046
+ $scope.autostart = info.autostart;
1047
+ $scope.status = info.status;
1048
+ if ($scope.checkVersion) $scope.checkVersion();
1049
+ } else {
1050
+ $scope.installed = false;
1051
+ }
1052
+ $scope.loaded = true;
1053
+ $scope.waiting = false;
1054
+ $scope.checking = false;
1055
+ });
1056
+ };
1057
+ }
1058
+ ];
1059
+
1060
+ var ServiceCronCtrl = [
1061
+ '$scope', '$routeParams', 'Module', 'Request', 'Message',
1062
+ function ($scope, $routeParams, Module, Request, Message) {
1063
+ var module = 'service.cron';
1064
+ Module.init(module, 'Cron');
1065
+ Module.initSection('base');
1066
+ $scope.scope = $scope;
1067
+ $scope.info = null;
1068
+ $scope.loaded = false;
1069
+
1070
+ $scope.installed = false;
1071
+ $scope.waiting = true;
1072
+ $scope.checking = false;
1073
+ var section = Module.getSection();
1074
+
1075
+ $scope.checkInstalled = function () {
1076
+ $scope.checking = true;
1077
+ Request.get('/api/query/service.crond', function (res) {
1078
+ var info = res['service.crond'];
1079
+ if (info) {
1080
+ $scope.installed = true;
1081
+ $scope.autostart = info.autostart;
1082
+ $scope.status = info.status;
1083
+ if ($scope.checkVersion) $scope.checkVersion();
1084
+ } else {
1085
+ $scope.installed = false;
1086
+ }
1087
+ $scope.loaded = true;
1088
+ $scope.waiting = false;
1089
+ $scope.checking = false;
1090
+ });
1091
+ if (section && section == 'settings') {
1092
+ $scope.tabSettings();
1093
+ }
1094
+ };
1095
+ $scope.settings = {};
1096
+ $scope.getSettings = function () {
1097
+ if (!$scope.installed) return;
1098
+ Request.post('/api/operation/cron', {
1099
+ 'action': 'get_settings'
1100
+ }, function (res) {
1101
+ if (res.code == 0) {
1102
+ $scope.settings = res.data;
1103
+ Message.setSuccess(res.msg);
1104
+ }
1105
+ }, false, true);
1106
+ };
1107
+ $scope.updateSetting = function () {
1108
+ if (!$scope.installed) return;
1109
+ Request.post('/api/operation/cron', {
1110
+ 'action': 'save_settings',
1111
+ 'mailto': $scope.settings.mailto
1112
+ }, function (res) {
1113
+ if (res.code == 0) {
1114
+ $scope.tabSettings();
1115
+ Message.setSuccess(res.msg);
1116
+ } else if (res.code == -1) {
1117
+ Message.setError(res.msg);
1118
+ }
1119
+ }, false, true);
1120
+ };
1121
+ $scope.tabSettings = function () {
1122
+ $scope.sec('settings');
1123
+ Module.setSection('settings');
1124
+ $scope.getSettings();
1125
+ }
1126
+ }
1127
+ ];
1128
+
1129
+ var ServiceNTPCtrl = [
1130
+ '$scope', '$routeParams', 'Module', 'Request',
1131
+ function ($scope, $routeParams, Module, Request) {
1132
+ var module = 'service.ntp';
1133
+ Module.init(module, 'NTP');
1134
+ Module.initSection('base');
1135
+ $scope.scope = $scope;
1136
+ $scope.info = null;
1137
+ $scope.loaded = false;
1138
+
1139
+ $scope.installed = false;
1140
+ $scope.waiting = true;
1141
+ $scope.checking = false;
1142
+
1143
+ $scope.checkInstalled = function () {
1144
+ $scope.checking = true;
1145
+ Request.get('/api/query/service.ntpd', function (res) {
1146
+ var info = res['service.ntpd'];
1147
+ if (info) {
1148
+ $scope.installed = true;
1149
+ $scope.autostart = info.autostart;
1150
+ $scope.status = info.status;
1151
+ if ($scope.checkVersion) $scope.checkVersion();
1152
+ } else {
1153
+ $scope.installed = false;
1154
+ }
1155
+ $scope.loaded = true;
1156
+ $scope.waiting = false;
1157
+ $scope.checking = false;
1158
+ });
1159
+ };
1160
+ }
1161
+ ];
1162
+
1163
+ var ServiceNamedCtrl = [
1164
+ '$scope', '$routeParams', 'Module', 'Request',
1165
+ function ($scope, $routeParams, Module, Request) {
1166
+ var module = 'service.named';
1167
+ var section = Module.getSection();
1168
+ Module.init(module, 'named');
1169
+ Module.initSection('base');
1170
+ $scope.scope = $scope;
1171
+ $scope.info = null;
1172
+ $scope.loaded = false;
1173
+
1174
+ $scope.installed = false;
1175
+ $scope.waiting = true;
1176
+ $scope.checking = false;
1177
+
1178
+ $scope.checkInstalled = function () {
1179
+ $scope.checking = true;
1180
+ Request.get('/api/query/service.named', function (res) {
1181
+ var info = res['service.named'];
1182
+ if (info) {
1183
+ $scope.installed = true;
1184
+ $scope.autostart = info.autostart;
1185
+ $scope.status = info.status;
1186
+ if ($scope.checkVersion) $scope.checkVersion();
1187
+ if (section == 'settings') {
1188
+ $scope.load_settings();
1189
+ }
1190
+ } else {
1191
+ $scope.installed = false;
1192
+ }
1193
+ $scope.loaded = true;
1194
+ $scope.waiting = false;
1195
+ $scope.checking = false;
1196
+ });
1197
+ };
1198
+ $scope.load_settings = function () {
1199
+ if (!$scope.installed) return;
1200
+ $scope.getsettings();
1201
+ $scope.sec('settings');
1202
+ Module.setSection('settings');
1203
+ };
1204
+ $scope.getsettings = function () {
1205
+ Request.post('/api/operation/named', {
1206
+ 'action': 'getsettings'
1207
+ }, function (data) {
1208
+ if (data.code == 0) {
1209
+ $scope.baseconfigs = data.data;
1210
+ }
1211
+ });
1212
+ };
1213
+
1214
+ $scope.savesettings = function () {
1215
+ $scope.processing = true;
1216
+ Request.post('/api/operation/named', {
1217
+ 'action': 'savesettings'
1218
+ }, function (data) {
1219
+ if (data.code == 0) {
1220
+ $scope.getsettings();
1221
+ }
1222
+ $scope.processing = false;
1223
+ });
1224
+ };
1225
+ }
1226
+ ];
1227
+
1228
+ var ServiceLighttpdCtrl = [
1229
+ '$scope', '$routeParams', 'Module', 'Request',
1230
+ function ($scope, $routeParams, Module, Request) {
1231
+ var module = 'service.lighttpd';
1232
+ var section = Module.getSection();
1233
+ Module.init(module, 'Lighttpd');
1234
+ Module.initSection('base');
1235
+ $scope.scope = $scope;
1236
+ $scope.info = null;
1237
+ $scope.loaded = false;
1238
+
1239
+ $scope.installed = false;
1240
+ $scope.waiting = true;
1241
+ $scope.checking = false;
1242
+
1243
+ $scope.checkInstalled = function () {
1244
+ $scope.checking = true;
1245
+ Request.get('/api/query/service.lighttpd', function (res) {
1246
+ var info = res['service.lighttpd'];
1247
+ if (info) {
1248
+ $scope.installed = true;
1249
+ $scope.autostart = info.autostart;
1250
+ $scope.status = info.status;
1251
+ if (section == 'settings') {
1252
+ $scope.load_settings();
1253
+ }
1254
+ if ($scope.checkVersion) {
1255
+ $scope.checkVersion();
1256
+ }
1257
+ } else {
1258
+ $scope.installed = false;
1259
+ }
1260
+ $scope.loaded = true;
1261
+ $scope.waiting = false;
1262
+ $scope.checking = false;
1263
+ });
1264
+ };
1265
+ $scope.load_settings = function () {
1266
+ if (!$scope.installed) return;
1267
+ $scope.getsettings();
1268
+ $scope.sec('settings');
1269
+ Module.setSection('settings');
1270
+ };
1271
+ $scope.getsettings = function () {
1272
+ Request.post('/api/operation/lighttpd', {
1273
+ 'action': 'getsettings'
1274
+ }, function (data) {
1275
+ if (data.code == 0) {
1276
+ $scope.baseconfigs = data.data;
1277
+ }
1278
+ });
1279
+ };
1280
+ $scope.savesettings = function () {
1281
+ $scope.processing = true;
1282
+ Request.post('/api/operation/lighttpd', {
1283
+ 'action': 'savesettings'
1284
+ }, function (data) {
1285
+ if (data.code == 0) {
1286
+ $scope.getsettings();
1287
+ }
1288
+ $scope.processing = false;
1289
+ });
1290
+ };
1291
+ }
1292
+ ];
1293
+
1294
+ var ServiceProFTPDCtrl = [
1295
+ '$scope', '$routeParams', 'Module', 'Request',
1296
+ function ($scope, $routeParams, Module, Request) {
1297
+ var module = 'service.proftpd';
1298
+ var section = Module.getSection();
1299
+ Module.init(module, 'ProFTPD');
1300
+ Module.initSection('base');
1301
+ $scope.scope = $scope;
1302
+ $scope.info = null;
1303
+ $scope.loaded = false;
1304
+
1305
+ $scope.installed = false;
1306
+ $scope.waiting = true;
1307
+ $scope.checking = false;
1308
+
1309
+ $scope.checkInstalled = function () {
1310
+ $scope.checking = true;
1311
+ Request.get('/api/query/service.proftpd', function (res) {
1312
+ var info = res['service.proftpd'];
1313
+ if (info) {
1314
+ $scope.installed = true;
1315
+ $scope.autostart = info.autostart;
1316
+ $scope.status = info.status;
1317
+ if (section == 'settings') {
1318
+ $scope.load_settings();
1319
+ }
1320
+ if ($scope.checkVersion) {
1321
+ $scope.checkVersion();
1322
+ }
1323
+ } else {
1324
+ $scope.installed = false;
1325
+ }
1326
+ $scope.loaded = true;
1327
+ $scope.waiting = false;
1328
+ $scope.checking = false;
1329
+ });
1330
+ };
1331
+ $scope.load_settings = function () {
1332
+ if (!$scope.installed) return;
1333
+ $scope.getsettings();
1334
+ $scope.sec('settings');
1335
+ Module.setSection('settings');
1336
+ };
1337
+ $scope.getsettings = function () {
1338
+ Request.post('/api/operation/proftpd', {
1339
+ 'action': 'getsettings'
1340
+ }, function (data) {
1341
+ if (data.code == 0) {
1342
+ $scope.baseconfigs = data.data;
1343
+ }
1344
+ });
1345
+ };
1346
+
1347
+ $scope.savesettings = function () {
1348
+ $scope.processing = true;
1349
+ Request.post('/api/operation/proftpd', {
1350
+ 'action': 'savesettings'
1351
+ }, function (data) {
1352
+ if (data.code == 0) {
1353
+ $scope.getsettings();
1354
+ }
1355
+ $scope.processing = false;
1356
+ });
1357
+ };
1358
+ }
1359
+ ];
1360
+
1361
+ var ServicePureFTPdCtrl = [
1362
+ '$scope', '$routeParams', 'Module', 'Request',
1363
+ function ($scope, $routeParams, Module, Request) {
1364
+ var module = 'service.pureftpd';
1365
+ var section = Module.getSection();
1366
+ Module.init(module, 'Pure-FTPd');
1367
+ Module.initSection('base');
1368
+ $scope.scope = $scope;
1369
+ $scope.info = null;
1370
+ $scope.loaded = false;
1371
+
1372
+ $scope.installed = false;
1373
+ $scope.waiting = true;
1374
+ $scope.checking = false;
1375
+
1376
+ $scope.checkInstalled = function () {
1377
+ $scope.checking = true;
1378
+ Request.get('/api/query/service.pure-ftpd', function (res) {
1379
+ var info = res['service.pure-ftpd'];
1380
+ if (info) {
1381
+ $scope.installed = true;
1382
+ $scope.autostart = info.autostart;
1383
+ $scope.status = info.status;
1384
+ if (section == 'settings') {
1385
+ $scope.load_settings();
1386
+ }
1387
+ if ($scope.checkVersion) {
1388
+ $scope.checkVersion();
1389
+ }
1390
+ } else {
1391
+ $scope.installed = false;
1392
+ }
1393
+ $scope.loaded = true;
1394
+ $scope.waiting = false;
1395
+ $scope.checking = false;
1396
+ });
1397
+ };
1398
+
1399
+ $scope.load_settings = function () {
1400
+ if (!$scope.installed) return;
1401
+ $scope.getsettings();
1402
+ $scope.sec('settings');
1403
+ Module.setSection('settings');
1404
+ };
1405
+ $scope.getsettings = function () {
1406
+ Request.post('/api/operation/pureftpd', {
1407
+ 'action': 'getsettings'
1408
+ }, function (data) {
1409
+ if (data.code == 0) {
1410
+ $scope.baseconfigs = data.data;
1411
+ }
1412
+ });
1413
+ };
1414
+ $scope.savesettings = function () {
1415
+ $scope.processing = true;
1416
+ Request.post('/api/operation/pureftpd', {
1417
+ 'action': 'savesettings'
1418
+ }, function (data) {
1419
+ if (data.code == 0) {
1420
+ $scope.getsettings();
1421
+ }
1422
+ $scope.processing = false;
1423
+ });
1424
+ };
1425
+ }
1426
+ ];
1427
+
1428
+ var ServiceSambaCtrl = [
1429
+ '$scope', '$routeParams', 'Module', 'Request',
1430
+ function ($scope, $routeParams, Module, Request) {
1431
+ var module = 'service.samba';
1432
+ Module.init(module, 'Samba');
1433
+ Module.initSection('base');
1434
+ $scope.scope = $scope;
1435
+ $scope.info = null;
1436
+ $scope.loaded = false;
1437
+
1438
+ $scope.installed = false;
1439
+ $scope.waiting = true;
1440
+ $scope.checking = false;
1441
+
1442
+ $scope.checkInstalled = function () {
1443
+ $scope.checking = true;
1444
+ Request.get('/api/query/service.smb', function (res) {
1445
+ var info = res['service.smb'];
1446
+ if (info) {
1447
+ $scope.installed = true;
1448
+ $scope.autostart = info.autostart;
1449
+ $scope.status = info.status;
1450
+ if ($scope.checkVersion) $scope.checkVersion();
1451
+ } else {
1452
+ $scope.installed = false;
1453
+ }
1454
+ $scope.loaded = true;
1455
+ $scope.waiting = false;
1456
+ $scope.checking = false;
1457
+ });
1458
+ };
1459
+ }
1460
+ ];