Compare commits

...
867 Commits
Author SHA1 Message Date
midoks 0c44305a01 Update requirements.txt 2021-05-01 11:11:22 +08:00
midoks 9c4d482471 Update requirements.txt 2021-05-01 11:07:11 +08:00
midoks 713f77c1ad up 2021-05-01 10:56:12 +08:00
midoks db2b71582b Update requirements.txt 2021-05-01 10:14:01 +08:00
midoks ccc750cce3 Update simdht_delta.conf 2021-04-30 21:59:14 +08:00
midoks 0dc26232b6 Update simdht_delta.conf 2021-04-30 21:58:36 +08:00
midoks fa0fc8eefe Update requirements.txt 2021-04-30 18:41:05 +08:00
midoks 1cadcde740 Update requirements.txt 2021-04-30 18:40:13 +08:00
midoks a602cad2db Update requirements.txt 2021-04-30 18:36:05 +08:00
midoks 0a400aeda9 Update requirements.txt 2021-04-30 18:35:13 +08:00
midoks aaca85bc7e Update requirements.txt 2021-04-30 18:27:06 +08:00
midoks fcba8a9269 Update requirements.txt 2021-04-30 18:19:47 +08:00
midoks 8931a28286 Update install_centos.sh 2021-04-30 18:02:09 +08:00
midoks 8d4d72e14d Update zimg.tpl 2021-04-26 17:21:46 +08:00
midoks fa40d1dc92 Update phplib.conf 2021-04-24 09:51:59 +08:00
midoks 4007d14517 Create openssl.sh 2021-04-24 09:51:09 +08:00
midoks 389db5404c up 2021-04-24 09:22:39 +08:00
midoks 763065e7ab Update install.sh 2021-04-24 09:19:30 +08:00
midoks c697f016aa 更新memcached版本 2021-04-24 09:19:12 +08:00
midoks 1df3b8efd0 更新版本 2021-04-24 09:08:53 +08:00
midoks bfce862180 up 2021-04-22 04:08:30 +08:00
midoks 3f0cc58bdc up 2021-04-22 04:00:01 +08:00
midoks 710482e9ed Update index.py 2021-04-13 15:21:10 +08:00
midoks 49dc230feb Update zimg.tpl 2021-04-13 15:15:03 +08:00
midoks bf6cca7b95 up 2021-04-13 13:15:20 +08:00
midoks 6281e7ae2d up 2021-04-13 12:57:58 +08:00
midoks 4f488ba75f Update zimg.tpl 2021-04-13 12:56:45 +08:00
midoks 1fa59d0a08 Update index.py 2021-04-13 12:55:28 +08:00
midoks ccc9bd26c5 up 2021-04-13 12:54:01 +08:00
midoks 1436a508a5 up 2021-04-13 12:51:56 +08:00
midoks a9aabdfa0c Update install.sh 2021-04-13 12:43:18 +08:00
midoks a6d2081d22 Update install.sh 2021-04-13 12:23:26 +08:00
midoks 88dba0e876 Update install.sh 2021-04-13 12:16:56 +08:00
midoks 88c9680682 Update install.sh 2021-04-13 12:10:49 +08:00
midoks 1e1157159a up 2021-04-13 12:00:48 +08:00
midoks b2fe48e1f2 up 2021-04-11 18:38:52 +08:00
midoks e1b5d6f8b1 Update phplib.conf 2021-04-11 18:34:22 +08:00
midoks 003a0bfacc Create openssl.sh 2021-04-11 18:32:26 +08:00
midoks 08b73394ee Update index.py 2021-04-11 12:19:26 +08:00
midoks ec9d4c050f Update index.py 2021-04-11 12:13:21 +08:00
midoks 6460a0d7db up 2021-04-11 12:12:36 +08:00
midoks f709a033a5 up 2021-04-11 12:05:31 +08:00
midoks 851d6829ee up 2021-04-11 11:51:30 +08:00
midoks 8b5f2aec6b Update index.py 2021-04-11 11:46:20 +08:00
midoks 32f911c3cf Update index.py 2021-04-11 11:37:09 +08:00
midoks ef74376c21 Update index.py 2021-04-11 11:36:26 +08:00
midoks 2752d758b5 up 2021-04-11 11:25:02 +08:00
midoks 296d4fb96d Update install.sh 2021-04-11 11:02:26 +08:00
midoks 69f8a492c8 Delete api_login.txt 2021-04-11 10:47:19 +08:00
midoks 21cf32852b aria2 2021-04-11 10:46:53 +08:00
midoks 5eff5e7b1a Create check-ssh.sh 2021-03-09 22:49:59 +08:00
midoks 9edd79e5f1 up 2021-02-21 15:56:10 +08:00
midoks 4c2a42fc48 Update init.lua 2021-02-21 12:51:46 +08:00
midoks 10446a1934 Update luawaf.conf 2021-02-21 12:51:39 +08:00
midoks 3aeb2b0959 up 2021-02-21 12:34:58 +08:00
midoks e9807280d5 Update init.lua 2021-02-21 12:05:38 +08:00
midoks 395f8b456a up 2021-02-21 11:28:46 +08:00
midoks ef7c9d4e47 Update info.json 2021-02-21 11:06:14 +08:00
midoks f8bea1c812 Update info.json 2021-02-19 21:52:02 +08:00
midoks 4a83cfba83 Update info.json 2021-02-19 21:51:37 +08:00
midoks 199aec01ca Update phplib.conf 2021-02-19 21:50:57 +08:00
midoks 65d6b5e360 Create seaslog.sh 2021-02-19 21:50:39 +08:00
midoks dac412ad4e up 2021-02-19 21:42:51 +08:00
midoks 0f3aaf015a up 2021-02-19 21:39:41 +08:00
midoks d48be332ca Update README.md 2021-02-19 21:31:05 +08:00
midoks c943034145 up 2021-02-19 21:28:24 +08:00
midoks e453a8fa79 Update phplib.conf 2021-02-19 21:21:41 +08:00
midoks b84b7ec0d0 Update redis.sh 2021-02-19 21:19:04 +08:00
midoks 22b3b1e90f up 2021-02-19 21:18:19 +08:00
midoks d1eb61bb84 Create mongodb.sh 2021-02-19 21:13:17 +08:00
midoks aba61490d4 Update yaf.sh 2021-02-19 21:09:23 +08:00
midoks 298023f283 Update phplib.conf 2021-02-19 21:03:52 +08:00
midoks e5e55431ed Create redis.sh 2021-02-19 21:03:33 +08:00
midoks 13c3a20e84 Update swoole.sh 2021-02-19 21:00:51 +08:00
midoks b5a15244b3 up 2021-02-17 11:39:08 +08:00
midoks cb446ae89c Update install.sh 2021-02-17 11:37:25 +08:00
midoks 83ccf6ff24 up 2021-02-16 15:05:53 +08:00
midoks 1eb20f7cb6 Update index.py 2021-02-16 14:46:09 +08:00
midoks 34574a36f1 up 2021-02-16 14:20:34 +08:00
midoks 91c8d1f47a up 2021-02-16 14:10:06 +08:00
midoks 0e5760eaa2 Update index.py 2021-02-16 13:45:36 +08:00
midoks 81a25eeedf Update my8.0.cnf 2021-02-16 12:57:22 +08:00
midoks 627c9efb44 Update my8.0.cnf 2021-02-16 12:55:39 +08:00
midoks e76db6c669 Update my.cnf 2021-02-16 12:55:05 +08:00
midoks c44e901992 Update install.sh 2021-02-16 11:56:59 +08:00
midoks b88d03f316 Update my.cnf 2021-02-15 22:41:40 +08:00
midoks ede3872627 Update my.cnf 2021-02-15 22:40:31 +08:00
midoks 29b50e057c Update index.py 2021-02-15 21:12:22 +08:00
midoks ff75e0440f up 2021-02-15 17:58:57 +08:00
midoks 4ab8d5854b Update mysql.js 2021-02-15 15:32:08 +08:00
midoks d555cdacb8 up 2021-02-15 15:27:32 +08:00
midoks c704184884 up 2021-02-15 15:08:45 +08:00
midoks 9e58352fad Update mysql.js 2021-02-15 12:42:22 +08:00
midoks 0c7a32f372 up 2021-02-15 12:36:26 +08:00
midoks 604c5bc8a0 Update index.py 2021-02-06 14:01:10 +08:00
midoks 87c97694f7 Update index.py 2021-02-06 13:49:01 +08:00
midoks aee7c53729 Update index.py 2021-02-05 22:05:55 +08:00
midoks 22e0ba7043 Update index.py 2021-02-05 21:44:26 +08:00
midoks 280de58a54 up 2021-02-05 21:43:07 +08:00
midoks b6774d8656 up 2021-02-05 21:05:32 +08:00
midoks 268eb0eb2d Update my.cnf 2021-02-05 18:30:39 +08:00
midoks fac0e1179b Update index.py 2021-02-05 17:49:31 +08:00
midoks 985c6f0a67 Update index.py 2021-02-05 16:57:54 +08:00
midoks db1d9320bd Update index.py 2021-02-05 16:52:05 +08:00
midoks 0a110c4afa Update index.py 2021-02-05 16:36:08 +08:00
midoks e436375090 Update index.py 2021-02-05 16:35:20 +08:00
midoks 8723ad9577 up 2021-02-05 16:09:41 +08:00
midoks f8693c8cc3 up 2021-02-05 15:22:45 +08:00
midoks 1a1b0a59ee Update index.py 2021-02-05 14:39:30 +08:00
midoks af22a68540 Update index.py 2021-02-05 14:37:21 +08:00
midoks 696df06794 up 2021-02-05 11:43:05 +08:00
midoks 9886e43335 up 2021-02-05 11:37:49 +08:00
midoks 3bd5886a6c up 2021-02-05 11:35:36 +08:00
midoks aa071bfb15 up 2021-02-05 11:26:47 +08:00
midoks 98d3001861 Update mysql.js 2021-02-05 10:59:11 +08:00
midoks 36b55cc73c Update mysql.js 2021-02-05 02:25:13 +08:00
midoks 80f64066a7 Update mysql.js 2021-02-05 02:06:25 +08:00
midoks a5ce95d831 Update config.inc.php 2021-02-04 20:31:28 +08:00
midoks b07409050a Update mysql.js 2021-02-04 19:26:05 +08:00
midoks a2ee7c9092 Update index.py 2021-02-04 19:18:29 +08:00
midoks f9c9c91490 Update index.py 2021-02-04 19:04:35 +08:00
midoks dca43f812d Update index.py 2021-02-04 18:59:50 +08:00
midoks d93329478d Update crontab_api.py 2021-02-04 17:49:36 +08:00
midoks 3d296e4099 up 2021-02-04 02:49:43 +08:00
midoks b7f9485ff6 up 2021-02-04 02:26:10 +08:00
midoks 65bd3fefa9 Update requirements.txt 2021-02-04 02:20:42 +08:00
midoks 5a4c831809 Update index.py 2021-02-04 02:09:47 +08:00
midoks 3c6ce19b3a Update index.py 2021-02-03 23:44:44 +08:00
midoks cdb6966455 up 2021-02-03 23:20:52 +08:00
midoks 27c8142602 Update index.py 2021-02-03 23:00:17 +08:00
midoks c04779efe2 mysql 主从可配置化end 2021-02-03 22:52:16 +08:00
midoks be5a9f7b4b Update index.py 2021-02-03 21:26:09 +08:00
midoks 1564047a26 up 2021-02-03 21:20:39 +08:00
midoks e561a909e7 up 2021-02-03 19:26:31 +08:00
midoks 3e06062784 Update install.sh 2021-02-03 14:19:09 +08:00
midoks 65a2af748b Update install.sh 2021-02-03 14:17:43 +08:00
midoks febd9de71b Update index.py 2021-02-03 14:15:11 +08:00
midoks 870808b31b Update install.sh 2021-02-03 14:13:07 +08:00
midoks debfdabde9 Update install.sh 2021-02-03 14:09:29 +08:00
midoks 6cf7152478 up 2021-02-03 14:02:12 +08:00
midoks f75d121a59 up 2021-02-03 14:00:55 +08:00
midoks 407b5a619a Update mysql.js 2021-02-03 02:17:11 +08:00
midoks b46bc89cb9 Update index.html 2021-02-03 02:17:06 +08:00
midoks cb587b18bd Update index.py 2021-02-03 00:49:17 +08:00
midoks 8b67421c0c Update index.py 2021-02-03 00:37:16 +08:00
midoks 64f882c6b8 Update index.py 2021-02-03 00:32:06 +08:00
midoks eb6590a275 Update mysql.js 2021-02-02 23:19:04 +08:00
midoks 595c238fb5 up 2021-02-02 22:26:50 +08:00
midoks 80d1e4efe7 Update index.py 2021-02-02 22:06:49 +08:00
midoks 8ee6f9d190 up 2021-02-02 21:30:48 +08:00
midoks 94a2f88633 Update index.py 2021-02-02 20:49:41 +08:00
midoks 605cf36e9c Update my.cnf 2021-02-02 17:42:08 +08:00
midoks 21194aa285 up 2021-02-02 17:31:39 +08:00
midoks e3876de3d2 Update my.cnf 2021-02-02 15:34:45 +08:00
midoks 1e054f9801 up 2021-02-02 15:33:07 +08:00
midoks df048c6bd6 up 2021-02-02 15:32:06 +08:00
midoks 3056fb9ceb up 2021-02-02 15:21:37 +08:00
midoks bb655b55e5 Update index.py 2021-02-02 03:59:06 +08:00
midoks 97ab18a771 Update index.html 2021-02-02 03:58:58 +08:00
midoks 26760502d0 mysql init.d 2021-02-02 03:50:30 +08:00
midoks 126c7e08e3 mysql conf 2021-02-02 03:49:06 +08:00
midoks 5e55cf753e Update install.sh 2021-02-02 01:37:06 +08:00
midoks da8b0ccbfc Update task.py 2021-02-02 01:33:42 +08:00
midoks c746e8e139 Update task.py 2021-02-02 01:31:37 +08:00
midoks 0e2df5620e up 2021-02-02 00:29:10 +08:00
midoks b1b43120ea Update info.json 2021-02-01 22:31:10 +08:00
midoks e854cc083f up 2021-02-01 22:26:55 +08:00
midoks 791f2b8ec9 up 2021-02-01 22:13:59 +08:00
midoks 0c6b293337 Update info.json 2021-02-01 21:16:55 +08:00
midoks da9b3bf435 update mysql version 2021-02-01 20:54:27 +08:00
midoks 301086faa1 up 2021-02-01 20:49:55 +08:00
midoks 3b6b54103b web ssh opt 2021-02-01 20:13:14 +08:00
midoks 6dda90b64f Update mw.py 2021-02-01 19:55:21 +08:00
midoks d28fcce8b6 Update info.json 2021-01-30 16:24:37 +08:00
midoks ba2da974c9 Update __init__.py 2021-01-30 15:05:44 +08:00
midoks 024f8bd62f Update __init__.py 2021-01-30 14:54:37 +08:00
midoks fe7853781b Update __init__.py 2021-01-30 13:56:08 +08:00
midoks d92010bfe0 Update __init__.py 2021-01-30 13:33:11 +08:00
midoks 2631f1771c Update __init__.py 2021-01-30 13:32:26 +08:00
midoks 4cf7a6b8fe Update __init__.py 2021-01-30 13:18:50 +08:00
midoks af460ffed6 Update index.py 2021-01-29 19:59:49 +08:00
midoks a7982c4df3 Update index.py 2021-01-29 19:54:32 +08:00
midoks 0850654da8 Update install.sh 2021-01-29 19:34:58 +08:00
midoks 086e050914 Update index.html 2021-01-29 19:32:44 +08:00
midoks 4c57b9a2e6 Update index.py 2021-01-29 19:26:09 +08:00
midoks ca7095c65a Update index.html 2021-01-29 19:22:45 +08:00
midoks 2c3f2e797d Update swap.tpl 2021-01-29 19:21:41 +08:00
midoks cccd3ff7fc Update index.py 2021-01-29 19:13:38 +08:00
midoks effc3ba296 yp 2021-01-29 19:13:11 +08:00
midoks e96fdea003 Update index.py 2021-01-29 18:51:38 +08:00
midoks 00a43549a2 Update index.py 2021-01-29 18:48:32 +08:00
midoks ebd09842a2 up 2021-01-29 18:42:39 +08:00
midoks 1eccc9cb7c Update index.py 2021-01-29 18:13:05 +08:00
midoks a44df8dd9a Update swap.tpl 2021-01-29 18:07:59 +08:00
midoks 58d78d5c5d swap 2021-01-29 18:05:43 +08:00
midoks 9babeb4373 Update socket5.js 2021-01-29 17:15:53 +08:00
midoks 8345bd8bb5 up 2021-01-29 17:06:53 +08:00
midoks 9106246891 up 2021-01-29 17:03:34 +08:00
midoks 21209a75d8 Update index.py 2021-01-29 16:52:54 +08:00
midoks 3b6d50661b up 2021-01-29 16:50:39 +08:00
midoks 295cc70e0a Update index.py 2021-01-29 16:46:59 +08:00
midoks c7fa266ae1 Update index.py 2021-01-29 16:46:38 +08:00
midoks 8788afc35f o 2021-01-29 16:26:56 +08:00
midoks 44c55ee923 up 2021-01-29 16:13:40 +08:00
midoks 2073fbd680 up 2021-01-29 15:46:36 +08:00
midoks 1b876d4cac Update install.sh 2021-01-29 15:35:31 +08:00
midoks 0961b233e0 socket5 2021-01-29 15:27:08 +08:00
midoks 184bcf88d7 Update install.sh 2021-01-12 13:13:30 +08:00
midoks 3f07a11b53 Update gunicorn.conf 2021-01-05 17:59:28 +08:00
midoks aa3a66cf01 Create gunicorn.conf 2021-01-05 17:39:58 +08:00
midoks 0bc8f670f5 Update index.py 2020-10-13 11:57:36 +08:00
midoks 63cb8f0e84 Update install.sh 2020-10-13 11:54:36 +08:00
midoks 5a17df7c5c Update install.sh 2020-10-13 11:51:43 +08:00
midoks 3ce9735ff8 Update install.sh 2020-10-13 11:47:55 +08:00
midoks 1819b814a3 Update install.sh 2020-10-13 11:45:30 +08:00
midoks f5c5bd03e6 Update eaccelerator.sh 2020-09-30 09:28:27 +08:00
midoks 04c6d4b3cc Update index.py 2020-09-30 03:11:10 +08:00
midoks 7e5116ba59 Update index.py 2020-09-30 03:10:48 +08:00
midoks 44d254415e Update index.py 2020-09-30 03:03:48 +08:00
midoks 0efba47c53 Update index.py 2020-09-30 02:53:59 +08:00
midoks c7be9b7230 Update index.py 2020-09-30 02:53:39 +08:00
midoks 311310e04c Update index.py 2020-09-30 02:52:21 +08:00
midoks 59ca997372 Update index.py 2020-09-30 02:50:47 +08:00
midoks 27a96495ae up 2020-09-30 02:48:16 +08:00
midoks cd1662761b Update php-fpm-52.conf 2020-09-30 02:41:35 +08:00
midoks 4995131e24 Update php-fpm-52.conf 2020-09-30 02:39:08 +08:00
midoks ae9989a13f 兼容php5.2 2020-09-30 02:22:31 +08:00
midoks db143ea39f xhporf 52 2020-09-30 02:06:04 +08:00
midoks 7582b0e6ba php mysql 2020-09-28 17:13:15 +08:00
midoks 1ce6cbef51 Update install.sh 2020-09-28 12:52:11 +08:00
midoks e136330e36 Update install.sh 2020-09-28 11:27:12 +08:00
midoks 346f09dabd Update install.sh 2020-09-28 10:57:29 +08:00
midoks 0d56f1ab5f Update redis.sh 2020-09-27 11:49:11 +08:00
midoks 2f771b1f05 Update redis.sh 2020-09-27 11:44:32 +08:00
midoks 1862e68c52 Update phplib.conf 2020-09-27 11:42:04 +08:00
midoks aaca9cc654 Create redis.sh 2020-09-27 11:40:17 +08:00
midoks bda83eb434 up 2020-09-27 00:15:39 +08:00
midoks 6f5838306d Update phplib.conf 2020-09-26 23:41:56 +08:00
midoks 615e1b60b7 up 2020-09-26 23:40:25 +08:00
midoks 4300a532ba Create memcache.sh 2020-09-26 22:45:41 +08:00
midoks 52c92183f5 Update install.sh 2020-09-26 22:27:13 +08:00
midoks feda58b8c4 Update install.sh 2020-09-26 20:48:43 +08:00
midoks a41d0b4553 Update install.sh 2020-09-26 20:46:39 +08:00
midoks 68e9fa157d Update install.sh 2020-09-26 20:44:07 +08:00
midoks 81f79582b5 Update zendguardloader.sh 2020-09-26 20:42:21 +08:00
midoks 552aa85eb6 Update install.sh 2020-09-26 20:29:32 +08:00
midoks 5119e522d4 Update zendoptimizer.sh 2020-09-26 20:16:19 +08:00
midoks 46f112fe7f up 2020-09-26 20:10:07 +08:00
midoks 2215c1bd38 Update zendguardloader.sh 2020-09-26 20:09:08 +08:00
midoks aa38037087 Update index.py 2020-09-26 20:01:27 +08:00
midoks b48efb4607 up 2020-09-26 19:59:16 +08:00
midoks 3c22dd6380 up 2020-09-26 19:54:17 +08:00
midoks 9127ed5220 Update index.py 2020-09-26 19:50:40 +08:00
midoks a04c6b46af Update index.py 2020-09-26 19:43:04 +08:00
midoks ed7bc1cdf3 up 2020-09-26 19:39:12 +08:00
midoks 6d191fc162 Update install.sh 2020-09-26 19:33:12 +08:00
midoks b14f22a0cf Update install.sh 2020-09-26 19:29:39 +08:00
midoks bb9fe44a0f up 2020-09-26 19:13:55 +08:00
midoks ee6adfa83c Update install.sh 2020-09-26 19:06:42 +08:00
midoks 8d990b3f96 Update install.sh 2020-09-26 19:04:52 +08:00
midoks 9b0b5d1504 Update install.sh 2020-09-26 19:01:27 +08:00
midoks aac1cc30a5 Update install.sh 2020-09-26 18:58:56 +08:00
midoks e8f1cb4e02 Update install.sh 2020-09-26 18:54:30 +08:00
midoks f973794e4a Update install.sh 2020-09-26 18:50:06 +08:00
midoks 062a8917cb Update install.sh 2020-09-26 18:48:21 +08:00
midoks 3c412c91f7 Update install.sh 2020-09-26 18:45:56 +08:00
midoks b3f338e4e0 Update install.sh 2020-09-26 18:37:50 +08:00
midoks 78f422c64a Update install.sh 2020-09-26 18:37:26 +08:00
midoks 6f76846497 up 2020-09-26 18:32:37 +08:00
midoks 638426b81b Update config_api.py
优化计划任务管理
2020-09-19 20:27:09 +08:00
midoks a982e8a0e2 up 2020-09-19 16:03:09 +08:00
midoks 79a2954486 up 2020-09-19 16:01:46 +08:00
midoks 3e73314cb1 up 2020-09-19 15:36:56 +08:00
midoks 92e94ab4e9 Update solr.js 2020-09-15 13:26:01 +08:00
midoks 1e0ec8e17e Update redis.conf 2020-09-14 01:04:44 +08:00
midoks a1e0e95925 Update index.py 2020-08-04 21:51:10 +08:00
midoks ceb1a7828a Update qbittorrent.tpl 2020-08-04 21:42:05 +08:00
midoks 02beb55896 Update qbittorrent.tpl 2020-08-04 19:24:01 +08:00
midoks f53377cc7d Update qbittorrent.tpl 2020-08-04 18:56:54 +08:00
midoks 02fbb7cdcf Update commit.tpl 2020-07-31 00:22:01 +08:00
midoks 58059111c1 Update qbittorrent_worker.py 2020-07-25 17:35:48 +08:00
midoks f51cc16500 Update qbittorrent_worker.py 2020-07-25 13:38:40 +08:00
midoks 1d6fa13a94 Update qbittorrent_worker.py 2020-07-25 13:25:23 +08:00
midoks 6924adbda3 Update qbittorrent_worker.py 2020-07-25 13:22:50 +08:00
midoks 983dde38d2 Update qbittorrent_worker.py 2020-07-25 12:21:08 +08:00
midoks bda0753b77 Update qb.sql 2020-07-25 11:08:14 +08:00
midoks 93d9dbfd20 Update qb.sql 2020-07-25 11:07:52 +08:00
midoks 0a277b7e52 Update qbittorrent_worker.py 2020-07-25 11:03:36 +08:00
midoks 4825a1ca09 Update qbittorrent_worker.py 2020-07-23 11:20:31 +08:00
midoks 21dd6f39a8 Update qbittorrent_worker.py 2020-07-23 00:17:27 +08:00
midoks 261b85dbda Update install.sh 2020-07-22 23:59:34 +08:00
midoks 4716cff256 Update qbittorrent_worker.py 2020-07-22 23:03:02 +08:00
midoks d86c6ad6ee Update qbittorrent_worker.py 2020-07-22 22:52:48 +08:00
midoks bd7906595a Update qb.conf 2020-07-22 22:16:45 +08:00
midoks f00478cf17 Update qbittorrent_worker.py 2020-07-22 20:59:24 +08:00
midoks 1a24d11137 Update install.sh 2020-07-22 20:10:02 +08:00
midoks b8185e042f Update install.sh 2020-07-22 20:07:50 +08:00
midoks 318cc79b8e Update install.sh 2020-07-22 19:53:02 +08:00
midoks 389abf794f Update install.sh 2020-07-22 19:50:28 +08:00
midoks 1d37ec38ee Update qbittorrent_worker.py 2020-07-22 19:46:34 +08:00
midoks fd2a9223ff Update qbittorrent_worker.py 2020-07-22 19:46:17 +08:00
midoks 84e7da76b5 Update install.sh 2020-07-22 17:49:06 +08:00
midoks 90d30df686 Update qbittorrent_worker.py 2020-07-22 17:32:52 +08:00
midoks 9fa9ed9f6e Update qb.conf 2020-07-22 17:32:09 +08:00
midoks c26867c80b Update index.py 2020-07-22 17:31:35 +08:00
midoks 221a005fc7 Update install.sh 2020-07-22 17:20:07 +08:00
midoks 7fb61a5121 Delete ss1.jpg 2020-07-21 16:08:26 +08:00
midoks 6eadbcd53e up 2020-07-16 16:30:00 +08:00
midoks b43da4eea8 Update yaf.sh 2020-07-15 18:24:03 +08:00
midoks 1590e1061c update 2020-07-15 17:39:07 +08:00
midoks 3ac32665b8 Update pcntl.sh 2020-07-15 17:36:36 +08:00
midoks 97f01aeb74 up 2020-07-15 17:34:57 +08:00
midoks 92e3bd82ef Update phplib.conf 2020-07-15 17:33:05 +08:00
midoks ad2ce68a49 up 2020-07-15 17:28:18 +08:00
midoks 75f212bec7 up 2020-07-15 17:00:53 +08:00
midoks 13f6ee18f9 Update system_api.py 2020-07-15 12:38:32 +08:00
midoks 571d2056fb Update system_api.py 2020-07-15 12:34:48 +08:00
midoks 08ef87c77e Update system_api.py 2020-07-15 12:29:45 +08:00
midoks 5d2e7acc95 Update system_api.py 2020-07-15 12:29:07 +08:00
midoks 58e18e3ebb Update system_api.py 2020-07-15 12:23:57 +08:00
midoks a4731e0053 Update system_api.py 2020-07-15 12:15:15 +08:00
midoks db22749219 Update system_api.py 2020-07-15 12:13:44 +08:00
midoks 942c0023fb Update system_api.py 2020-07-15 12:12:18 +08:00
midoks 0b4fa3ea5c Update system_api.py 2020-07-15 11:59:05 +08:00
midoks e23b15ccd1 Update system_api.py 2020-07-15 11:54:15 +08:00
midoks 0f515829fe up 2020-07-15 11:36:30 +08:00
midoks 95a3de24b3 up 2020-07-15 11:07:09 +08:00
midoks 154b543f82 up op 2020-07-15 10:43:10 +08:00
midoks 3b3f22f4fa up 2020-07-15 09:40:02 +08:00
midoks 6cce72c966 Update phplib.conf 2020-07-15 08:52:46 +08:00
midoks 2309d07d26 up 2020-07-15 08:49:30 +08:00
midoks 3617eb6028 opcache update 2020-07-15 08:42:24 +08:00
midoks 9ce4de6237 yaf 2020-07-14 16:30:44 +08:00
midoks 02e8c98de0 up 2020-07-14 16:28:21 +08:00
midoks 566c6d3b24 up 2020-07-14 16:21:56 +08:00
midoks 0b8d662be1 Create mongodb.sh 2020-07-14 16:20:46 +08:00
midoks 71602d2440 Update phplib.conf 2020-07-14 16:20:33 +08:00
midoks 212aea1fc3 Update phplib.conf 2020-07-14 16:12:19 +08:00
midoks 8a5d8236e9 Update mongodb.sh 2020-07-14 16:11:51 +08:00
midoks ad484adf2a Update mongodb.sh 2020-07-14 15:48:20 +08:00
midoks 04c2f9d155 Update lib.sh 2020-07-14 15:48:16 +08:00
midoks d387e0ef22 Update zendguardloader.sh 2020-07-14 15:25:03 +08:00
midoks dc74db0313 Update phplib.conf 2020-07-14 15:24:03 +08:00
midoks 2bc336ea7d Create zendguardloader.sh 2020-07-14 15:17:12 +08:00
midoks 5b13be2dd9 Update imagemagick.sh 2020-07-14 15:05:43 +08:00
midoks f94db9bcdc Update imagemagick.sh 2020-07-14 15:05:23 +08:00
midoks da599b3947 Update imagemagick.sh 2020-07-14 15:04:54 +08:00
midoks f559e19da8 Update imagemagick.sh 2020-07-14 15:04:29 +08:00
midoks 866fc68a81 Update imagemagick.sh 2020-07-14 15:04:02 +08:00
midoks 546bd4f577 Update lib.sh 2020-07-14 14:54:10 +08:00
midoks 37bc9a71b3 Update lib.sh 2020-07-14 14:15:18 +08:00
midoks fab204143a up 2020-07-14 14:05:08 +08:00
midoks 46a7f8d754 Update memcached.sh 2020-07-14 14:02:52 +08:00
midoks e0b1f8b622 up 2020-07-14 14:01:35 +08:00
midoks ebf63d0fae up 2020-07-14 14:01:10 +08:00
midoks 53ed086f84 Update memcached.sh 2020-07-14 13:58:05 +08:00
midoks 44555af3da Update memcached.sh 2020-07-14 13:16:57 +08:00
midoks 042880b115 Update imagemagick.sh 2020-07-14 13:14:20 +08:00
midoks eb99b18bd3 Update apc.sh 2020-07-14 13:10:36 +08:00
midoks eda0911a2e Update apc.sh 2020-07-14 13:09:29 +08:00
midoks 4a92866138 Update eaccelerator.sh 2020-07-14 13:02:09 +08:00
midoks 32f64b3dab Update eaccelerator.sh 2020-07-14 13:01:35 +08:00
midoks 3f94905735 Update apc.sh 2020-07-14 12:57:02 +08:00
midoks e7b69c46a3 Update apc.sh 2020-07-14 12:55:43 +08:00
midoks f1695efa6e Update apc.sh 2020-07-14 12:53:52 +08:00
midoks cd4996477b Update opcache.sh 2020-07-14 12:53:03 +08:00
midoks 6490610c30 Update site_api.py 2020-07-14 12:46:26 +08:00
midoks 49e2eb47ef Create php8.ini 2020-07-14 12:43:59 +08:00
midoks 34504e80a8 Update index.py 2020-07-14 12:36:08 +08:00
midoks dccf70fef9 Update install.sh 2020-07-14 12:22:13 +08:00
midoks d74ed17e9e up 2020-07-14 12:12:54 +08:00
midoks 72b2da6558 Update info.json 2020-07-14 12:09:55 +08:00
midoks 7cbc4e0d38 Create install.sh 2020-07-14 12:06:13 +08:00
midoks 23889fbe29 up 2020-07-14 11:48:22 +08:00
midoks c44d9b4a52 Update lib.sh 2020-07-14 09:22:04 +08:00
midoks 1f00ebeefb Update lib.sh 2020-07-14 09:18:29 +08:00
midoks a06d55531e up 2020-07-14 09:08:19 +08:00
midoks 7f5dcc2667 Update install.sh 2020-07-14 09:02:10 +08:00
midoks f1ec8ad714 Update install.sh 2020-07-14 08:46:30 +08:00
midoks b1a03e50b2 Update install.sh 2020-07-14 08:44:31 +08:00
midoks 85c80cfe28 Update install.sh 2020-07-14 08:38:10 +08:00
midoks 89d15a2f10 Create wmcms.conf 2020-07-13 18:17:46 +08:00
midoks 6225e77eb8 up 2020-07-13 00:21:30 +08:00
midoks a1f03de98d up 2020-07-13 00:14:56 +08:00
midoks c8105363df Update install.sh 2020-07-13 00:09:24 +08:00
midoks 5f416ba2d4 xhprof update 2020-07-13 00:01:08 +08:00
midoks bd6cb8f029 Update index.py 2020-07-12 23:54:01 +08:00
midoks 03e2b95305 Update index.py 2020-07-12 23:51:18 +08:00
midoks a9a26a3b84 Update index.py 2020-07-12 23:50:30 +08:00
midoks c89c4963a2 Update index.py 2020-07-12 23:47:46 +08:00
midoks ec83257a27 Update index.py 2020-07-12 23:43:34 +08:00
midoks 853234c4b6 Update lib.sh 2020-07-12 23:37:23 +08:00
midoks 29f2a3ce7e Update php7.ini 2020-07-12 23:37:12 +08:00
midoks 6da5641263 Update php5.ini 2020-07-12 23:37:10 +08:00
midoks 2b7514c5b4 Update install.sh 2020-07-12 18:37:13 +08:00
midoks 65ba422c77 Create app_start.php 2020-07-12 18:15:03 +08:00
midoks 5edf8b8dda xhprof 2020-07-12 18:14:56 +08:00
midoks 6384c1bd13 Update lib.sh 2020-07-12 15:27:25 +08:00
midoks 53398031b1 up 2020-07-12 15:10:39 +08:00
midoks 060b2160aa up 2020-07-12 14:46:16 +08:00
midoks b0d1586d78 Update index.html 2020-07-12 14:32:17 +08:00
midoks 0838f759a1 php73 2020-07-12 00:22:04 +08:00
midoks d3a539638e PHP 72 2020-07-12 00:18:46 +08:00
midoks 59abf77572 PHP 74 2020-07-12 00:15:16 +08:00
midoks 1467efa015 PHP 55 2020-07-12 00:12:41 +08:00
midoks 56dca95325 Update apc.sh 2020-07-12 00:06:31 +08:00
midoks 5d705246b9 PHP 54 2020-07-12 00:03:50 +08:00
midoks 5423046937 php 70 2020-07-11 23:58:39 +08:00
midoks 3068007aa8 Update imagemagick.sh 2020-07-11 23:53:19 +08:00
midoks a8f8e84ae3 up 2020-07-11 23:51:07 +08:00
midoks 3d66bb47bd up 2020-07-11 23:50:34 +08:00
midoks cc3757e869 Update redis.sh 2020-07-11 23:49:51 +08:00
midoks f6b9e2da54 php 53,56,71修复版。 2020-07-11 23:47:58 +08:00
midoks f752d99e8b Update memcached.sh 2020-07-11 23:29:49 +08:00
midoks 69947f5353 Update memcached.sh 2020-07-11 23:27:57 +08:00
midoks 4d73843e00 Update memcached.sh 2020-07-11 23:18:16 +08:00
midoks f882c85e83 Update memcached.sh 2020-07-11 23:04:06 +08:00
midoks d9c886ce95 up 2020-07-11 23:02:03 +08:00
midoks 200bf07644 Update memcached.sh 2020-07-11 22:55:30 +08:00
midoks b981d89077 up 2020-07-11 22:52:40 +08:00
midoks 8ab69bf40f Update memcached.sh 2020-07-11 22:47:46 +08:00
midoks b7a2b6cbf8 Update lib.sh 2020-07-11 22:11:37 +08:00
midoks d740ca4d2e up 2020-07-11 22:07:35 +08:00
midoks 1bb9613de1 Update memcached.sh 2020-07-11 22:04:57 +08:00
midoks 73cf09e75e Update lib.sh 2020-07-11 22:04:25 +08:00
midoks fb5c483b22 Update nginx.conf 2020-07-11 10:22:28 +08:00
midoks 8d9126ea80 Update firewall_api.py 2020-07-11 02:37:38 +08:00
midoks 81ddf69370 Update firewall_api.py 2020-07-11 02:30:37 +08:00
midoks 0545fffd8c Update firewall_api.py 2020-07-11 02:21:29 +08:00
midoks 8fa6060729 Update index.py 2020-07-11 01:24:54 +08:00
midoks 63c3e513be Update redis.tpl 2020-07-11 00:37:56 +08:00
midoks 5249658207 Update index.py 2020-07-11 00:21:15 +08:00
midoks 10585f6406 Update __init__.py 2020-07-10 16:22:14 +08:00
midoks 72d5939ec3 Update update.sh 2020-07-10 15:59:04 +08:00
midoks 6c65e45d00 2020-07-10 解决public冲突。 2020-07-10 15:57:25 +08:00
midoks 89e3940771 Update requirements.txt 2020-07-10 13:47:47 +08:00
midoks f802cc36d3 Update install_centos.sh 2020-07-09 20:05:14 +08:00
midoks d938affe9b up 2020-07-09 19:26:34 +08:00
midoks c1af2aaa63 Update requirements.txt 2020-07-09 19:07:08 +08:00
midoks 1fec620adb Update install_centos.sh 2020-07-09 18:54:16 +08:00
midoks 245ee059a1 Update update.sh 2020-07-04 12:41:27 +08:00
midoks b39bf7e4d7 Create clear.sh 2020-07-04 12:19:03 +08:00
midoks 9533cc3960 up 2020-06-28 13:49:44 +08:00
midoks 8eebaebdf6 Update install.sh 2020-06-28 13:49:06 +08:00
midoks 6bde23e737 Update install.sh 2020-06-28 13:44:38 +08:00
midoks 1a61754255 Update install.sh 2020-06-28 13:16:02 +08:00
midoks 9496ee401b Update info.json 2020-06-28 13:10:34 +08:00
midoks e35b0ecf76 优化openresty安装 2020-06-28 13:09:15 +08:00
midoks f2505df3d7 Update redis.tpl 2020-06-28 12:58:45 +08:00
midoks 45e8c22825 Update crontab_api.py 2020-06-24 00:37:02 +08:00
midoks f7115481dd Create v2ray.conf 2020-06-20 18:27:07 +08:00
midoks b728766677 vmess 更新 2020-06-20 18:22:46 +08:00
midoks 6912798076 Update index.py 2020-06-20 17:19:15 +08:00
midoks 667210fc24 Update black_list.txt 2020-06-18 22:35:07 +08:00
midoks b42710c0ed Update gogs.js 2020-06-18 15:54:10 +08:00
midoks 490df14a0a Update gogs.js 2020-06-18 15:49:25 +08:00
midoks 8e174f837d up 2020-06-16 22:18:44 +08:00
midoks 48c24c0126 默认开启443端口 2020-06-11 23:39:31 +08:00
midoks bd352d946e Update install.sh 2020-06-08 23:18:45 +08:00
midoks d956531421 v2ray 2020-06-08 08:45:48 +08:00
midoks 679c74b15a up 2020-06-08 08:42:18 +08:00
midoks 907e1ca275 Update index.py 2020-06-08 08:29:49 +08:00
midoks caefc23670 Update index.py 2020-06-08 08:25:47 +08:00
midoks 53510581aa Update info.json 2020-06-08 08:13:09 +08:00
midoks 27b1d94a86 Update index.py 2020-06-08 08:11:33 +08:00
midoks 8e6edf8cd7 Update index.py 2020-06-08 08:10:52 +08:00
midoks 2651ed8ecb v2ray 2020-06-08 08:06:14 +08:00
midoks bffe9547ff update redis 2020-06-07 16:29:49 +08:00
midoks d6cae70249 shadowsocks 2020-06-06 23:21:37 +08:00
midoks ff7e063f09 Update shadowsocks.json 2020-06-06 18:58:12 +08:00
midoks 3b53bcbcdb Update shadowsocks.tpl 2020-06-05 17:41:53 +08:00
midoks 497d6dd961 Update shadowsocks.tpl 2020-06-05 17:31:58 +08:00
midoks 41d33eef54 Update index.py 2020-06-02 23:05:53 +08:00
midoks 2ff18a9cf9 Update shadowsocks.js 2020-06-02 16:57:17 +08:00
midoks 0c43fcda07 shadowsocks 2020-06-02 16:55:41 +08:00
midoks d0bb505b3f 更新PHP版本 2020-05-20 10:43:48 +08:00
midoks a21cca51c3 simdht 2020-05-17 22:36:58 +08:00
midoks 30cb7516b1 Update requirements.txt 2020-05-12 01:21:41 +08:00
midoks 06e6deff87 Update requirements.txt 2020-04-20 14:41:01 +08:00
midoks a4ce338088 up 2019-12-13 02:54:48 +08:00
midoks 45c7430af3 Update requirements.txt 2019-12-12 00:18:49 +08:00
midoks b0b34a6ea1 Update requirements.txt 2019-12-12 00:14:26 +08:00
midoks 0fcada900b flask cache 2019-12-08 21:10:22 +08:00
midoks ca5729e26d Update requirements.txt 2019-12-07 01:19:38 +08:00
midoks 22eed3f67b Update requirements.txt 2019-12-07 01:19:14 +08:00
midoks cd0799cc15 Update index.py 2019-12-07 01:15:11 +08:00
midoks a0724c4fa9 Update index.py 2019-12-07 01:08:18 +08:00
midoks 0145d8db47 Update index.py 2019-12-07 01:06:22 +08:00
midoks 7ba4d2332d Update index.py 2019-12-07 01:05:44 +08:00
midoks fb5e522a81 up 2019-12-07 01:04:34 +08:00
midoks 71dae04946 up 2019-12-07 01:02:25 +08:00
midoks 8418c3c3a0 Update index.py 2019-12-07 00:57:56 +08:00
midoks 94ac06b35c up 2019-12-07 00:48:18 +08:00
midoks 9fd6160571 系统优化插件 2019-12-07 00:43:57 +08:00
midoks 4b9ffbe71f Update jenkins.js 2019-12-06 19:20:38 +08:00
midoks 8018682049 Update index.py 2019-12-06 19:16:17 +08:00
midoks f44ff2fb0d Update jenkins.js 2019-12-06 19:09:55 +08:00
midoks 7a79388978 up 2019-12-06 19:09:32 +08:00
midoks 0d5af34b19 Update index.py 2019-12-06 18:07:02 +08:00
midoks d05f5ebff8 jenkins plugin init 2019-12-06 18:01:46 +08:00
midoks 4c64feef62 Update index.py 2019-12-06 16:00:33 +08:00
midoks 0491503774 walle ok 2019-12-06 15:18:30 +08:00
midoks fa67ee7e71 Update walle.js 2019-12-06 04:01:45 +08:00
midoks 1ae0682d77 Update install.sh 2019-12-06 03:48:55 +08:00
midoks 357749f22d Update install.sh 2019-12-06 03:28:40 +08:00
midoks 9a078193bd Update install.sh 2019-12-06 03:27:15 +08:00
midoks fd9746b7ef update 2019-12-06 03:27:05 +08:00
midoks a2de2b6ff1 Update requirements.txt 2019-12-06 03:06:43 +08:00
midoks 970706028a up 2019-12-06 03:02:43 +08:00
midoks ced6c480d1 Update walle.conf 2019-12-06 02:31:30 +08:00
midoks d795097290 Update install.sh 2019-12-06 00:12:14 +08:00
midoks 084a21a071 Update install.sh 2019-12-06 00:04:13 +08:00
midoks 590a13256d up 2019-12-05 23:52:04 +08:00
midoks 49c2250900 Update config_api.py 2019-11-30 21:41:03 +08:00
midoks a6d70cd8a6 up 2019-11-30 18:28:34 +08:00
midoks ed6d8e0d34 up 2019-11-30 18:02:21 +08:00
midoks c0f37ceb08 up 2019-11-30 17:38:50 +08:00
midoks d2160f388d up 2019-11-30 16:55:45 +08:00
midoks 1617bd521a up 2019-11-30 01:24:28 +08:00
midoks 15e475d667 up 2019-11-29 23:59:50 +08:00
midoks ed779fd026 up 2019-11-29 23:00:04 +08:00
midoks 214634606f Update yar.sh 2019-11-29 22:08:38 +08:00
midoks afaecef2d7 up 2019-11-29 21:51:49 +08:00
midoks c76920f531 up 2019-11-29 20:22:45 +08:00
midoks 1657823988 Update swoole.sh 2019-11-29 19:30:46 +08:00
midoks df9c7928ae up 2019-11-29 19:27:08 +08:00
midoks f44710c0f1 update 2019-11-29 19:22:16 +08:00
midoks adbfe2fdef up 2019-11-29 18:29:23 +08:00
midoks 910198ffc3 swoole 4.4.12 2019-11-29 18:14:45 +08:00
midoks 19a172347f Update yaf.sh 2019-11-29 17:51:41 +08:00
midoks ccf00d17f6 up 2019-11-29 17:41:55 +08:00
midoks 1ac01637ef up 2019-11-29 17:21:38 +08:00
midoks 3861de61aa up 2019-11-29 16:58:45 +08:00
midoks 549686b9ef up 2019-11-29 16:36:09 +08:00
midoks c484fd5136 updated 2019-11-29 16:25:44 +08:00
midoks 1f3cb33bd2 up 2019-11-29 15:52:49 +08:00
midoks 438628c773 Update install.sh 2019-11-23 17:53:39 +08:00
midoks aeac132b09 up 2019-11-22 13:37:34 +08:00
midoks 8664186f7c Update install.sh 2019-11-22 13:30:13 +08:00
midoks 07e716c95f up 2019-11-22 13:25:24 +08:00
midoks 092b9ed4e8 up 2019-11-22 13:24:14 +08:00
midoks 2ae578a010 Update install.sh 2019-11-22 13:13:19 +08:00
midoks df14029aa9 Update lib.sh 2019-11-22 13:05:39 +08:00
midoks 4b3c44cc18 Update install_centos.sh 2019-10-03 01:58:24 +08:00
midoks 859df3cb04 说明 2019-09-26 21:08:53 +08:00
midoks 51485fcabb Update index.py 2019-09-25 19:43:59 +08:00
midoks 43d2dcb81c up 2019-09-14 00:26:03 +08:00
midoks 9d020beff0 Update index.html 2019-09-14 00:06:48 +08:00
midoks 02af143025 up 2019-09-14 00:03:22 +08:00
midoks 826bf7f540 Update update_centos.sh 2019-09-13 18:49:32 +08:00
midoks 8f4b72d551 Update index.py 2019-09-13 01:43:05 +08:00
midoks 67dbfc8569 Update index.py 2019-09-13 01:42:30 +08:00
midoks 71c7a38297 Update rsyncd.tpl 2019-09-13 01:30:24 +08:00
midoks 7c3ba76494 Update index.py 2019-09-13 00:02:55 +08:00
midoks a223f1e722 Update rsyncd.tpl 2019-09-12 23:55:25 +08:00
midoks a71d0b5a55 Update rsyncd.tpl 2019-09-12 23:46:15 +08:00
midoks 37cb8c3898 Update rsyncd.tpl 2019-09-12 23:31:29 +08:00
midoks c3b4fffd17 Update README.md 2019-09-12 23:21:39 +08:00
midoks b3c917f456 Update solr.tpl 2019-09-12 23:12:41 +08:00
midoks 7f58398a43 Update rsyncd.tpl 2019-09-12 22:57:27 +08:00
midoks 777eb0c4a2 Update rsyncd.tpl 2019-09-12 22:56:32 +08:00
midoks 9c69443e2f Update index.py 2019-09-12 22:51:51 +08:00
midoks 440f68529c Update index.py 2019-09-12 22:49:35 +08:00
midoks 50706f9286 up 2019-09-12 22:38:34 +08:00
midoks 44e3434b6d Update index.py 2019-09-12 18:48:57 +08:00
midoks a096631ab0 update 2019-09-06 21:06:12 +08:00
midoks 25ee8ab83b Update memcached.sh 2019-09-06 21:03:35 +08:00
midoks 28a9fdcdc8 update 2019-08-26 22:14:22 +08:00
midoks ee12d11709 up 2019-08-26 19:16:38 +08:00
midoks 6db083584e Update install.sh 2019-08-26 18:50:05 +08:00
midoks d833c9b441 up 2019-08-25 14:27:34 +08:00
midoks 7c2e77dbc5 Update web.xml 2019-08-23 12:15:06 +08:00
midoks 2e0dcb9b00 Update web.xml 2019-08-23 11:54:06 +08:00
midoks 6063ce9fcb 配置更新 2019-08-23 11:53:56 +08:00
midoks 2d6c2e8f9c Update solr.js 2019-08-22 21:11:28 +08:00
midoks e6b9427b3a Update solr.js 2019-08-22 21:02:44 +08:00
midoks 6a0a53ce7e up 2019-08-20 19:11:01 +08:00
midoks 5cec4d5c82 Update solrconfig.xml 2019-08-20 18:51:07 +08:00
midoks 0d403c9c8f up 2019-08-20 18:46:32 +08:00
midoks c1e66ba5a7 Update .gitignore 2019-08-20 18:33:18 +08:00
midoks 94c3d7d2e2 更新 2019-08-20 18:32:30 +08:00
midoks 202cfdb628 Create solrconfig.xml 2019-08-20 16:23:12 +08:00
midoks d9176781ab Update install.sh 2019-08-20 15:55:09 +08:00
midoks 0979dc67e8 Update install.sh 2019-08-20 14:03:52 +08:00
midoks 2e02f6d274 Update install.sh 2019-08-20 14:01:02 +08:00
midoks 3893f057e1 Update info.json 2019-08-20 12:44:11 +08:00
midoks 7a25982022 Update index.py 2019-08-18 20:09:35 +08:00
Mr Chen 824abad8e5 Update go-fastdfs.tpl 2019-08-07 17:09:05 +08:00
Mr Chen 94239e2e44 go-fastdfs-web 2019-08-07 16:36:53 +08:00
Mr Chen 72f1d1c43a Update index.py 2019-08-07 16:09:27 +08:00
midoks a026da484f Update full.py 2019-08-06 23:35:39 +08:00
midoks 2e5c5efde7 Update full.py 2019-08-06 22:49:49 +08:00
midoks 72edb784db Update full.py 2019-08-06 22:49:37 +08:00
midoks 53c66ed216 Update full.py 2019-08-06 22:24:15 +08:00
midoks f510735231 Update full.py 2019-08-06 22:22:45 +08:00
midoks e6ea2737c0 up 2019-08-06 21:21:41 +08:00
midoks 65e84830a2 Update full.py 2019-08-06 20:08:52 +08:00
Mr Chen 687decec5f solr全量同步脚本 2019-08-06 19:09:23 +08:00
Mr Chen 967ca42c6b Create full.py 2019-08-06 19:05:27 +08:00
Mr Chen 457f861ee0 Update solr.js 2019-08-06 14:13:27 +08:00
Mr Chen 572a8d82b0 Update solr.js 2019-08-06 14:09:28 +08:00
midoks 0cbf7bb65a Update index.py 2019-08-06 00:35:25 +08:00
midoks 647c997a21 Update index.py 2019-08-06 00:31:45 +08:00
midoks 1575e2976b Update install.sh 2019-08-06 00:19:49 +08:00
midoks 9198799caa Update index.py 2019-08-06 00:14:29 +08:00
midoks e766058c57 Update index.py 2019-08-05 23:54:05 +08:00
midoks d7c758ccd5 Update index.py 2019-08-05 22:54:47 +08:00
midoks ed3f29b824 Update index.py 2019-08-05 22:49:08 +08:00
midoks 789bd8fd70 Update install.sh 2019-08-05 22:32:53 +08:00
midoks c4f11af537 Update index.py 2019-08-05 22:30:07 +08:00
midoks fe939bc073 Update install.sh 2019-08-05 22:29:21 +08:00
midoks ae18a12894 Update install.sh 2019-08-05 22:21:20 +08:00
midoks 0f51e27a14 Update install.sh 2019-08-05 22:10:31 +08:00
midoks 3409849c4a init 2019-08-05 15:20:01 +08:00
midoks 72900d7df6 修复错误 2019-08-05 13:21:33 +08:00
midoks 2dae8ff902 fastdfs ok 2019-08-03 13:23:34 +08:00
midoks b1dbaf1d6d Update index.py 2019-08-03 11:03:45 +08:00
midoks 7bd49e6de1 up 2019-08-03 11:00:59 +08:00
midoks a63bf8c39a up 2019-08-03 01:58:28 +08:00
midoks 8e14e0c82f Update go-fastdfs.tpl 2019-08-02 23:42:01 +08:00
midoks e631259caa up 2019-08-02 22:35:24 +08:00
midoks ff7b6a52e6 Update install.sh 2019-08-02 21:00:50 +08:00
midoks f336d977ef Update install.sh 2019-08-02 20:26:32 +08:00
Mr Chen 3b9d2c8c37 Update fastdfs.js 2019-08-02 19:03:45 +08:00
Mr Chen 22699b9d6b up 2019-08-02 19:01:53 +08:00
Mr Chen 2468e8ca6b Update install.sh 2019-08-02 18:58:45 +08:00
Mr Chen dfad245187 Update install.sh 2019-08-02 17:56:18 +08:00
Mr Chen 3d2bc25355 update 2019-08-02 17:47:07 +08:00
Mr Chen 1f4095fa65 update 2019-08-02 17:46:05 +08:00
Mr Chen 6898193218 Update solr.js 2019-08-02 17:30:11 +08:00
Mr Chen fccf4fcd5b solr基本ok 2019-08-02 17:28:44 +08:00
Mr Chen 183b142203 web管理 2019-08-02 13:46:51 +08:00
Mr Chen 70e87ff5d6 优化 2019-08-02 13:46:42 +08:00
Mr Chen 77174243ed 安装即下载mysql-connector-java
mysql-connector-java-5.1.48.jar
mysql-connector-java-8.0.17.jar
2019-08-02 13:03:50 +08:00
midoks db4136ef62 Update __init__.py 2019-08-02 08:30:14 +08:00
midoks 220ca5a0a2 Update info.json 2019-08-01 23:52:17 +08:00
midoks 9bdf449d38 Update info.json 2019-08-01 23:14:21 +08:00
midoks e2be44ad78 Update info.json 2019-08-01 23:09:13 +08:00
midoks 3913a77265 Update info.json 2019-08-01 23:08:27 +08:00
midoks f395469a09 Update info.json 2019-08-01 23:07:46 +08:00
midoks 0101516935 Update info.json 2019-08-01 23:06:45 +08:00
midoks d726fca5d0 solr 配置文件 2019-08-01 22:56:22 +08:00
midoks 39902363ab Update solr.js 2019-08-01 22:09:07 +08:00
midoks 4b93a7e3a1 Update info.json 2019-08-01 21:11:38 +08:00
Mr Chen 9152fca0c9 solr delete ok 2019-08-01 19:05:30 +08:00
Mr Chen e5393b2127 solr add ok 2019-08-01 17:09:23 +08:00
Mr Chen 034939a0c5 solr add 2019-08-01 16:46:34 +08:00
Mr Chen d35c6bb02f Update index.py 2019-08-01 15:32:17 +08:00
Mr Chen 56746d9c01 Update phpmyadmin.conf 2019-08-01 11:07:12 +08:00
midoks b2fe702d51 Update index.py 2019-07-31 23:54:44 +08:00
midoks c6282d5660 Update index.py 2019-07-31 23:46:24 +08:00
midoks a2851b2787 Update index.py 2019-07-31 23:45:28 +08:00
midoks 26f41228db Update setting.py 2019-07-31 21:42:52 +08:00
midoks f5cb06ea53 Update setting.py 2019-07-31 21:42:29 +08:00
midoks a16441e87d Update requirements.txt 2019-07-31 20:25:35 +08:00
Mr Chen 3b4601e083 php安装脚本加入
--no-check-certificate
2019-07-31 17:56:39 +08:00
Mr Chen 556f8175e8 Update install.sh 2019-07-31 17:53:04 +08:00
Mr Chen 13d6128e39 Update requirements.txt 2019-07-31 17:49:45 +08:00
Mr Chen 3bd56d161a Update install_centos.sh 2019-07-31 17:36:48 +08:00
Mr Chen eed88c721e Update install_centos.sh 2019-07-31 17:34:32 +08:00
Mr Chen 0fbb507b07 Update README.md 2019-07-25 11:41:03 +08:00
Mr Chen 57516929c1 u 2019-07-22 16:44:01 +08:00
Mr Chen a8d6a7eaf2 l2tp 2019-07-22 16:43:40 +08:00
Mr Chen 49022b2f57 更新PHP版本 2019-05-22 13:07:25 +08:00
midoks a7cd64a54c Update index.py 2019-05-18 15:28:09 +08:00
midoks db4a7af2b5 Update install_centos.sh 2019-05-18 14:35:40 +08:00
midoks c746876026 Update install_centos.sh 2019-05-18 14:34:56 +08:00
midoks 7578aa32ae Update install_centos.sh 2019-05-18 14:34:38 +08:00
Mr Chen 9cae0dc4ab 修改提示地址 2019-05-06 14:53:37 +08:00
Mr Chen cc97c6299d update 2019-05-06 14:35:15 +08:00
Mr Chen e6e0f7dea7 up 2019-05-06 14:04:38 +08:00
Mr Chen bdfcf9179d up 2019-05-06 13:40:48 +08:00
Mr Chen cdb50b681f Update init.lua 2019-05-06 13:27:01 +08:00
Mr Chen 8ca50abb0c Update init.lua 2019-05-06 13:21:46 +08:00
Mr Chen 0196a7a622 优化 2019-05-06 13:11:00 +08:00
Mr Chen 835a575535 update 2019-05-06 12:23:58 +08:00
Mr Chen d54d123850 update 2019-05-06 12:22:43 +08:00
Mr Chen 83f033427d Update op_waf.js 2019-05-06 10:46:48 +08:00
Mr Chen de8242e5e5 update 2019-05-06 10:41:51 +08:00
midoks 8f416db0ad up 2019-05-05 22:01:40 +08:00
midoks 2323cbdf77 update 2019-05-05 21:35:29 +08:00
midoks 925bb15d7b Update task.py 2019-05-05 20:46:23 +08:00
Mr Chen 50e18bb3d9 up 2019-05-05 19:00:39 +08:00
Mr Chen c15b97f2ba update 2019-05-05 17:17:38 +08:00
Mr Chen f367f10d02 update 2019-05-05 14:12:30 +08:00
Mr Chen 9ee3e2a88e Update op_waf.js 2019-05-05 13:02:37 +08:00
midoks 5e0f877d20 Update index.py 2019-05-04 20:54:42 +08:00
midoks 6e3d9e6983 up 2019-05-04 20:41:10 +08:00
midoks b1d04333bf up 2019-05-04 19:33:50 +08:00
midoks 1af55a1dd3 up 2019-05-04 11:44:27 +08:00
midoks 5f9cee95e6 Update op_waf.js 2019-05-03 23:50:28 +08:00
midoks f139587464 up 2019-05-03 23:21:33 +08:00
midoks 0f2ee7ae54 Update op_waf.js 2019-05-02 15:41:57 +08:00
midoks eff62918ba up 2019-05-02 10:59:08 +08:00
midoks 345808c200 update 2019-05-01 17:23:37 +08:00
midoks 15eabc51cb Update op_waf.js 2019-05-01 14:23:52 +08:00
midoks a7c6a89583 update 2019-05-01 12:34:18 +08:00
midoks 5acba5ad76 update 2019-04-30 23:53:13 +08:00
Mr Chen 40f782c602 Update index.py 2019-04-30 20:29:06 +08:00
Mr Chen 1c0ac62b4f op 2019-04-30 18:11:58 +08:00
midoks 3d13ab9096 Update .gitignore 2019-04-30 00:14:25 +08:00
midoks 29bdbf0d5e up 2019-04-30 00:14:07 +08:00
midoks 555fdb4ff0 Update op_waf.js 2019-04-29 22:19:32 +08:00
Mr Chen 541d74fc71 update 2019-04-29 19:20:31 +08:00
Mr Chen aee77b2ec6 优化 2019-04-29 15:17:54 +08:00
Mr Chen fdbc8ad689 update 2019-04-29 10:29:52 +08:00
Mr Chen 3200412e0b 响应内容优化 2019-04-28 16:48:47 +08:00
midoks 39af5b6702 Update op_waf.js 2019-04-28 00:13:20 +08:00
midoks c18f3c11f6 Update op_waf.js 2019-04-27 23:53:12 +08:00
midoks f5e55d4f58 update 2019-04-27 22:02:31 +08:00
midoks 2438d2ab61 update 2019-04-27 20:21:26 +08:00
midoks 7bd906d374 Update init.lua 2019-04-27 17:59:20 +08:00
midoks 6a326649f9 update 2019-04-27 17:56:25 +08:00
midoks 72636d598f update 2019-04-27 17:54:09 +08:00
midoks bd6635ee09 u 2019-04-27 16:44:52 +08:00
midoks ef9bb2c4a6 uu 2019-04-27 16:44:46 +08:00
midoks f8f892e323 Update config.json 2019-04-27 16:44:26 +08:00
midoks 7eeec1625b uu 2019-04-27 13:02:21 +08:00
midoks 26a33573fd u 2019-04-27 09:37:33 +08:00
midoks 72c7044465 up 2019-04-27 09:30:52 +08:00
midoks 5191c711c3 update 2019-04-26 23:59:22 +08:00
midoks 6a536c14fd uu 2019-04-26 23:47:48 +08:00
Mr Chen 63a965f978 ii 2019-04-26 19:27:45 +08:00
Mr Chen e2b4c330fc 优化 2019-04-26 18:03:12 +08:00
Mr Chen 02431fdd9e update 2019-04-26 15:58:58 +08:00
Mr Chen 7a8bd83ab8 update 2019-04-26 15:12:57 +08:00
Mr Chen 3475dd5036 uu 2019-04-26 13:58:07 +08:00
midoks 8771059682 Update op_waf.js 2019-04-25 23:45:12 +08:00
midoks 48990384df Create total.json 2019-04-25 23:17:28 +08:00
Mr Chen 0c84f0da80 oo 2019-04-25 18:03:00 +08:00
Mr Chen a1d701cd9f 防火墙插件优化 2019-04-25 17:47:19 +08:00
Mr Chen b23315f19b 删除防火墙栏目 2019-04-25 17:47:05 +08:00
midoks 0ee844ee5b Update index.html 2019-04-25 00:02:06 +08:00
midoks 0d4d20553d delete 2019-04-24 23:44:03 +08:00
midoks 457a86b742 Update site_api.py
防跨站攻击(open_basedir) 手动设置生效,不自动生效
2019-04-24 23:40:55 +08:00
midoks 3482d5cb3e 优化 2019-04-24 22:07:54 +08:00
Mr Chen 4ce30ff46e waf dev 2019-04-24 19:24:20 +08:00
Mr Chen bceec90de4 up 2019-04-24 14:11:37 +08:00
midoks 3e396f9e60 waf 2019-04-24 00:15:01 +08:00
midoks 9370884eb5 uu 2019-04-22 22:31:51 +08:00
midoks 8627925274 waf init 2019-04-22 21:21:49 +08:00
Mr Chen 2bfb240c7f update 2019-04-22 13:46:13 +08:00
Mr Chen acbf965f94 uu 2019-04-22 11:33:29 +08:00
midoks 74800f70bc sphinx模板配置优化 2019-04-21 23:59:41 +08:00
midoks 003c8f856c yar-update 2019-04-21 23:36:07 +08:00
midoks 29c3557c66 Update soft.js 2019-04-21 18:54:18 +08:00
midoks f7f8a5042a Update install.sh 2019-04-21 18:38:06 +08:00
midoks 19911de04f Update install.sh 2019-04-21 18:27:47 +08:00
midoks 954df1b522 up 2019-04-21 18:22:31 +08:00
midoks e1d6a16672 Update soft.js 2019-04-21 18:02:18 +08:00
midoks 536138b9ce 设置默认地址-DONE 2019-04-19 23:18:35 +08:00
Mr Chen 33e311f98e 优化重启和任务功能 2019-04-19 10:37:02 +08:00
Mr Chen 66c542dbc8 默认文档修改 2019-04-18 17:19:53 +08:00
Mr Chen bd333d9854 php 添加yar扩展 2019-04-18 15:26:58 +08:00
Mr Chen ecad6fe891 Update app.ini 2019-04-17 13:38:53 +08:00
midoks f709bef197 Update install.sh 2019-04-09 23:18:51 +08:00
Mr Chen 980392b811 php7+,支持pdo_mysql 2019-04-03 17:50:21 +08:00
Mr Chen 497217446b php7+,支持mysqli 2019-04-03 16:23:06 +08:00
midoks f82c66a6bd Update qbittorrent.conf 2019-04-03 00:46:40 +08:00
midoks e1c10caf81 Update qbittorrent.conf 2019-04-03 00:44:27 +08:00
midoks bdea272028 增sphinx事例 2019-04-03 00:42:42 +08:00
Mr Chen e6e6dab8f6 update 2019-04-02 17:36:03 +08:00
Mr Chen 03655f16eb Update install_centos.sh 2019-04-02 16:46:46 +08:00
Mr Chen b11f8793e3 提前处理了 2019-04-02 16:42:44 +08:00
Mr Chen 595219da19 Update index.py 2019-04-02 15:53:47 +08:00
Mr Chen 735aa7224b Update requirements.txt 2019-04-02 15:17:58 +08:00
Mr Chen 8a522c43e5 优化rsyncd启动配置 2019-04-02 15:13:41 +08:00
Mr Chen c5b6df846b Update requirements.txt 2019-04-02 14:09:31 +08:00
Mr Chen 4326e2c7ca Update update_centos.sh 2019-04-02 14:09:04 +08:00
Mr Chen d899e332e0 Update update_centos.sh 2019-04-02 14:08:12 +08:00
Mr Chen 0eeedf22ea Update mw.tpl 2019-04-02 14:07:28 +08:00
Mr Chen c56e487e8d Update requirements.txt 2019-04-02 14:04:11 +08:00
Mr Chen 0d753f0c9d Update requirements.txt 2019-04-02 14:03:51 +08:00
Mr Chen 9a3855f2df Update bbr.sh 2019-04-02 13:56:23 +08:00
Mr Chen 7d4a0bb1d4 PHP-00 配置文件支持3 2019-04-02 13:48:12 +08:00
Mr Chen 49be7f3779 PHP-00 配置文件支持2 2019-04-02 13:42:10 +08:00
Mr Chen 01288d2fa9 PHP-00 配置文件支持 2019-04-02 13:30:27 +08:00
Mr Chen 527a1a70c8 Update index.py 2019-04-02 13:29:35 +08:00
Mr Chen cfe1b29518 Update requirements.txt 2019-04-02 13:07:14 +08:00
Mr Chen c0335f0936 Update requirements.txt 2019-04-02 12:54:59 +08:00
Mr Chen f1156b221d Update requirements.txt 2019-04-02 12:49:51 +08:00
Mr Chen 43c260522c Update install_centos.sh 2019-04-02 12:46:01 +08:00
midoks 2272242493 Update index.py 2019-03-30 12:01:19 +08:00
midoks 4bc68d1f17 Update index.py 2019-03-30 12:00:59 +08:00
midoks 3f0957e3df Update index.py 2019-03-30 11:58:34 +08:00
midoks 77c5ead2b6 Update index.py 2019-03-30 11:46:15 +08:00
midoks 19674add02 Update index.py 2019-03-30 11:43:31 +08:00
midoks 064bd1a810 Update index.py 2019-03-30 11:34:16 +08:00
midoks 1f11d6b622 Update index.py 2019-03-30 11:33:09 +08:00
midoks e5374afee3 Update install.sh 2019-03-30 11:30:17 +08:00
midoks c874c3e6b2 update 2019-03-30 11:28:08 +08:00
midoks bdc5c7b85c Update bbr.js 2019-03-30 11:23:54 +08:00
midoks 9b55c92dc2 Update bbr.js 2019-03-30 11:20:50 +08:00
midoks b838831970 Update bbr.js 2019-03-30 11:20:00 +08:00
midoks 21fcf429b6 Update index.html 2019-03-30 11:19:01 +08:00
midoks 8d19106412 Update info.json 2019-03-30 11:12:29 +08:00
midoks 4b6460bd5b Update bbr.js 2019-03-30 11:11:20 +08:00
midoks 5c5cddd1bf 优化 2019-03-30 01:50:34 +08:00
Mr Chen 5b6db26617 修复展示路径 2019-03-29 17:36:51 +08:00
Mr Chen a40fc46f47 修复展示路径 2019-03-29 17:36:21 +08:00
Mr Chen 490daa14de Update rsyncd.conf 2019-03-29 16:44:31 +08:00
Mr Chen a022ea419f Update index.py 2019-03-29 16:43:54 +08:00
Mr Chen 54c6ab3f08 Update files_api.py 2019-03-29 14:59:03 +08:00
Mr Chen 83a9accf0f 优化说明 2019-03-29 14:36:46 +08:00
Mr Chen 956e3b3ca2 update 2019-03-29 13:56:30 +08:00
midoks 83cf0c2604 0.7.3 2019-03-29 01:14:01 +08:00
midoks 7999108b91 减小图片大小 2019-03-29 01:10:00 +08:00
midoks b80de25598 减小图片大小 2019-03-29 01:05:11 +08:00
midoks 7c25ae0ec2 BBR[DEV] 2019-03-29 01:02:58 +08:00
Mr Chen 84e9c4a484 Update README.md 2019-03-28 17:21:44 +08:00
Mr Chen 5178e11e44 截图 2019-03-28 17:20:00 +08:00
midoks 0e7c2769c8 修复bug
retJson
2019-03-27 00:30:43 +08:00
midoks 6651a706b7 Update files_api.py 2019-03-27 00:14:53 +08:00
midoks a81f922592 Update .gitignore 2019-03-27 00:11:45 +08:00
Mr Chen 2b87887054 批量复制|剪切|权限|压缩优化 2019-03-26 16:46:52 +08:00
midoks 7859bfb451 修复更新检查判断 2019-03-26 00:14:53 +08:00
midoks 35369f8f41 部分优化 2019-03-25 23:31:51 +08:00
midoks a47166d547 Update files_api.py 2019-03-25 21:46:57 +08:00
midoks 457a69b34a Update config_api.py 2019-03-25 21:45:09 +08:00
midoks 881f571902 Update files.js 2019-03-25 21:44:53 +08:00
midoks d889c3305f Update files.js 2019-03-25 21:43:31 +08:00
midoks cb793d5f3f 0.7.0
fix
2019-03-25 21:42:49 +08:00
Mr Chen b4882aa0fc 优化配置 2019-03-25 10:52:09 +08:00
Mr Chen ef3b5b2a6c Create video.conf 2019-03-20 16:49:35 +08:00
Mr Chen d4501b736b 优化sphinx 2019-03-20 16:49:17 +08:00
Mr Chen 261e24390f 优先显示 2019-03-19 17:26:14 +08:00
Mr Chen 10abbd7efd 调整时间 2019-03-19 16:38:25 +08:00
Mr Chen e2196735d9 Update task.py 2019-03-19 16:28:59 +08:00
Mr Chen dbbc243359 Update task.py 2019-03-19 16:23:37 +08:00
Mr Chen 94bb8e31cf Update task.py 2019-03-19 16:07:20 +08:00
Mr Chen 282bcccf39 优化 2019-03-19 16:06:20 +08:00
Mr Chen 886f6c2369 优化PHP插件
启动时,就配置php-fpm配置文件
2019-03-19 15:49:59 +08:00
Mr Chen ab822f0572 Update task.py 2019-03-19 15:27:02 +08:00
Mr Chen 4ec2355182 添加PHP守护插件 2019-03-19 15:14:50 +08:00
midoks a4237ca213 Update task.py 2019-03-18 22:49:21 +08:00
midoks 4615b70c60 Update firewall_api.py
关闭防火墙-删除自启动
开启防火墙-添加自启动
2019-03-18 21:30:31 +08:00
Mr Chen 97b9d12769 gogs修改
post-receive很少修改。
commit 修改比较多
2019-03-18 15:17:41 +08:00
Mr Chen 35a7c2d96f 权限设置修复 2019-03-18 14:42:04 +08:00
Mr Chen 11ea1e2e1f 删除PHPmysqlAdmin未解决方案 2019-03-18 14:20:07 +08:00
Mr Chen 1860dda320 登陆提示优化 2019-03-18 11:20:56 +08:00
Mr Chen 5610b1b1da Update setting.py 2019-03-15 18:02:09 +08:00
Mr Chen 422dea0e3f Update info.json 2019-03-15 17:48:31 +08:00
Mr Chen d52a355cc9 Update config_api.py 2019-03-15 17:45:55 +08:00
Mr Chen 389d87c2b5 Update index.py 2019-03-15 17:44:33 +08:00
Mr Chen 7ef8322731 Update index.py 2019-03-15 17:42:27 +08:00
Mr Chen d1a0b32bf6 Update gogs.tpl 2019-03-15 17:24:56 +08:00
Mr Chen 295cb399e3 Update gogs.tpl 2019-03-15 17:15:06 +08:00
Mr Chen db9477c22e Update install_centos.sh 2019-03-15 17:05:50 +08:00
Mr Chen b2ae6b67d6 Update install_centos.sh 2019-03-15 16:58:10 +08:00
Mr Chen bf5f0cecff Update config_api.py 2019-03-15 16:54:55 +08:00
Mr Chen 251503952d sphinx 自启动 done 2019-03-15 16:54:00 +08:00
Mr Chen 60445a565d pureftp 自启动 done 2019-03-15 16:50:20 +08:00
Mr Chen 6a8db02aa7 redis 自启动 done 2019-03-15 16:47:55 +08:00
Mr Chen ac50b335c3 memcached 自启动 done 2019-03-15 16:45:15 +08:00
Mr Chen c9826d5daf mysql 自启动done 2019-03-15 16:02:59 +08:00
Mr Chen ada8225e05 update 2019-03-15 15:23:54 +08:00
Mr Chen 613ca4bce0 Update index.py 2019-03-15 14:53:08 +08:00
Mr Chen 1bdfb0625a openresty 自启动 2019-03-15 14:52:18 +08:00
Mr Chen ad2e33fcd2 Update common.py 2019-03-15 14:43:00 +08:00
Mr Chen 6e846a4a51 Update common.py 2019-03-15 14:42:38 +08:00
Mr Chen dc76f0ca33 chkconfig自启动需要 2019-03-15 14:33:33 +08:00
Mr Chen c619f00c54 Update README.md 2019-03-14 17:14:28 +08:00
Mr Chen 015b132b85 update 2019-03-14 15:29:09 +08:00
Mr Chen 4e4b4ad308 Update info.json 2019-03-14 14:29:41 +08:00
Mr Chen 1226caaa39 Update update_centos.sh 2019-03-14 14:21:14 +08:00
Mr Chen 5a92027f20 Update update_centos.sh 2019-03-14 14:21:01 +08:00
Mr Chen ea6ed08461 Update update_centos.sh 2019-03-14 14:20:43 +08:00
693 changed files with 40388 additions and 4304 deletions
+6 -3
View File
@@ -116,7 +116,10 @@ data/iplist.txt
data/json/index.json data/json/index.json
data/json/config.json data/json/config.json
data/site.pl data/site.pl
data/admin_path.pl data/admin_path.pl
data/close.pl data/close.pl
ssl/input.pl ssl/input.pl
data/datadir.pl data/datadir.pl
data/502Task.pl
data/default.pl
data/backup.pl
+34 -2
View File
@@ -1,5 +1,31 @@
# mdserver-web ### mdserver-web 0.8.6
简单的Linux面板 简单的Linux面板,感谢BT.CN写出如此好的web管理软件。我一看到,就知道这是我一直想要的页面化管理方式。
复制了后台管理界面,按照自己想要的方式写了一版。
* ssh工具优化
* 面板收藏功能完成
* 网站子目录绑定
* 网站备份功能
* 自动更新优化
* 插件方式管理
基本上可以使用,后续会继续优化!欢迎提供意见!
### 主要插件介绍
* OpenResty - 轻量级,占有内存少,并发能力强。
* PHP[52-80] - PHP是世界上最好的编程语言。
* MySQL - MySQL是一种关系数据库管理系统。
* phpMyAdmin - 著名Web端MySQL管理工具。
* Memcached - 一个高性能的分布式内存对象缓存系统。
* Redis - 一个高性能的key-value数据库。
* CSVN - 最流行的SVN代码共享管理软件。
* PureFtpd - 一款专注于程序健壮和软件安全的免费FTP服务器软件。
* Gogs - 一款极易搭建的自助Git服务。
* Rsyncd - 通用同步服务。
### 版本更新 0.8.6
* mysql主从配置。
* swap插件[虚拟内存]。
### 自动安装 ### 自动安装
``` ```
@@ -12,3 +38,9 @@ curl -fsSL https://raw.githubusercontent.com/midoks/mdserver-web/master/scripts
curl -fsSL https://raw.githubusercontent.com/midoks/mdserver-web/master/scripts/update.sh | sh curl -fsSL https://raw.githubusercontent.com/midoks/mdserver-web/master/scripts/update.sh | sh
``` ```
### 无图不真相
[![截图](/route/static/mdw.jpg)](/route/static/mdw.jpg)
### wiki
[了解更多...](https://github.com/midoks/mdserver-web/wiki)
+20 -16
View File
@@ -13,7 +13,7 @@ import re
import hashlib import hashlib
from random import Random from random import Random
import public import mw
import db import db
from flask import redirect from flask import redirect
@@ -41,7 +41,7 @@ def checkClose():
def initDB(): def initDB():
try: try:
sql = db.Sql().dbfile('default') sql = db.Sql().dbfile('default')
csql = public.readFile('data/sql/default.sql') csql = mw.readFile('data/sql/default.sql')
csql_list = csql.split(';') csql_list = csql.split(';')
for index in range(len(csql_list)): for index in range(len(csql_list)):
sql.execute(csql_list[index], ()) sql.execute(csql_list[index], ())
@@ -51,31 +51,35 @@ def initDB():
def initInitD(): def initInitD():
script = public.getRunDir() + '/scripts/init.d/mw.tpl' script = mw.getRunDir() + '/scripts/init.d/mw.tpl'
script_bin = public.getRunDir() + '/scripts/init.d/mw' script_bin = mw.getRunDir() + '/scripts/init.d/mw'
# if os.path.exists(script_bin): # if os.path.exists(script_bin):
# return # return
content = public.readFile(script) content = mw.readFile(script)
content = content.replace("{$SERVER_PATH}", public.getRunDir()) content = content.replace("{$SERVER_PATH}", mw.getRunDir())
public.writeFile(script_bin, content) mw.writeFile(script_bin, content)
public.execShell('chmod +x ' + script_bin) mw.execShell('chmod +x ' + script_bin)
if not public.isAppleSystem(): mw.setHostAddr(mw.getLocalIp())
if not mw.isAppleSystem():
initd_bin = '/etc/init.d/mw' initd_bin = '/etc/init.d/mw'
if not os.path.exists(initd_bin): if not os.path.exists(initd_bin):
import shutil import shutil
shutil.copyfile(script_bin, initd_bin) shutil.copyfile(script_bin, initd_bin)
public.execShell('chmod +x ' + initd_bin) mw.execShell('chmod +x ' + initd_bin)
# 加入自启动
mw.execShell('chkconfig --add mw')
def initUserInfo(): def initUserInfo():
data = public.M('users').where('id=?', (1,)).getField('password') data = mw.M('users').where('id=?', (1,)).getField('password')
if data == '21232f297a57a5a743894a0e4a801fc3': if data == '21232f297a57a5a743894a0e4a801fc3':
pwd = public.getRandomString(8).lower() pwd = mw.getRandomString(8).lower()
file_pw = public.getRunDir() + '/data/default.pl' file_pw = mw.getRunDir() + '/data/default.pl'
public.writeFile(file_pw, pwd) mw.writeFile(file_pw, pwd)
public.M('users').where('id=?', (1,)).setField( mw.M('users').where('id=?', (1,)).setField(
'password', public.md5(pwd)) 'password', mw.md5(pwd))
+99 -96
View File
@@ -4,7 +4,7 @@ import psutil
import time import time
import os import os
import sys import sys
import public import mw
import re import re
import json import json
import pwd import pwd
@@ -15,7 +15,10 @@ from flask import request
class config_api: class config_api:
__version = '0.4.2' # 本版解决自启动问题
# 文件管理重命名
# 优化计划任务管理
__version = '0.8.6'
def __init__(self): def __init__(self):
pass pass
@@ -24,9 +27,9 @@ class config_api:
# 取面板列表 # 取面板列表
def getPanelListApi(self): def getPanelListApi(self):
data = public.M('panel').field( data = mw.M('panel').field(
'id,title,url,username,password,click,addtime').order('click desc').select() 'id,title,url,username,password,click,addtime').order('click desc').select()
return public.getJson(data) return mw.getJson(data)
def addPanelInfoApi(self): def addPanelInfoApi(self):
title = request.form.get('title', '') title = request.form.get('title', '')
@@ -34,24 +37,24 @@ class config_api:
username = request.form.get('username', '') username = request.form.get('username', '')
password = request.form.get('password', '') password = request.form.get('password', '')
# 校验是还是重复 # 校验是还是重复
isAdd = public.M('panel').where( isAdd = mw.M('panel').where(
'title=? OR url=?', (title, url)).count() 'title=? OR url=?', (title, url)).count()
if isAdd: if isAdd:
return public.returnJson(False, '备注或面板地址重复!') return mw.returnJson(False, '备注或面板地址重复!')
isRe = public.M('panel').add('title,url,username,password,click,addtime', isRe = mw.M('panel').add('title,url,username,password,click,addtime',
(title, url, username, password, 0, int(time.time()))) (title, url, username, password, 0, int(time.time())))
if isRe: if isRe:
return public.returnJson(True, '添加成功!') return mw.returnJson(True, '添加成功!')
return public.returnJson(False, '添加失败!') return mw.returnJson(False, '添加失败!')
# 删除面板资料 # 删除面板资料
def delPanelInfoApi(self): def delPanelInfoApi(self):
mid = request.form.get('id', '') mid = request.form.get('id', '')
isExists = public.M('panel').where('id=?', (mid,)).count() isExists = mw.M('panel').where('id=?', (mid,)).count()
if not isExists: if not isExists:
return public.returnJson(False, '指定面板资料不存在!') return mw.returnJson(False, '指定面板资料不存在!')
public.M('panel').where('id=?', (mid,)).delete() mw.M('panel').where('id=?', (mid,)).delete()
return public.returnJson(True, '删除成功!') return mw.returnJson(True, '删除成功!')
# 修改面板资料 # 修改面板资料
def setPanelInfoApi(self): def setPanelInfoApi(self):
@@ -61,51 +64,51 @@ class config_api:
password = request.form.get('password', '') password = request.form.get('password', '')
mid = request.form.get('id', '') mid = request.form.get('id', '')
# 校验是还是重复 # 校验是还是重复
isSave = public.M('panel').where( isSave = mw.M('panel').where(
'(title=? OR url=?) AND id!=?', (title, url, mid)).count() '(title=? OR url=?) AND id!=?', (title, url, mid)).count()
if isSave: if isSave:
return public.returnJson(False, '备注或面板地址重复!') return mw.returnJson(False, '备注或面板地址重复!')
# 更新到数据库 # 更新到数据库
isRe = public.M('panel').where('id=?', (mid,)).save( isRe = mw.M('panel').where('id=?', (mid,)).save(
'title,url,username,password', (title, url, username, password)) 'title,url,username,password', (title, url, username, password))
if isRe: if isRe:
return public.returnJson(True, '修改成功!') return mw.returnJson(True, '修改成功!')
return public.returnJson(False, '修改失败!') return mw.returnJson(False, '修改失败!')
def syncDateApi(self): def syncDateApi(self):
if public.isAppleSystem(): if mw.isAppleSystem():
return public.returnJson(True, '开发系统不必同步时间!') return mw.returnJson(True, '开发系统不必同步时间!')
data = public.execShell('ntpdate -s time.nist.gov') data = mw.execShell('ntpdate -s time.nist.gov')
if data[0] == '': if data[0] == '':
return public.returnJson(True, '同步成功!') return mw.returnJson(True, '同步成功!')
return public.returnJson(False, '同步失败:' + data[0]) return mw.returnJson(False, '同步失败:' + data[0])
def setPasswordApi(self): def setPasswordApi(self):
password1 = request.form.get('password1', '') password1 = request.form.get('password1', '')
password2 = request.form.get('password2', '') password2 = request.form.get('password2', '')
if password1 != password2: if password1 != password2:
return public.returnJson(False, '两次输入的密码不一致,请重新输入!') return mw.returnJson(False, '两次输入的密码不一致,请重新输入!')
if len(password1) < 5: if len(password1) < 5:
return public.returnJson(False, '用户密码不能小于5位!') return mw.returnJson(False, '用户密码不能小于5位!')
public.M('users').where("username=?", (session['username'],)).setField( mw.M('users').where("username=?", (session['username'],)).setField(
'password', public.md5(password1.strip())) 'password', mw.md5(password1.strip()))
return public.returnJson(True, '密码修改成功!') return mw.returnJson(True, '密码修改成功!')
def setNameApi(self): def setNameApi(self):
name1 = request.form.get('name1', '') name1 = request.form.get('name1', '')
name2 = request.form.get('name2', '') name2 = request.form.get('name2', '')
if name1 != name2: if name1 != name2:
return public.returnJson(False, '两次输入的用户名不一致,请重新输入!') return mw.returnJson(False, '两次输入的用户名不一致,请重新输入!')
if len(name1) < 3: if len(name1) < 3:
return public.returnJson(False, '用户名长度不能少于3位') return mw.returnJson(False, '用户名长度不能少于3位')
public.M('users').where("username=?", (session['username'],)).setField( mw.M('users').where("username=?", (session['username'],)).setField(
'username', name1.strip()) 'username', name1.strip())
session['username'] = name1 session['username'] = name1
return public.returnJson(True, '用户修改成功!') return mw.returnJson(True, '用户修改成功!')
def setApi(self): def setApi(self):
webname = request.form.get('webname', '') webname = request.form.get('webname', '')
@@ -118,34 +121,34 @@ class config_api:
if domain != '': if domain != '':
reg = "^([\w\-\*]{1,100}\.){1,4}(\w{1,10}|\w{1,10}\.\w{1,10})$" reg = "^([\w\-\*]{1,100}\.){1,4}(\w{1,10}|\w{1,10}\.\w{1,10})$"
if not re.match(reg, domain): if not re.match(reg, domain):
return public.returnJson(False, '主域名格式不正确') return mw.returnJson(False, '主域名格式不正确')
if int(port) >= 65535 or int(port) < 100: if int(port) >= 65535 or int(port) < 100:
return public.returnJson(False, '端口范围不正确!') return mw.returnJson(False, '端口范围不正确!')
if webname != public.getConfig('title'): if webname != mw.getConfig('title'):
public.setConfig('title', webname) mw.setConfig('title', webname)
if sites_path != public.getWwwDir(): if sites_path != mw.getWwwDir():
public.setWwwDir(sites_path) mw.setWwwDir(sites_path)
if backup_path != public.getWwwDir(): if backup_path != mw.getWwwDir():
public.setBackupDir(backup_path) mw.setBackupDir(backup_path)
if port != public.getHostPort(): if port != mw.getHostPort():
import system_api import system_api
public.setHostPort(port) mw.setHostPort(port)
system_api.system_api().restartMw() system_api.system_api().restartMw()
if host_ip != public.getHostAddr(): if host_ip != mw.getHostAddr():
public.setHostAddr(host_ip) mw.setHostAddr(host_ip)
mhost = public.getHostAddr() mhost = mw.getHostAddr()
info = { info = {
'uri': '/config', 'uri': '/config',
'host': mhost + ':' + port 'host': mhost + ':' + port
} }
return public.returnJson(True, '保存成功!', info) return mw.returnJson(True, '保存成功!', info)
def setAdminPathApi(self): def setAdminPathApi(self):
admin_path = request.form.get('admin_path', '').strip() admin_path = request.form.get('admin_path', '').strip()
@@ -157,59 +160,59 @@ class config_api:
admin_path = '/' admin_path = '/'
if admin_path != '/': if admin_path != '/':
if len(admin_path) < 6: if len(admin_path) < 6:
return public.returnJson(False, '安全入口地址长度不能小于6位!') return mw.returnJson(False, '安全入口地址长度不能小于6位!')
if admin_path in admin_path_checks: if admin_path in admin_path_checks:
return public.returnJson(False, '该入口已被面板占用,请使用其它入口!') return mw.returnJson(False, '该入口已被面板占用,请使用其它入口!')
if not re.match("^/[\w\./-_]+$", admin_path): if not re.match("^/[\w\./-_]+$", admin_path):
return public.returnJson(False, '入口地址格式不正确,示例: /my_panel') return mw.returnJson(False, '入口地址格式不正确,示例: /my_panel')
else: else:
domain = public.readFile('data/domain.conf') domain = mw.readFile('data/domain.conf')
if not domain: if not domain:
domain = '' domain = ''
limitip = public.readFile('data/limitip.conf') limitip = mw.readFile('data/limitip.conf')
if not limitip: if not limitip:
limitip = '' limitip = ''
if not domain.strip() and not limitip.strip(): if not domain.strip() and not limitip.strip():
return public.returnJson(False, '警告,关闭安全入口等于直接暴露你的后台地址在外网,十分危险,至少开启以下一种安全方式才能关闭:<a style="color:red;"><br>1、绑定访问域名<br>2、绑定授权IP</a>') return mw.returnJson(False, '警告,关闭安全入口等于直接暴露你的后台地址在外网,十分危险,至少开启以下一种安全方式才能关闭:<a style="color:red;"><br>1、绑定访问域名<br>2、绑定授权IP</a>')
admin_path_file = 'data/admin_path.pl' admin_path_file = 'data/admin_path.pl'
admin_path_old = '/' admin_path_old = '/'
if os.path.exists(admin_path_file): if os.path.exists(admin_path_file):
admin_path_old = public.readFile(admin_path_file).strip() admin_path_old = mw.readFile(admin_path_file).strip()
if admin_path_old != admin_path: if admin_path_old != admin_path:
public.writeFile(admin_path_file, admin_path) mw.writeFile(admin_path_file, admin_path)
public.restartMw() mw.restartMw()
return public.returnJson(True, '修改成功!') return mw.returnJson(True, '修改成功!')
def closePanelApi(self): def closePanelApi(self):
filename = 'data/close.pl' filename = 'data/close.pl'
if os.path.exists(filename): if os.path.exists(filename):
os.remove(filename) os.remove(filename)
return public.returnJson(True, '开启成功') return mw.returnJson(True, '开启成功')
public.writeFile(filename, 'True') mw.writeFile(filename, 'True')
public.execShell("chmod 600 " + filename) mw.execShell("chmod 600 " + filename)
public.execShell("chown root.root " + filename) mw.execShell("chown root.root " + filename)
return public.returnJson(True, '面板已关闭!') return mw.returnJson(True, '面板已关闭!')
def setIpv6StatusApi(self): def setIpv6StatusApi(self):
ipv6_file = 'data/ipv6.pl' ipv6_file = 'data/ipv6.pl'
if os.path.exists('data/ipv6.pl'): if os.path.exists('data/ipv6.pl'):
os.remove(ipv6_file) os.remove(ipv6_file)
public.writeLog('面板设置', '关闭面板IPv6兼容!') mw.writeLog('面板设置', '关闭面板IPv6兼容!')
else: else:
public.writeFile(ipv6_file, 'True') mw.writeFile(ipv6_file, 'True')
public.writeLog('面板设置', '开启面板IPv6兼容!') mw.writeLog('面板设置', '开启面板IPv6兼容!')
public.restartMw() mw.restartMw()
return public.returnJson(True, '设置成功!') return mw.returnJson(True, '设置成功!')
# 获取面板证书 # 获取面板证书
def getPanelSslApi(self): def getPanelSslApi(self):
cert = {} cert = {}
cert['privateKey'] = public.readFile('ssl/privateKey.pem') cert['privateKey'] = mw.readFile('ssl/privateKey.pem')
cert['certPem'] = public.readFile('ssl/certificate.pem') cert['certPem'] = mw.readFile('ssl/certificate.pem')
cert['rep'] = os.path.exists('ssl/input.pl') cert['rep'] = os.path.exists('ssl/input.pl')
return public.getJson(cert) return mw.getJson(cert)
# 保存面板证书 # 保存面板证书
def savePanelSslApi(self): def savePanelSslApi(self):
@@ -220,37 +223,37 @@ class config_api:
certPem = request.form.get('certPem', '').strip() certPem = request.form.get('certPem', '').strip()
privateKey = request.form.get('privateKey', '').strip() privateKey = request.form.get('privateKey', '').strip()
public.writeFile(checkCert, certPem) mw.writeFile(checkCert, certPem)
if privateKey: if privateKey:
public.writeFile(keyPath, privateKey) mw.writeFile(keyPath, privateKey)
if certPem: if certPem:
public.writeFile(certPath, certPem) mw.writeFile(certPath, certPem)
if not public.checkCert(checkCert): if not mw.checkCert(checkCert):
return public.returnJson(False, '证书错误,请检查!') return mw.returnJson(False, '证书错误,请检查!')
public.writeFile('ssl/input.pl', 'True') mw.writeFile('ssl/input.pl', 'True')
return public.returnJson(True, '证书已保存!') return mw.returnJson(True, '证书已保存!')
# 设置面板SSL # 设置面板SSL
def setPanelSslApi(self): def setPanelSslApi(self):
sslConf = public.getRunDir() + '/data/ssl.pl' sslConf = mw.getRunDir() + '/data/ssl.pl'
if os.path.exists(sslConf): if os.path.exists(sslConf):
os.system('rm -f ' + sslConf) os.system('rm -f ' + sslConf)
return public.returnJson(True, 'SSL已关闭,请使用http协议访问面板!') return mw.returnJson(True, 'SSL已关闭,请使用http协议访问面板!')
else: else:
os.system('pip install cffi==1.10') os.system('pip install cffi==1.10')
os.system('pip install cryptography==2.1') os.system('pip install cryptography==2.1')
os.system('pip install pyOpenSSL==16.2') os.system('pip install pyOpenSSL==16.2')
try: try:
if not self.createSSL(): if not self.createSSL():
return public.returnJson(False, '开启失败,无法自动安装pyOpenSSL组件!<p>请尝试手动安装: pip install pyOpenSSL</p>') return mw.returnJson(False, '开启失败,无法自动安装pyOpenSSL组件!<p>请尝试手动安装: pip install pyOpenSSL</p>')
public.writeFile(sslConf, 'True') mw.writeFile(sslConf, 'True')
except Exception as ex: except Exception as ex:
return public.returnJson(False, '开启失败,无法自动安装pyOpenSSL组件!<p>请尝试手动安装: pip install pyOpenSSL</p>') return mw.returnJson(False, '开启失败,无法自动安装pyOpenSSL组件!<p>请尝试手动安装: pip install pyOpenSSL</p>')
return public.returnJson(True, '开启成功,请使用https协议访问面板!') return mw.returnJson(True, '开启成功,请使用https协议访问面板!')
def getApi(self): def getApi(self):
data = {} data = {}
return public.getJson(data) return mw.getJson(data)
##### ----- end ----- ### ##### ----- end ----- ###
# 自签证书 # 自签证书
@@ -262,7 +265,7 @@ class config_api:
key.generate_key(OpenSSL.crypto.TYPE_RSA, 2048) key.generate_key(OpenSSL.crypto.TYPE_RSA, 2048)
cert = OpenSSL.crypto.X509() cert = OpenSSL.crypto.X509()
cert.set_serial_number(0) cert.set_serial_number(0)
cert.get_subject().CN = '120.27.27.98' cert.get_subject().CN = mw.getLocalIp()
cert.set_issuer(cert.get_subject()) cert.set_issuer(cert.get_subject())
cert.gmtime_adj_notBefore(0) cert.gmtime_adj_notBefore(0)
cert.gmtime_adj_notAfter(86400 * 3650) cert.gmtime_adj_notAfter(86400 * 3650)
@@ -273,8 +276,8 @@ class config_api:
private_key = OpenSSL.crypto.dump_privatekey( private_key = OpenSSL.crypto.dump_privatekey(
OpenSSL.crypto.FILETYPE_PEM, key) OpenSSL.crypto.FILETYPE_PEM, key)
if len(cert_ca) > 100 and len(private_key) > 100: if len(cert_ca) > 100 and len(private_key) > 100:
public.writeFile('ssl/certificate.pem', cert_ca) mw.writeFile('ssl/certificate.pem', cert_ca)
public.writeFile('ssl/privateKey.pem', private_key) mw.writeFile('ssl/privateKey.pem', private_key)
print cert_ca, private_key print cert_ca, private_key
return True return True
return False return False
@@ -285,20 +288,20 @@ class config_api:
def get(self): def get(self):
data = {} data = {}
data['title'] = public.getConfig('title') data['title'] = mw.getConfig('title')
data['site_path'] = public.getWwwDir() data['site_path'] = mw.getWwwDir()
data['backup_path'] = public.getBackupDir() data['backup_path'] = mw.getBackupDir()
sformat = 'date +"%Y-%m-%d %H:%M:%S %Z %z"' sformat = 'date +"%Y-%m-%d %H:%M:%S %Z %z"'
data['systemdate'] = public.execShell(sformat)[0].strip() data['systemdate'] = mw.execShell(sformat)[0].strip()
data['port'] = public.getHostPort() data['port'] = mw.getHostPort()
data['ip'] = public.getHostAddr() data['ip'] = mw.getHostAddr()
admin_path_file = 'data/admin_path.pl' admin_path_file = 'data/admin_path.pl'
if not os.path.exists(admin_path_file): if not os.path.exists(admin_path_file):
data['admin_path'] = '/' data['admin_path'] = '/'
else: else:
data['admin_path'] = public.readFile(admin_path_file) data['admin_path'] = mw.readFile(admin_path_file)
ipv6_file = 'data/ipv6.pl' ipv6_file = 'data/ipv6.pl'
if os.path.exists('data/ipv6.pl'): if os.path.exists('data/ipv6.pl'):
@@ -312,9 +315,9 @@ class config_api:
else: else:
data['ssl'] = '' data['ssl'] = ''
data['site_count'] = public.M('sites').count() data['site_count'] = mw.M('sites').count()
data['username'] = public.M('users').where( data['username'] = mw.M('users').where(
"id=?", (1,)).getField('username') "id=?", (1,)).getField('username')
return data return data
+111 -101
View File
@@ -4,7 +4,7 @@ import psutil
import time import time
import os import os
import sys import sys
import public import mw
import re import re
import json import json
import pwd import pwd
@@ -21,62 +21,71 @@ class crontab_api:
##### ----- start ----- ### ##### ----- start ----- ###
def listApi(self): def listApi(self):
_list = public.M('crontab').where('', ()).field(self.field).limit( p = request.args.get('p', 1)
'0,5').order('id desc').select() psize = 10
startPage = (int(p) - 1) * psize
pageInfo = str(startPage) + ',' + str(psize)
_list = mw.M('crontab').where('', ()).field(
self.field).limit(pageInfo).order('id desc').select()
data = [] data = []
for i in range(len(_list)): for i in range(len(_list)):
tmp = _list[i] tmp = _list[i]
if _list[i]['type'] == "day": if _list[i]['type'] == "day":
tmp['type'] = '每天' tmp['type'] = '每天'
tmp['cycle'] = public.getInfo('每天, {1}点{2}分 执行', (str( tmp['cycle'] = mw.getInfo('每天, {1}点{2}分 执行', (str(
_list[i]['where_hour']), str(_list[i]['where_minute']))) _list[i]['where_hour']), str(_list[i]['where_minute'])))
elif _list[i]['type'] == "day-n": elif _list[i]['type'] == "day-n":
tmp['type'] = public.getInfo( tmp['type'] = mw.getInfo(
'每{1}天', (str(_list[i]['where1']),)) '每{1}天', (str(_list[i]['where1']),))
tmp['cycle'] = public.getInfo('每隔{1}天, {2}点{3}分 执行', (str( tmp['cycle'] = mw.getInfo('每隔{1}天, {2}点{3}分 执行', (str(
_list[i]['where1']), str(_list[i]['where_hour']), str(_list[i]['where_minute']))) _list[i]['where1']), str(_list[i]['where_hour']), str(_list[i]['where_minute'])))
elif _list[i]['type'] == "hour": elif _list[i]['type'] == "hour":
tmp['type'] = '每小时' tmp['type'] = '每小时'
tmp['cycle'] = public.getInfo( tmp['cycle'] = mw.getInfo(
'每小时, 第{1}分钟 执行', (str(_list[i]['where_minute']),)) '每小时, 第{1}分钟 执行', (str(_list[i]['where_minute']),))
elif _list[i]['type'] == "hour-n": elif _list[i]['type'] == "hour-n":
tmp['type'] = public.getInfo( tmp['type'] = mw.getInfo(
'每{1}小时', (str(_list[i]['where1']),)) '每{1}小时', (str(_list[i]['where1']),))
tmp['cycle'] = public.getInfo('每{1}小时, 第{2}分钟 执行', (str( tmp['cycle'] = mw.getInfo('每{1}小时, 第{2}分钟 执行', (str(
_list[i]['where1']), str(_list[i]['where_minute']))) _list[i]['where1']), str(_list[i]['where_minute'])))
elif _list[i]['type'] == "minute-n": elif _list[i]['type'] == "minute-n":
tmp['type'] = public.getInfo( tmp['type'] = mw.getInfo(
'每{1}分钟', (str(_list[i]['where1']),)) '每{1}分钟', (str(_list[i]['where1']),))
tmp['cycle'] = public.getInfo( tmp['cycle'] = mw.getInfo(
'每隔{1}分钟执行', (str(_list[i]['where1']),)) '每隔{1}分钟执行', (str(_list[i]['where1']),))
elif _list[i]['type'] == "week": elif _list[i]['type'] == "week":
tmp['type'] = '每周' tmp['type'] = '每周'
if not _list[i]['where1']: if not _list[i]['where1']:
_list[i]['where1'] = '0' _list[i]['where1'] = '0'
tmp['cycle'] = public.getInfo('每周{1}, {2}点{3}分执行', (self.toWeek(int( tmp['cycle'] = mw.getInfo('每周{1}, {2}点{3}分执行', (self.toWeek(int(
_list[i]['where1'])), str(_list[i]['where_hour']), str(_list[i]['where_minute']))) _list[i]['where1'])), str(_list[i]['where_hour']), str(_list[i]['where_minute'])))
elif _list[i]['type'] == "month": elif _list[i]['type'] == "month":
tmp['type'] = '每月' tmp['type'] = '每月'
tmp['cycle'] = public.getInfo('每月, {1}日 {2}点{3}分执行', (str(_list[i]['where1']), str( tmp['cycle'] = mw.getInfo('每月, {1}日 {2}点{3}分执行', (str(_list[i]['where1']), str(
_list[i]['where_hour']), str(_list[i]['where_minute']))) _list[i]['where_hour']), str(_list[i]['where_minute'])))
data.append(tmp) data.append(tmp)
_ret = {} _ret = {}
_ret['data'] = data _ret['data'] = data
count = public.M('crontab').where('', ()).count() count = mw.M('crontab').where('', ()).count()
_page = {} _page = {}
_page['count'] = count _page['count'] = count
_page['tojs'] = 'remind' _page['p'] = p
_page['row'] = psize
_page['tojs'] = "getCronData"
_ret['page'] = public.getPage(_page) _ret['list'] = mw.getPage(_page)
return public.getJson(_ret) _ret['p'] = p
return mw.getJson(_ret)
# 设置计划任务状态 # 设置计划任务状态
def setCronStatusApi(self): def setCronStatusApi(self):
mid = request.form.get('id', '') mid = request.form.get('id', '')
cronInfo = public.M('crontab').where( cronInfo = mw.M('crontab').where(
'id=?', (mid,)).field(self.field).find() 'id=?', (mid,)).field(self.field).find()
status = 1 status = 1
if cronInfo['status'] == status: if cronInfo['status'] == status:
@@ -86,17 +95,17 @@ class crontab_api:
cronInfo['status'] = 1 cronInfo['status'] = 1
self.syncToCrond(cronInfo) self.syncToCrond(cronInfo)
public.M('crontab').where('id=?', (mid,)).setField('status', status) mw.M('crontab').where('id=?', (mid,)).setField('status', status)
public.writeLog( mw.writeLog(
'计划任务', '修改计划任务[' + cronInfo['name'] + ']状态为[' + str(status) + ']') '计划任务', '修改计划任务[' + cronInfo['name'] + ']状态为[' + str(status) + ']')
return public.returnJson(True, '设置成功') return mw.returnJson(True, '设置成功')
# 获取指定任务数据 # 获取指定任务数据
def getCrondFindApi(self): def getCrondFindApi(self):
sid = request.form.get('id', '') sid = request.form.get('id', '')
data = public.M('crontab').where( data = mw.M('crontab').where(
'id=?', (sid,)).field(self.field).find() 'id=?', (sid,)).field(self.field).find()
return public.getJson(data) return mw.getJson(data)
def modifyCrondApi(self): def modifyCrondApi(self):
sid = request.form.get('id', '') sid = request.form.get('id', '')
@@ -114,7 +123,7 @@ class crontab_api:
urladdress = request.form.get('urladdress', '') urladdress = request.form.get('urladdress', '')
if len(iname) < 1: if len(iname) < 1:
return public.returnJson(False, '任务名称不能为空!') return mw.returnJson(False, '任务名称不能为空!')
params = { params = {
'name': iname, 'name': iname,
@@ -131,7 +140,7 @@ class crontab_api:
'urladdress': urladdress, 'urladdress': urladdress,
} }
cuonConfig, get, name = self.getCrondCycle(params) cuonConfig, get, name = self.getCrondCycle(params)
cronInfo = public.M('crontab').where( cronInfo = mw.M('crontab').where(
'id=?', (sid,)).field(self.field).find() 'id=?', (sid,)).field(self.field).find()
del(cronInfo['id']) del(cronInfo['id'])
del(cronInfo['addtime']) del(cronInfo['addtime'])
@@ -145,21 +154,21 @@ class crontab_api:
cronInfo['sbody'] = get['sbody'] cronInfo['sbody'] = get['sbody']
cronInfo['urladdress'] = get['urladdress'] cronInfo['urladdress'] = get['urladdress']
addData = public.M('crontab').where('id=?', (sid,)).save('name,type,where1,where_hour,where_minute,save,backup_to,sbody,urladdress', (get[ addData = mw.M('crontab').where('id=?', (sid,)).save('name,type,where1,where_hour,where_minute,save,backup_to,sbody,urladdress', (get[
'name'], field_type, get['where1'], get['hour'], get['minute'], get['save'], get['backup_to'], get['sbody'], get['urladdress'])) 'name'], field_type, get['where1'], get['hour'], get['minute'], get['save'], get['backup_to'], get['sbody'], get['urladdress']))
self.removeForCrond(cronInfo['echo']) self.removeForCrond(cronInfo['echo'])
self.syncToCrond(cronInfo) self.syncToCrond(cronInfo)
public.writeLog('计划任务', '修改计划任务[' + cronInfo['name'] + ']成功') mw.writeLog('计划任务', '修改计划任务[' + cronInfo['name'] + ']成功')
return public.returnJson(True, '修改成功') return mw.returnJson(True, '修改成功')
def logsApi(self): def logsApi(self):
sid = request.form.get('id', '') sid = request.form.get('id', '')
echo = public.M('crontab').where("id=?", (sid,)).field('echo').find() echo = mw.M('crontab').where("id=?", (sid,)).field('echo').find()
logFile = public.getServerDir() + '/cron/' + echo['echo'] + '.log' logFile = mw.getServerDir() + '/cron/' + echo['echo'] + '.log'
if not os.path.exists(logFile): if not os.path.exists(logFile):
return public.returnJson(False, '当前日志为空!') return mw.returnJson(False, '当前日志为空!')
log = public.getNumLines(logFile, 2000) log = mw.getNumLines(logFile, 500)
return public.returnJson(True, log) return mw.returnJson(True, log)
def addApi(self): def addApi(self):
iname = request.form.get('name', '') iname = request.form.get('name', '')
@@ -176,7 +185,7 @@ class crontab_api:
urladdress = request.form.get('urladdress', '') urladdress = request.form.get('urladdress', '')
if len(iname) < 1: if len(iname) < 1:
return public.returnJson(False, '任务名称不能为空!') return mw.returnJson(False, '任务名称不能为空!')
params = { params = {
'name': iname, 'name': iname,
@@ -194,49 +203,50 @@ class crontab_api:
} }
# print params # print params
cuonConfig, get, name = self.getCrondCycle(params) cronConfig, get, name = self.getCrondCycle(params)
cronPath = public.getServerDir() + '/cron' cronPath = mw.getServerDir() + '/cron'
cronName = self.getShell(params) cronName = self.getShell(params)
# print cuonConfig, _params, name # print cronConfig, _params, name
# print cronPath, cronName # print 'vv', cronPath, cronName
# print stype # print 'stype', stype
if type(cronName) == dict: if type(cronName) == dict:
return cronName return cronName
cuonConfig += ' ' + cronPath + '/' + cronName + \ cronConfig += ' ' + cronPath + '/' + cronName + \
' >> ' + cronPath + '/' + cronName + '.log 2>&1' ' >> ' + cronPath + '/' + cronName + '.log 2>&1'
wRes = self.writeShell(cuonConfig)
if type(wRes) != bool: if not mw.isAppleSystem():
return wRes wRes = self.writeShell(cronConfig)
if type(wRes) != bool:
return wRes
self.crondReload()
self.crondReload() addData = mw.M('crontab').add('name,type,where1,where_hour,where_minute,echo,addtime,status,save,backup_to,stype,sname,sbody,urladdress', (iname, field_type, where1, hour, minute, cronName, time.strftime(
addData = public.M('crontab').add('name,type,where1,where_hour,where_minute,echo,addtime,status,save,backup_to,stype,sname,sbody,urladdress', (iname, field_type, where1, hour, minute, cronName, time.strftime(
'%Y-%m-%d %X', time.localtime()), 1, save, backup_to, stype, sname, sbody, urladdress)) '%Y-%m-%d %X', time.localtime()), 1, save, backup_to, stype, sname, sbody, urladdress))
if addData > 0: if addData > 0:
return public.returnJson(True, '添加成功') return mw.returnJson(True, '添加成功')
return public.returnJson(False, '添加失败') return mw.returnJson(False, '添加失败')
def startTaskApi(self): def startTaskApi(self):
sid = request.form.get('id', '') sid = request.form.get('id', '')
echo = public.M('crontab').where('id=?', (sid,)).getField('echo') echo = mw.M('crontab').where('id=?', (sid,)).getField('echo')
execstr = public.getServerDir() + '/cron/' + echo execstr = mw.getServerDir() + '/cron/' + echo
os.system('chmod +x ' + execstr) os.system('chmod +x ' + execstr)
os.system('nohup ' + execstr + ' >> ' + execstr + '.log 2>&1 &') os.system('nohup ' + execstr + ' >> ' + execstr + '.log 2>&1 &')
return public.returnJson(True, '任务已执行!') return mw.returnJson(True, '任务已执行!')
def delApi(self): def delApi(self):
sid = request.form.get('id', '') sid = request.form.get('id', '')
try: try:
find = public.M('crontab').where( find = mw.M('crontab').where(
"id=?", (sid,)).field('name,echo').find() "id=?", (sid,)).field('name,echo').find()
if not self.removeForCrond(find['echo']): if not self.removeForCrond(find['echo']):
return public.returnJson(False, '无法写入文件,请检查是否开启了系统加固功能!') return mw.returnJson(False, '无法写入文件,请检查是否开启了系统加固功能!')
cronPath = public.getServerDir() + '/cron' cronPath = mw.getServerDir() + '/cron'
sfile = cronPath + '/' + find['echo'] sfile = cronPath + '/' + find['echo']
if os.path.exists(sfile): if os.path.exists(sfile):
@@ -245,22 +255,22 @@ class crontab_api:
if os.path.exists(sfile): if os.path.exists(sfile):
os.remove(sfile) os.remove(sfile)
public.M('crontab').where("id=?", (sid,)).delete() mw.M('crontab').where("id=?", (sid,)).delete()
public.writeLog('计划任务', public.getInfo( mw.writeLog('计划任务', mw.getInfo(
'删除计划任务[{1}]成功!', (find['name'],))) '删除计划任务[{1}]成功!', (find['name'],)))
return public.returnJson(True, '删除成功') return mw.returnJson(True, '删除成功')
except Exception as e: except Exception as e:
return public.returnJson(False, '删除失败:' + str(e)) return mw.returnJson(False, '删除失败:' + str(e))
def delLogsApi(self): def delLogsApi(self):
sid = request.form.get('id', '') sid = request.form.get('id', '')
try: try:
echo = public.M('crontab').where("id=?", (sid,)).getField('echo') echo = mw.M('crontab').where("id=?", (sid,)).getField('echo')
logFile = public.getServerDir() + '/cron/' + echo + '.log' logFile = mw.getServerDir() + '/cron/' + echo + '.log'
os.remove(logFile) os.remove(logFile)
return public.returnJson(True, '任务日志已清空!') return mw.returnJson(True, '任务日志已清空!')
except: except:
return public.returnJson(False, '任务日志清空失败!') return mw.returnJson(False, '任务日志清空失败!')
# 取数据列表 # 取数据列表
def getDataListApi(self): def getDataListApi(self):
@@ -268,19 +278,19 @@ class crontab_api:
if stype == 'databases': if stype == 'databases':
db_list = {} db_list = {}
db_list['orderOpt'] = [] db_list['orderOpt'] = []
path = public.getServerDir() + '/mysql' path = mw.getServerDir() + '/mysql'
if not os.path.exists(path + '/mysql.db'): if not os.path.exists(path + '/mysql.db'):
db_list['data'] = [] db_list['data'] = []
else: else:
db_list['data'] = public.M('databases').dbPos( db_list['data'] = mw.M('databases').dbPos(
path, 'mysql').field('name,ps').select() path, 'mysql').field('name,ps').select()
return public.getJson(db_list) return mw.getJson(db_list)
data = {} data = {}
data['data'] = public.M(stype).field('name,ps').select() data['data'] = mw.M(stype).field('name,ps').select()
data['orderOpt'] = [] data['orderOpt'] = []
# try: # try:
# tmp = public.readFile('data/libList.conf') # tmp = mw.readFile('data/libList.conf')
# libs = json.loads(tmp) # libs = json.loads(tmp)
# import imp # import imp
# for lib in libs: # for lib in libs:
@@ -291,7 +301,7 @@ class crontab_api:
# data['orderOpt'].append(tmp) # data['orderOpt'].append(tmp)
# except Exception as e: # except Exception as e:
# print e # print e
return public.getJson(data) return mw.getJson(data)
##### ----- start ----- ### ##### ----- start ----- ###
# 转换大写星期 # 转换大写星期
@@ -318,7 +328,7 @@ class crontab_api:
name = '每天' name = '每天'
elif params['type'] == "day-n": elif params['type'] == "day-n":
cuonConfig = self.getDay_N(params) cuonConfig = self.getDay_N(params)
name = public.getInfo('每{1}天', (params['where1'],)) name = mw.getInfo('每{1}天', (params['where1'],))
elif params['type'] == "hour": elif params['type'] == "hour":
cuonConfig = self.getHour(params) cuonConfig = self.getHour(params)
name = '每小时' name = '每小时'
@@ -384,24 +394,24 @@ class crontab_api:
log = '.log' log = '.log'
wheres = { wheres = {
'path': head + "python " + public.getServerDir() + "/mdserver-web/scripts/backup.py path " + param['sname'] + " " + str(param['save']), 'path': head + "python " + mw.getServerDir() + "/mdserver-web/scripts/backup.py path " + param['sname'] + " " + str(param['save']),
'site': head + "python " + public.getServerDir() + "/mdserver-web/scripts/backup.py site " + param['sname'] + " " + str(param['save']), 'site': head + "python " + mw.getServerDir() + "/mdserver-web/scripts/backup.py site " + param['sname'] + " " + str(param['save']),
'database': head + "python " + public.getServerDir() + "/mdserver-web/scripts/backup.py database " + param['sname'] + " " + str(param['save']), 'database': head + "python " + mw.getServerDir() + "/mdserver-web/scripts/backup.py database " + param['sname'] + " " + str(param['save']),
'logs': head + "python " + public.getServerDir() + "/mdserver-web/scripts/logs_backup.py " + param['sname'] + log + " " + str(param['save']), 'logs': head + "python " + mw.getServerDir() + "/mdserver-web/scripts/logs_backup.py " + param['sname'] + log + " " + str(param['save']),
'rememory': head + "/bin/bash " + public.getServerDir() + '/mdserver-web/scripts/rememory.sh' 'rememory': head + "/bin/bash " + mw.getServerDir() + '/mdserver-web/scripts/rememory.sh'
} }
if param['backup_to'] != 'localhost': if param['backup_to'] != 'localhost':
cfile = public.getServerDir() + "/mdserver-web/plugin/" + param[ cfile = mw.getServerDir() + "/mdserver-web/plugin/" + param[
'backup_to'] + "/" + param['backup_to'] + "_main.py" 'backup_to'] + "/" + param['backup_to'] + "_main.py"
if not os.path.exists(cfile): if not os.path.exists(cfile):
cfile = public.getServerDir() + "/mdserver-web/script/backup_" + \ cfile = mw.getServerDir() + "/mdserver-web/script/backup_" + \
param['backup_to'] + ".py" param['backup_to'] + ".py"
wheres = { wheres = {
'path': head + "python " + cfile + " path " + param['sname'] + " " + str(param['save']), 'path': head + "python " + cfile + " path " + param['sname'] + " " + str(param['save']),
'site': head + "python " + cfile + " site " + param['sname'] + " " + str(param['save']), 'site': head + "python " + cfile + " site " + param['sname'] + " " + str(param['save']),
'database': head + "python " + cfile + " database " + param['sname'] + " " + str(param['save']), 'database': head + "python " + cfile + " database " + param['sname'] + " " + str(param['save']),
'logs': head + "python " + public.getServerDir() + "/mdserver-web/scripts/logs_backup.py " + param['sname'] + log + " " + str(param['save']), 'logs': head + "python " + mw.getServerDir() + "/mdserver-web/scripts/logs_backup.py " + param['sname'] + log + " " + str(param['save']),
'rememory': head + "/bin/bash " + public.getServerDir() + '/mdserver-web/scripts/rememory.sh' 'rememory': head + "/bin/bash " + mw.getServerDir() + '/mdserver-web/scripts/rememory.sh'
} }
try: try:
shell = wheres[stype] shell = wheres[stype]
@@ -418,16 +428,16 @@ endDate=`date +"%Y-%m-%d %H:%M:%S"`
echo "★[$endDate] Successful" echo "★[$endDate] Successful"
echo "----------------------------------------------------------------------------" echo "----------------------------------------------------------------------------"
''' '''
cronPath = public.getServerDir() + '/cron' cronPath = mw.getServerDir() + '/cron'
if not os.path.exists(cronPath): if not os.path.exists(cronPath):
public.execShell('mkdir -p ' + cronPath) mw.execShell('mkdir -p ' + cronPath)
if not 'echo' in param: if not 'echo' in param:
cronName = public.md5(public.md5(str(time.time()) + '_mw')) cronName = mw.md5(mw.md5(str(time.time()) + '_mw'))
else: else:
cronName = param['echo'] cronName = param['echo']
file = cronPath + '/' + cronName file = cronPath + '/' + cronName
public.writeFile(file, self.checkScript(shell)) mw.writeFile(file, self.checkScript(shell))
public.execShell('chmod 750 ' + file) mw.execShell('chmod 750 ' + file)
return cronName return cronName
# 检查脚本 # 检查脚本
@@ -443,52 +453,52 @@ echo "--------------------------------------------------------------------------
u_file = '/var/spool/cron/crontabs/root' u_file = '/var/spool/cron/crontabs/root'
if not os.path.exists(u_file): if not os.path.exists(u_file):
file = '/var/spool/cron/root' file = '/var/spool/cron/root'
if public.isAppleSystem(): if mw.isAppleSystem():
file = '/etc/crontab' file = '/etc/crontab'
else: else:
file = u_file file = u_file
if not os.path.exists(file): if not os.path.exists(file):
public.writeFile(file, '') mw.writeFile(file, '')
conf = public.readFile(file) conf = mw.readFile(file)
conf += config + "\n" conf += str(config) + "\n"
if public.writeFile(file, conf): if mw.writeFile(file, conf):
if not os.path.exists(u_file): if not os.path.exists(u_file):
public.execShell("chmod 600 '" + file + mw.execShell("chmod 600 '" + file +
"' && chown root.root " + file) "' && chown root.root " + file)
else: else:
public.execShell("chmod 600 '" + file + mw.execShell("chmod 600 '" + file +
"' && chown root.crontab " + file) "' && chown root.crontab " + file)
return True return True
return public.returnJson(False, '文件写入失败,请检查是否开启系统加固功能!') return mw.returnJson(False, '文件写入失败,请检查是否开启系统加固功能!')
# 重载配置 # 重载配置
def crondReload(self): def crondReload(self):
if public.isAppleSystem(): if mw.isAppleSystem():
if os.path.exists('/etc/crontab'): if os.path.exists('/etc/crontab'):
pass pass
# public.execShell('/usr/sbin/cron restart') # mw.execShell('/usr/sbin/cron restart')
else: else:
if os.path.exists('/etc/init.d/crond'): if os.path.exists('/etc/init.d/crond'):
public.execShell('/etc/init.d/crond reload') mw.execShell('/etc/init.d/crond reload')
elif os.path.exists('/etc/init.d/cron'): elif os.path.exists('/etc/init.d/cron'):
public.execShell('service cron restart') mw.execShell('service cron restart')
else: else:
public.execShell("systemctl reload crond") mw.execShell("systemctl reload crond")
# 从crond删除 # 从crond删除
def removeForCrond(self, echo): def removeForCrond(self, echo):
u_file = '/var/spool/cron/crontabs/root' u_file = '/var/spool/cron/crontabs/root'
if not os.path.exists(u_file): if not os.path.exists(u_file):
file = '/var/spool/cron/root' file = '/var/spool/cron/root'
if public.isAppleSystem(): if mw.isAppleSystem():
file = '/etc/crontab' file = '/etc/crontab'
else: else:
file = u_file file = u_file
conf = public.readFile(file) conf = mw.readFile(file)
rep = ".+" + str(echo) + ".+\n" rep = ".+" + str(echo) + ".+\n"
conf = re.sub(rep, "", conf) conf = re.sub(rep, "", conf)
if not public.writeFile(file, conf): if not mw.writeFile(file, conf):
return False return False
self.crondReload() self.crondReload()
return True return True
@@ -502,7 +512,7 @@ echo "--------------------------------------------------------------------------
cronInfo['minute'] = cronInfo['where_minute'] cronInfo['minute'] = cronInfo['where_minute']
cronInfo['week'] = cronInfo['where1'] cronInfo['week'] = cronInfo['where1']
cuonConfig, cronInfo, name = self.getCrondCycle(cronInfo) cuonConfig, cronInfo, name = self.getCrondCycle(cronInfo)
cronPath = public.getServerDir() + '/cron' cronPath = mw.getServerDir() + '/cron'
cronName = self.getShell(cronInfo) cronName = self.getShell(cronInfo)
if type(cronName) == dict: if type(cronName) == dict:
return cronName return cronName
+6 -6
View File
@@ -194,8 +194,8 @@ class Sql():
opt = opt[0:len(opt) - 1] opt = opt[0:len(opt) - 1]
sql = "UPDATE " + self.__DB_TABLE + " SET " + opt + self.__OPT_WHERE sql = "UPDATE " + self.__DB_TABLE + " SET " + opt + self.__OPT_WHERE
import public import mw
public.writeFile('/tmp/test.pl', sql) mw.writeFile('/tmp/test.pl', sql)
# 处理拼接WHERE与UPDATE参数 # 处理拼接WHERE与UPDATE参数
tmp = list(param) tmp = list(param)
@@ -249,8 +249,8 @@ class Sql():
def create(self, name): def create(self, name):
# 创建数据表 # 创建数据表
self.__GetConn() self.__GetConn()
import public import mw
script = public.readFile('data/' + name + '.sql') script = mw.readFile('data/' + name + '.sql')
result = self.__DB_CONN.executescript(script) result = self.__DB_CONN.executescript(script)
self.__DB_CONN.commit() self.__DB_CONN.commit()
return result.rowcount return result.rowcount
@@ -258,8 +258,8 @@ class Sql():
def fofile(self, filename): def fofile(self, filename):
# 执行脚本 # 执行脚本
self.__GetConn() self.__GetConn()
import public import mw
script = public.readFile(filename) script = mw.readFile(filename)
result = self.__DB_CONN.executescript(script) result = self.__DB_CONN.executescript(script)
self.__DB_CONN.commit() self.__DB_CONN.commit()
return result.rowcount return result.rowcount
+329 -96
View File
@@ -4,7 +4,7 @@ import psutil
import time import time
import os import os
import sys import sys
import public import mw
import re import re
import json import json
import pwd import pwd
@@ -13,6 +13,7 @@ import shutil
from flask import request from flask import request
from flask import send_file, send_from_directory from flask import send_file, send_from_directory
from flask import make_response from flask import make_response
from flask import session
class files_api: class files_api:
@@ -20,7 +21,7 @@ class files_api:
rPath = None rPath = None
def __init__(self): def __init__(self):
self.rPath = public.getRootDir() + '/recycle_bin/' self.rPath = mw.getRootDir() + '/recycle_bin/'
##### ----- start ----- ### ##### ----- start ----- ###
def getBodyApi(self): def getBodyApi(self):
@@ -32,13 +33,13 @@ class files_api:
line = request.form.get('line', '100') line = request.form.get('line', '100')
if not os.path.exists(path): if not os.path.exists(path):
return public.returnJson(False, '文件不存在', (path,)) return mw.returnJson(False, '文件不存在', (path,))
try: try:
data = public.getNumLines(path, int(line)) data = mw.getNumLines(path, int(line))
return public.returnJson(True, 'OK', data) return mw.returnJson(True, 'OK', data)
except Exception as ex: except Exception as ex:
return public.returnJson(False, u'无法正确读取文件!' + str(ex)) return mw.returnJson(False, u'无法正确读取文件!' + str(ex))
def saveBodyApi(self): def saveBodyApi(self):
path = request.form.get('path', '').encode('utf-8') path = request.form.get('path', '').encode('utf-8')
@@ -51,7 +52,7 @@ class files_api:
if not os.path.exists(filename): if not os.path.exists(filename):
return '' return ''
response = make_response(send_from_directory( response = make_response(send_from_directory(
os.path.dirname(filename), os.path.basename(filename), as_attachment=True)) os.path.dirname(filename).encode('utf-8'), os.path.basename(filename).encode('utf-8'), as_attachment=True))
return response return response
def zipApi(self): def zipApi(self):
@@ -61,6 +62,27 @@ class files_api:
path = request.form.get('path', '').encode('utf-8') path = request.form.get('path', '').encode('utf-8')
return self.zip(sfile, dfile, stype, path) return self.zip(sfile, dfile, stype, path)
# 移动文件或目录
def mvFileApi(self):
sfile = request.form.get('sfile', '').encode('utf-8')
dfile = request.form.get('dfile', '').encode('utf-8')
if not self.checkFileName(dfile):
return mw.returnJson(False, '文件名中不能包含特殊字符!')
if not os.path.exists(sfile):
return mw.returnJson(False, '指定文件不存在!')
if not self.checkDir(sfile):
return mw.returnJson(False, 'FILE_DANGER')
import shutil
try:
shutil.move(sfile, dfile)
msg = mw.getInfo('移动文件或目录[{1}]到[{2}]成功!', (sfile, dfile,))
mw.writeLog('文件管理', msg)
return mw.returnJson(True, '移动文件或目录成功!')
except:
return mw.returnJson(False, '移动文件或目录失败!')
def deleteApi(self): def deleteApi(self):
path = request.form.get('path', '').encode('utf-8') path = request.form.get('path', '').encode('utf-8')
return self.delete(path) return self.delete(path)
@@ -68,55 +90,85 @@ class files_api:
def fileAccessApi(self): def fileAccessApi(self):
filename = request.form.get('filename', '').encode('utf-8') filename = request.form.get('filename', '').encode('utf-8')
data = self.getAccess(filename) data = self.getAccess(filename)
return public.getJson(data) return mw.getJson(data)
def setFileAccessApi(self):
if mw.isAppleSystem():
return mw.returnJson(True, '开发机不设置!')
filename = request.form.get('filename', '').encode('utf-8')
user = request.form.get('user', '').encode('utf-8')
access = request.form.get('access', '755')
sall = '-R'
try:
if not self.checkDir(filename):
return mw.returnJson(False, '请不要花样作死')
if not os.path.exists(filename):
return mw.returnJson(False, '指定文件不存在!')
os.system('chmod ' + sall + ' ' + access + " '" + filename + "'")
os.system('chown ' + sall + ' ' + user +
':' + user + " '" + filename + "'")
msg = mw.getInfo(
'设置[{1}]权限为[{2}]所有者为[{3}]', (filename, access, user,))
mw.writeLog('文件管理', msg)
return mw.returnJson(True, '设置成功!')
except:
return mw.returnJson(False, '设置失败!')
def getDirSizeApi(self): def getDirSizeApi(self):
path = request.form.get('path', '').encode('utf-8') path = request.form.get('path', '').encode('utf-8')
tmp = self.getDirSize(path) tmp = self.getDirSize(path)
return public.returnJson(True, tmp[0].split()[0]) return mw.returnJson(True, tmp[0].split()[0])
def getDirApi(self): def getDirApi(self):
path = request.form.get('path', '').encode('utf-8') path = request.form.get('path', '').encode('utf-8')
if not os.path.exists(path): if not os.path.exists(path):
path = public.getRootDir() + "/wwwroot" path = mw.getRootDir() + "/wwwroot"
search = request.args.get('search', '').strip().lower() search = request.args.get('search', '').strip().lower()
page = request.args.get('p', '1').strip().lower() page = request.args.get('p', '1').strip().lower()
row = request.args.get('showRow', '10') row = request.args.get('showRow', '10')
disk = request.form.get('disk', '')
if disk == 'True':
row = 1000
return self.getDir(path, int(page), int(row), search) return self.getDir(path, int(page), int(row), search)
def createFileApi(self): def createFileApi(self):
file = request.form.get('path', '').encode('utf-8') file = request.form.get('path', '').encode('utf-8')
try: try:
if not self.checkFileName(file): if not self.checkFileName(file):
return public.returnJson(False, '文件名中不能包含特殊字符!') return mw.returnJson(False, '文件名中不能包含特殊字符!')
if os.path.exists(file): if os.path.exists(file):
return public.returnJson(False, '指定文件已存在!') return mw.returnJson(False, '指定文件已存在!')
_path = os.path.dirname(file) _path = os.path.dirname(file)
if not os.path.exists(_path): if not os.path.exists(_path):
os.makedirs(_path) os.makedirs(_path)
open(file, 'w+').close() open(file, 'w+').close()
self.setFileAccept(file) self.setFileAccept(file)
msg = public.getInfo('创建文件[{1}]成功!', (file,)) msg = mw.getInfo('创建文件[{1}]成功!', (file,))
public.writeLog('文件管理', msg) mw.writeLog('文件管理', msg)
return public.returnJson(True, '文件创建成功!') return mw.returnJson(True, '文件创建成功!')
except Exception as e: except Exception as e:
# print str(e) # print str(e)
return public.returnJson(True, '文件创建失败!') return mw.returnJson(True, '文件创建失败!')
def createDirApi(self): def createDirApi(self):
path = request.form.get('path', '').encode('utf-8') path = request.form.get('path', '').encode('utf-8')
try: try:
if not self.checkFileName(path): if not self.checkFileName(path):
return public.returnJson(False, '目录名中不能包含特殊字符!') return mw.returnJson(False, '目录名中不能包含特殊字符!')
if os.path.exists(path): if os.path.exists(path):
return public.returnJson(False, '指定目录已存在!') return mw.returnJson(False, '指定目录已存在!')
os.makedirs(path) os.makedirs(path)
self.setFileAccept(path) self.setFileAccept(path)
msg = public.getInfo('创建目录[{1}]成功!', (path,)) msg = mw.getInfo('创建目录[{1}]成功!', (path,))
public.writeLog('文件管理', msg) mw.writeLog('文件管理', msg)
return public.returnJson(True, '目录创建成功!') return mw.returnJson(True, '目录创建成功!')
except Exception as e: except Exception as e:
return public.returnJson(False, '目录创建失败!') return mw.returnJson(False, '目录创建失败!')
def downloadFileApi(self): def downloadFileApi(self):
import db import db
@@ -125,20 +177,20 @@ class files_api:
path = request.form.get('path', '').encode('utf-8') path = request.form.get('path', '').encode('utf-8')
filename = request.form.get('filename', '').encode('utf-8') filename = request.form.get('filename', '').encode('utf-8')
isTask = public.getRootDir() + '/tmp/panelTask.pl' isTask = mw.getRootDir() + '/tmp/panelTask.pl'
execstr = url + '|mw|' + path + '/' + filename execstr = url + '|mw|' + path + '/' + filename
public.M('tasks').add('name,type,status,addtime,execstr', mw.M('tasks').add('name,type,status,addtime,execstr',
('下载文件[' + filename + ']', 'download', '0', time.strftime('%Y-%m-%d %H:%M:%S'), execstr)) ('下载文件[' + filename + ']', 'download', '0', time.strftime('%Y-%m-%d %H:%M:%S'), execstr))
public.writeFile(isTask, 'True') mw.writeFile(isTask, 'True')
# self.setFileAccept(path + '/' + filename) # self.setFileAccept(path + '/' + filename)
return public.returnJson(True, '已将下载任务添加到队列!') return mw.returnJson(True, '已将下载任务添加到队列!')
def removeTaskApi(self): def removeTaskApi(self):
mid = request.form.get('id', '').encode('utf-8') mid = request.form.get('id', '').encode('utf-8')
try: try:
name = public.M('tasks').where('id=?', (mid,)).getField('name') name = mw.M('tasks').where('id=?', (mid,)).getField('name')
status = public.M('tasks').where('id=?', (mid,)).getField('status') status = mw.M('tasks').where('id=?', (mid,)).getField('status')
public.M('tasks').delete(mid) mw.M('tasks').delete(mid)
if status == '-1': if status == '-1':
os.system( os.system(
"kill `ps -ef |grep 'python panelSafe.pyc'|grep -v grep|grep -v panelExec|awk '{print $2}'`") "kill `ps -ef |grep 'python panelSafe.pyc'|grep -v grep|grep -v panelExec|awk '{print $2}'`")
@@ -156,12 +208,12 @@ done
os.system( os.system(
'rm -f ' + name.replace('扫描目录[', '').replace(']', '') + '/scan.pl') 'rm -f ' + name.replace('扫描目录[', '').replace(']', '') + '/scan.pl')
isTask = public.getRootDir() + '/tmp/panelTask.pl' isTask = mw.getRootDir() + '/tmp/panelTask.pl'
public.writeFile(isTask, 'True') mw.writeFile(isTask, 'True')
os.system('/etc/init.d/mw start') os.system('/etc/init.d/mw start')
except: except:
os.system('/etc/init.d/mw start') os.system('/etc/init.d/mw start')
return public.returnJson(True, '任务已删除!') return mw.returnJson(True, '任务已删除!')
# 上传文件 # 上传文件
def uploadFileApi(self): def uploadFileApi(self):
@@ -184,9 +236,9 @@ done
os.chown(filename, p_stat.st_uid, p_stat.st_gid) os.chown(filename, p_stat.st_uid, p_stat.st_gid)
os.chmod(filename, p_stat.st_mode) os.chmod(filename, p_stat.st_mode)
msg = public.getInfo('上传文件[{1}] 到 [{2}]成功!', (filename, path)) msg = mw.getInfo('上传文件[{1}] 到 [{2}]成功!', (filename, path))
public.writeLog('文件管理', msg) mw.writeLog('文件管理', msg)
return public.returnMsg(True, '上传成功!') return mw.returnMsg(True, '上传成功!')
def getRecycleBinApi(self): def getRecycleBinApi(self):
rPath = self.rPath rPath = self.rPath
@@ -222,7 +274,7 @@ done
data['files'].append(tmp) data['files'].append(tmp)
except: except:
continue continue
return public.returnJson(True, 'OK', data) return mw.returnJson(True, 'OK', data)
# 回收站开关 # 回收站开关
def recycleBinApi(self): def recycleBinApi(self):
@@ -232,12 +284,12 @@ done
c = 'data/recycle_bin_db.pl' c = 'data/recycle_bin_db.pl'
if os.path.exists(c): if os.path.exists(c):
os.remove(c) os.remove(c)
public.writeLog('文件管理', '已关闭回收站功能!') mw.writeLog('文件管理', '已关闭回收站功能!')
return public.returnJson(True, '已关闭回收站功能!') return mw.returnJson(True, '已关闭回收站功能!')
else: else:
public.writeFile(c, 'True') mw.writeFile(c, 'True')
public.writeLog('文件管理', '已开启回收站功能!') mw.writeLog('文件管理', '已开启回收站功能!')
return public.returnJson(True, '已开启回收站功能!') return mw.returnJson(True, '已开启回收站功能!')
def reRecycleBinApi(self): def reRecycleBinApi(self):
rPath = self.rPath rPath = self.rPath
@@ -246,13 +298,13 @@ done
try: try:
import shutil import shutil
shutil.move(rPath + path, dFile) shutil.move(rPath + path, dFile)
msg = public.getInfo('移动文件[{1}]到回收站成功!', (dFile,)) msg = mw.getInfo('移动文件[{1}]到回收站成功!', (dFile,))
public.writeLog('文件管理', msg) mw.writeLog('文件管理', msg)
return public.returnJson(True, '恢复成功!') return mw.returnJson(True, '恢复成功!')
except Exception as e: except Exception as e:
msg = public.getInfo('从回收站恢复[{1}]失败!', (dFile,)) msg = mw.getInfo('从回收站恢复[{1}]失败!', (dFile,))
public.writeLog('文件管理', msg) mw.writeLog('文件管理', msg)
return public.returnJson(False, '恢复失败!') return mw.returnJson(False, '恢复失败!')
def delRecycleBinApi(self): def delRecycleBinApi(self):
rPath = self.rPath rPath = self.rPath
@@ -261,7 +313,7 @@ done
dFile = path.split('_t_')[0] dFile = path.split('_t_')[0]
if not self.checkDir(path): if not self.checkDir(path):
return public.returnJson(False, '敏感目录,请不要花样作死!') return mw.returnJson(False, '敏感目录,请不要花样作死!')
os.system('which chattr && chattr -R -i ' + rPath + path) os.system('which chattr && chattr -R -i ' + rPath + path)
if os.path.isdir(rPath + path): if os.path.isdir(rPath + path):
@@ -271,14 +323,14 @@ done
os.remove(rPath + path) os.remove(rPath + path)
tfile = path.replace('_mw_', '/').split('_t_')[0] tfile = path.replace('_mw_', '/').split('_t_')[0]
msg = public.getInfo('已彻底从回收站删除{1}!', (tfile,)) msg = mw.getInfo('已彻底从回收站删除{1}!', (tfile,))
public.writeLog('文件管理', msg) mw.writeLog('文件管理', msg)
return public.returnJson(True, msg) return mw.returnJson(True, msg)
# 获取进度 # 获取进度
def getSpeedApi(self): def getSpeedApi(self):
data = public.getSpeed() data = mw.getSpeed()
return public.returnJson(True, '已清空回收站!', data) return mw.returnJson(True, '已清空回收站!', data)
def closeRecycleBinApi(self): def closeRecycleBinApi(self):
rPath = self.rPath rPath = self.rPath
@@ -289,19 +341,19 @@ done
for name in rlist: for name in rlist:
i += 1 i += 1
path = rPath + name path = rPath + name
public.writeSpeed(name, i, l) mw.writeSpeed(name, i, l)
if os.path.isdir(path): if os.path.isdir(path):
shutil.rmtree(path) shutil.rmtree(path)
else: else:
os.remove(path) os.remove(path)
public.writeSpeed(None, 0, 0) mw.writeSpeed(None, 0, 0)
public.writeLog('文件管理', '已清空回收站!') mw.writeLog('文件管理', '已清空回收站!')
return public.returnJson(True, '已清空回收站!') return mw.returnJson(True, '已清空回收站!')
def deleteDirApi(self): def deleteDirApi(self):
path = request.form.get('path', '').encode('utf-8') path = request.form.get('path', '').encode('utf-8')
if not os.path.exists(path): if not os.path.exists(path):
return public.returnJson(False, '指定文件不存在!') return mw.returnJson(False, '指定文件不存在!')
# 检查是否为.user.ini # 检查是否为.user.ini
if path.find('.user.ini'): if path.find('.user.ini'):
@@ -309,24 +361,205 @@ done
try: try:
if os.path.exists('data/recycle_bin.pl'): if os.path.exists('data/recycle_bin.pl'):
if self.mvRecycleBin(path): if self.mvRecycleBin(path):
return public.returnJson(True, '已将文件移动到回收站!') return mw.returnJson(True, '已将文件移动到回收站!')
public.execShell('rm -rf ' + path) mw.execShell('rm -rf ' + path)
public.writeLog('文件管理', '删除文件成功!', (path,)) mw.writeLog('文件管理', '删除文件成功!', (path,))
return public.returnJson(True, '删除文件成功!') return mw.returnJson(True, '删除文件成功!')
except: except:
return public.returnJson(False, '删除文件失败!') return mw.returnJson(False, '删除文件失败!')
def closeLogsApi(self): def closeLogsApi(self):
logPath = public.getLogsDir() logPath = mw.getLogsDir()
os.system('rm -f ' + logPath + '/*') os.system('rm -f ' + logPath + '/*')
os.system('kill -USR1 `cat ' + public.getServerDir() + os.system('kill -USR1 `cat ' + mw.getServerDir() +
'openresty/nginx/logs/nginx.pid`') 'openresty/nginx/logs/nginx.pid`')
public.writeLog('文件管理', '网站日志已被清空!') mw.writeLog('文件管理', '网站日志已被清空!')
tmp = self.getDirSize(logPath) tmp = self.getDirSize(logPath)
return public.returnJson(True, tmp[0].split()[0]) return mw.returnJson(True, tmp[0].split()[0])
def setBatchDataApi(self):
path = request.form.get('path', '').encode('utf-8')
stype = request.form.get('type', '').encode('utf-8')
access = request.form.get('access', '').encode('utf-8')
user = request.form.get('user', '').encode('utf-8')
data = request.form.get('data')
if stype == '1' or stype == '2':
session['selected'] = {
'path': path,
'type': stype,
'access': access,
'user': user,
'data': data
}
return mw.returnJson(True, '标记成功,请在目标目录点击粘贴所有按钮!')
elif stype == '3':
for key in json.loads(data):
try:
key = key.encode('utf-8')
filename = path + '/' + key
if not self.checkDir(filename):
return mw.returnJson(False, 'FILE_DANGER')
os.system('chmod -R ' + access + " '" + filename + "'")
os.system('chown -R ' + user + ':' +
user + " '" + filename + "'")
except:
continue
mw.writeLog('文件管理', '批量设置权限成功!')
return mw.returnJson(True, '批量设置权限成功!')
else:
import shutil
isRecyle = os.path.exists('data/recycle_bin.pl')
data = json.loads(data)
l = len(data)
i = 0
for key in data:
try:
filename = path + '/' + key.encode('utf-8')
topath = filename
if not os.path.exists(filename):
continue
i += 1
mw.writeSpeed(key, i, l)
if os.path.isdir(filename):
if not self.checkDir(filename):
return mw.returnJson(False, '请不要花样作死!')
if isRecyle:
self.mvRecycleBin(topath)
else:
shutil.rmtree(filename)
else:
if key == '.user.ini':
os.system('which chattr && chattr -i ' + filename)
if isRecyle:
self.mvRecycleBin(topath)
else:
os.remove(filename)
except:
continue
mw.writeSpeed(None, 0, 0)
mw.writeLog('文件管理', '批量删除成功!')
return mw.returnJson(True, '批量删除成功!')
def checkExistsFilesApi(self):
dfile = request.form.get('dfile', '').encode('utf-8')
filename = request.form.get('filename', '').encode('utf-8')
data = []
filesx = []
if filename == '':
filesx = json.loads(session['selected']['data'])
else:
filesx.append(filename)
print filesx
for fn in filesx:
if fn == '.':
continue
filename = dfile + '/' + fn
if os.path.exists(filename):
tmp = {}
stat = os.stat(filename)
tmp['filename'] = fn
tmp['size'] = os.path.getsize(filename)
tmp['mtime'] = str(int(stat.st_mtime))
data.append(tmp)
return mw.returnJson(True, 'ok', data)
def batchPasteApi(self):
path = request.form.get('path', '').encode('utf-8')
stype = request.form.get('type', '').encode('utf-8')
# filename = request.form.get('filename', '').encode('utf-8')
import shutil
if not self.checkDir(path):
return mw.returnJson(False, '请不要花样作死!')
i = 0
myfiles = json.loads(session['selected']['data'])
l = len(myfiles)
if stype == '1':
for key in myfiles:
i += 1
mw.writeSpeed(key, i, l)
try:
sfile = session['selected'][
'path'] + '/' + key.encode('utf-8')
dfile = path + '/' + key.encode('utf-8')
if os.path.isdir(sfile):
shutil.copytree(sfile, dfile)
else:
shutil.copyfile(sfile, dfile)
stat = os.stat(sfile)
os.chown(dfile, stat.st_uid, stat.st_gid)
except:
continue
msg = mw.getInfo('从[{1}]批量复制到[{2}]成功',
(session['selected']['path'], path,))
mw.writeLog('文件管理', msg)
else:
for key in myfiles:
try:
i += 1
mw.writeSpeed(key, i, l)
sfile = session['selected'][
'path'] + '/' + key.encode('utf-8')
dfile = path + '/' + key.encode('utf-8')
shutil.move(sfile, dfile)
except:
continue
msg = mw.getInfo('从[{1}]批量移动到[{2}]成功',
(session['selected']['path'], path,))
mw.writeLog('文件管理', msg)
mw.writeSpeed(None, 0, 0)
errorCount = len(myfiles) - i
del(session['selected'])
msg = mw.getInfo('批量操作成功[{1}],失败[{2}]', (str(i), str(errorCount)))
return mw.returnJson(True, msg)
def copyFileApi(self):
sfile = request.form.get('sfile', '').encode('utf-8')
dfile = request.form.get('dfile', '').encode('utf-8')
if not os.path.exists(sfile):
return mw.returnJson(False, '指定文件不存在!')
if os.path.isdir(sfile):
return self.copyDir(sfile, dfile)
import shutil
try:
shutil.copyfile(sfile, dfile)
msg = mw.getInfo('复制文件[{1}]到[{2}]成功!', (sfile, dfile,))
mw.writeLog('文件管理', msg)
stat = os.stat(sfile)
os.chown(dfile, stat.st_uid, stat.st_gid)
return mw.returnJson(True, '文件复制成功!')
except:
return mw.returnJson(False, '文件复制失败!')
##### ----- end ----- ### ##### ----- end ----- ###
def copyDir(self, sfile, dfile):
if not os.path.exists(sfile):
return mw.returnJson(False, '指定目录不存在!')
if os.path.exists(dfile):
return mw.returnJson(False, '指定目录已存在!')
import shutil
try:
shutil.copytree(sfile, dfile)
stat = os.stat(sfile)
os.chown(dfile, stat.st_uid, stat.st_gid)
msg = mw.getInfo('复制目录[{1}]到[{2}]成功!', (sfile, dfile))
mw.writeLog('文件管理', msg)
return mw.returnJson(True, '目录复制成功!')
except:
return mw.returnJson(False, '目录复制失败!')
# 检查敏感目录 # 检查敏感目录
def checkDir(self, path): def checkDir(self, path):
path = path.replace('//', '/') path = path.replace('//', '/')
@@ -357,15 +590,15 @@ done
'/selinux', '/selinux',
'/www/server', '/www/server',
'/www/server/data', '/www/server/data',
public.getRootDir()) mw.getRootDir())
return not path in nDirs return not path in nDirs
def getDirSize(self, path): def getDirSize(self, path):
if public.getOs() == 'darwin': if mw.getOs() == 'darwin':
tmp = public.execShell('du -sh ' + path) tmp = mw.execShell('du -sh ' + path)
else: else:
tmp = public.execShell('du -sbh ' + path) tmp = mw.execShell('du -sbh ' + path)
return tmp return tmp
def checkFileName(self, filename): def checkFileName(self, filename):
@@ -380,8 +613,8 @@ done
def setFileAccept(self, filename): def setFileAccept(self, filename):
auth = 'www:www' auth = 'www:www'
if public.getOs() == 'darwin': if mw.getOs() == 'darwin':
user = public.execShell( user = mw.execShell(
"who | sed -n '2, 1p' |awk '{print $1}'")[0].strip() "who | sed -n '2, 1p' |awk '{print $1}'")[0].strip()
auth = user + ':staff' auth = user + ':staff'
os.system('chown -R ' + auth + ' ' + filename) os.system('chown -R ' + auth + ' ' + filename)
@@ -397,20 +630,20 @@ done
try: try:
import shutil import shutil
shutil.move(path, rFile) shutil.move(path, rFile)
public.writeLog('文件管理', public.getInfo( mw.writeLog('文件管理', mw.getInfo(
'移动文件[{1}]到回收站成功!', (path))) '移动文件[{1}]到回收站成功!', (path)))
return True return True
except: except:
public.writeLog('文件管理', public.getInfo( mw.writeLog('文件管理', mw.getInfo(
'移动文件[{1}]到回收站失败!', (path))) '移动文件[{1}]到回收站失败!', (path)))
return False return False
def getBody(self, path): def getBody(self, path):
if not os.path.exists(path): if not os.path.exists(path):
return public.returnJson(False, '文件不存在', (path,)) return mw.returnJson(False, '文件不存在', (path,))
if os.path.getsize(path) > 2097152: if os.path.getsize(path) > 2097152:
return public.returnJson(False, u'不能在线编辑大于2MB的文件!') return mw.returnJson(False, u'不能在线编辑大于2MB的文件!')
fp = open(path, 'rb') fp = open(path, 'rb')
data = {} data = {}
@@ -457,13 +690,13 @@ done
data['data'] = srcBody.decode('utf-8') data['data'] = srcBody.decode('utf-8')
data['encoding'] = u'utf-8' data['encoding'] = u'utf-8'
return public.returnJson(True, 'OK', data) return mw.returnJson(True, 'OK', data)
except Exception as ex: except Exception as ex:
return public.returnJson(False, u'文件编码不被兼容,无法正确读取文件!' + str(ex)) return mw.returnJson(False, u'文件编码不被兼容,无法正确读取文件!' + str(ex))
def saveBody(self, path, data, encoding='utf-8'): def saveBody(self, path, data, encoding='utf-8'):
if not os.path.exists(path): if not os.path.exists(path):
return public.returnJson(False, '文件不存在') return mw.returnJson(False, '文件不存在')
try: try:
if encoding == 'ascii': if encoding == 'ascii':
encoding = 'utf-8' encoding = 'utf-8'
@@ -477,18 +710,18 @@ done
fp.write(data) fp.write(data)
fp.close() fp.close()
public.writeLog('文件管理', '文件保存成功', (path,)) mw.writeLog('文件管理', '文件保存成功', (path,))
return public.returnJson(True, '文件保存成功') return mw.returnJson(True, '文件保存成功')
except Exception as ex: except Exception as ex:
return public.returnJson(False, 'FILE_SAVE_ERR:' + str(ex)) return mw.returnJson(False, 'FILE_SAVE_ERR:' + str(ex))
def zip(self, sfile, dfile, stype, path): def zip(self, sfile, dfile, stype, path):
if sfile.find(',') == -1: if sfile.find(',') == -1:
if not os.path.exists(path + '/' + sfile): if not os.path.exists(path + '/' + sfile):
return public.returnMsg(False, '指定文件不存在!') return mw.returnMsg(False, '指定文件不存在!')
try: try:
tmps = public.getRunDir() + '/tmp/panelExec.log' tmps = mw.getRunDir() + '/tmp/panelExec.log'
if stype == 'zip': if stype == 'zip':
os.system("cd '" + path + "' && zip '" + dfile + os.system("cd '" + path + "' && zip '" + dfile +
"' -r '" + sfile + "' > " + tmps + " 2>&1") "' -r '" + sfile + "' > " + tmps + " 2>&1")
@@ -501,15 +734,15 @@ done
os.system("cd '" + path + "' && tar -zcvf '" + os.system("cd '" + path + "' && tar -zcvf '" +
dfile + "' " + sfiles + " > " + tmps + " 2>&1") dfile + "' " + sfiles + " > " + tmps + " 2>&1")
self.setFileAccept(dfile) self.setFileAccept(dfile)
public.writeLog("文件管理", '文件压缩成功!', (sfile, dfile)) mw.writeLog("文件管理", '文件压缩成功!', (sfile, dfile))
return public.returnJson(True, '文件压缩成功!') return mw.returnJson(True, '文件压缩成功!')
except: except:
return public.returnJson(False, '文件压缩失败!') return mw.returnJson(False, '文件压缩失败!')
def delete(self, path): def delete(self, path):
if not os.path.exists(path): if not os.path.exists(path):
return public.returnJson(False, '指定文件不存在!') return mw.returnJson(False, '指定文件不存在!')
# 检查是否为.user.ini # 检查是否为.user.ini
if path.find('.user.ini') >= 0: if path.find('.user.ini') >= 0:
@@ -518,13 +751,13 @@ done
try: try:
if os.path.exists('data/recycle_bin.pl'): if os.path.exists('data/recycle_bin.pl'):
if self.mvRecycleBin(path): if self.mvRecycleBin(path):
return public.returnJson(True, '已将文件移动到回收站!') return mw.returnJson(True, '已将文件移动到回收站!')
os.remove(path) os.remove(path)
public.writeLog('文件管理', public.getInfo( mw.writeLog('文件管理', mw.getInfo(
'删除文件[{1}]成功!', (path))) '删除文件[{1}]成功!', (path)))
return public.returnJson(True, '删除文件成功!') return mw.returnJson(True, '删除文件成功!')
except: except:
return public.returnJson(False, '删除文件失败!') return mw.returnJson(False, '删除文件失败!')
def getAccess(self, filename): def getAccess(self, filename):
data = {} data = {}
@@ -559,7 +792,7 @@ done
info['row'] = page_size info['row'] = page_size
info['p'] = page info['p'] = page
info['tojs'] = 'getFiles' info['tojs'] = 'getFiles'
pageObj = public.getPageObject(info, '1,2,3,4,5,6,7,8') pageObj = mw.getPageObject(info, '1,2,3,4,5,6,7,8')
data['PAGE'] = pageObj[0] data['PAGE'] = pageObj[0]
i = 0 i = 0
@@ -607,4 +840,4 @@ done
data['DIR'] = sorted(dirnames) data['DIR'] = sorted(dirnames)
data['FILES'] = sorted(filenames) data['FILES'] = sorted(filenames)
data['PATH'] = path.replace('//', '/') data['PATH'] = path.replace('//', '/')
return public.getJson(data) return mw.getJson(data)
+118 -109
View File
@@ -4,7 +4,7 @@ import psutil
import time import time
import os import os
import sys import sys
import public import mw
import re import re
import json import json
import pwd import pwd
@@ -23,7 +23,7 @@ class firewall_api:
self.__isFirewalld = True self.__isFirewalld = True
if os.path.exists('/usr/sbin/ufw'): if os.path.exists('/usr/sbin/ufw'):
self.__isUfw = True self.__isUfw = True
if public.isAppleSystem(): if mw.isAppleSystem():
self.__isMac = True self.__isMac = True
##### ----- start ----- ### ##### ----- start ----- ###
@@ -35,30 +35,34 @@ class firewall_api:
rep = "^\d{1,3}\.\d{1,3}\.\d{1,3}\.\d{1,3}(\/\d{1,2})?$" rep = "^\d{1,3}\.\d{1,3}\.\d{1,3}\.\d{1,3}(\/\d{1,2})?$"
if not re.search(rep, port): if not re.search(rep, port):
return public.returnJson(False, '您输入的IP地址不合法!') return mw.returnJson(False, '您输入的IP地址不合法!')
address = port address = port
if public.M('firewall').where("port=?", (address,)).count() > 0: if mw.M('firewall').where("port=?", (address,)).count() > 0:
return public.returnJson(False, '您要放屏蔽的IP已存在屏蔽列表,无需重复处理!') return mw.returnJson(False, '您要放屏蔽的IP已存在屏蔽列表,无需重复处理!')
if self.__isUfw: if self.__isUfw:
public.execShell('ufw deny from ' + address + ' to any') mw.execShell('ufw deny from ' + address + ' to any')
else: else:
if self.__isFirewalld: if self.__isFirewalld:
cmd = 'firewall-cmd --permanent --add-rich-rule=\'rule family=ipv4 source address="' + \ cmd = 'firewall-cmd --permanent --add-rich-rule=\'rule family=ipv4 source address="' + \
address + '" drop\'' address + '" drop\''
public.execShell(cmd) mw.execShell(cmd)
else: else:
cmd = 'iptables -I INPUT -s ' + address + ' -j DROP' cmd = 'iptables -I INPUT -s ' + address + ' -j DROP'
public.execShell(cmd) mw.execShell(cmd)
msg = public.getInfo('屏蔽IP[{1}]成功!', (address,)) msg = mw.getInfo('屏蔽IP[{1}]成功!', (address,))
public.writeLog("防火墙管理", msg) mw.writeLog("防火墙管理", msg)
addtime = time.strftime('%Y-%m-%d %X', time.localtime()) addtime = time.strftime('%Y-%m-%d %X', time.localtime())
public.M('firewall').add('port,ps,addtime', (address, ps, addtime)) mw.M('firewall').add('port,ps,addtime', (address, ps, addtime))
self.firewallReload() self.firewallReload()
return public.returnJson(True, '添加成功!') return mw.returnJson(True, '添加成功!')
# 添加放行端口 # 添加放行端口
def addAcceptPortApi(self): def addAcceptPortApi(self):
if not self.getFwStatus():
return mw.returnJson(False, '防火墙启动时,才能添加规则!')
import re import re
import time import time
port = request.form.get('port', '').strip() port = request.form.get('port', '').strip()
@@ -67,76 +71,79 @@ class firewall_api:
rep = "^\d{1,5}(:\d{1,5})?$" rep = "^\d{1,5}(:\d{1,5})?$"
if not re.search(rep, port): if not re.search(rep, port):
return public.returnJson(False, '端口范围不正确!') return mw.returnJson(False, '端口范围不正确!')
if public.M('firewall').where("port=?", (port,)).count() > 0: if mw.M('firewall').where("port=?", (port,)).count() > 0:
return public.returnJson(False, '您要放行的端口已存在,无需重复放行!') return mw.returnJson(False, '您要放行的端口已存在,无需重复放行!')
msg = public.getInfo('放行端口[{1}]成功', (port,)) msg = mw.getInfo('放行端口[{1}]成功', (port,))
public.writeLog("防火墙管理", msg) mw.writeLog("防火墙管理", msg)
addtime = time.strftime('%Y-%m-%d %X', time.localtime()) addtime = time.strftime('%Y-%m-%d %X', time.localtime())
public.M('firewall').add('port,ps,addtime', (port, ps, addtime)) mw.M('firewall').add('port,ps,addtime', (port, ps, addtime))
self.addAcceptPort(port) self.addAcceptPort(port)
self.firewallReload() self.firewallReload()
return public.returnJson(True, '添加放行(' + port + ')端口成功!') return mw.returnJson(True, '添加放行(' + port + ')端口成功!')
# 删除IP屏蔽 # 删除IP屏蔽
def delDropAddressApi(self): def delDropAddressApi(self):
if not self.getFwStatus():
return mw.returnJson(False, '防火墙启动时,才能删除规则!')
port = request.form.get('port', '').strip() port = request.form.get('port', '').strip()
ps = request.form.get('ps', '').strip() ps = request.form.get('ps', '').strip()
sid = request.form.get('id', '').strip() sid = request.form.get('id', '').strip()
address = port address = port
if self.__isUfw: if self.__isUfw:
public.execShell('ufw delete deny from ' + address + ' to any') mw.execShell('ufw delete deny from ' + address + ' to any')
else: else:
if self.__isFirewalld: if self.__isFirewalld:
public.execShell( mw.execShell(
'firewall-cmd --permanent --remove-rich-rule=\'rule family=ipv4 source address="' + address + '" drop\'') 'firewall-cmd --permanent --remove-rich-rule=\'rule family=ipv4 source address="' + address + '" drop\'')
elif self.__isMac: elif self.__isMac:
pass pass
else: else:
cmd = 'iptables -D INPUT -s ' + address + ' -j DROP' cmd = 'iptables -D INPUT -s ' + address + ' -j DROP'
public.execShell(cmd) mw.execShell(cmd)
msg = public.getInfo('解除IP[{1}]的屏蔽!', (address,)) msg = mw.getInfo('解除IP[{1}]的屏蔽!', (address,))
public.writeLog("防火墙管理", msg) mw.writeLog("防火墙管理", msg)
public.M('firewall').where("id=?", (sid,)).delete() mw.M('firewall').where("id=?", (sid,)).delete()
self.firewallReload() self.firewallReload()
return public.returnJson(True, '删除成功!') return mw.returnJson(True, '删除成功!')
# 删除放行端口 # 删除放行端口
def delAcceptPortApi(self): def delAcceptPortApi(self):
port = request.form.get('port', '').strip() port = request.form.get('port', '').strip()
sid = request.form.get('id', '').strip() sid = request.form.get('id', '').strip()
mw_port = public.readFile('data/port.pl') mw_port = mw.readFile('data/port.pl')
try: try:
if(port == mw_port): if(port == mw_port):
return public.returnJson(False, '失败,不能删除当前面板端口!') return mw.returnJson(False, '失败,不能删除当前面板端口!')
if self.__isUfw: if self.__isUfw:
public.execShell('ufw delete allow ' + port + '/tcp') mw.execShell('ufw delete allow ' + port + '/tcp')
else: else:
if self.__isFirewalld: if self.__isFirewalld:
public.execShell( mw.execShell(
'firewall-cmd --permanent --zone=public --remove-port=' + port + '/tcp') 'firewall-cmd --permanent --zone=public --remove-port=' + port + '/tcp')
public.execShell( mw.execShell(
'firewall-cmd --permanent --zone=public --remove-port=' + port + '/udp') 'firewall-cmd --permanent --zone=public --remove-port=' + port + '/udp')
else: else:
public.execShell( mw.execShell(
'iptables -D INPUT -p tcp -m state --state NEW -m tcp --dport ' + port + ' -j ACCEPT') 'iptables -D INPUT -p tcp -m state --state NEW -m tcp --dport ' + port + ' -j ACCEPT')
msg = public.getInfo('删除防火墙放行端口[{1}]成功!', (port,)) msg = mw.getInfo('删除防火墙放行端口[{1}]成功!', (port,))
public.writeLog("防火墙管理", msg) mw.writeLog("防火墙管理", msg)
public.M('firewall').where("id=?", (sid,)).delete() mw.M('firewall').where("id=?", (sid,)).delete()
self.firewallReload() self.firewallReload()
return public.returnJson(True, '删除成功!') return mw.returnJson(True, '删除成功!')
except Exception as e: except Exception as e:
return public.returnJson(False, '删除失败!:' + str(e)) return mw.returnJson(False, '删除失败!:' + str(e))
def getWwwPathApi(self): def getWwwPathApi(self):
path = public.getLogsDir() path = mw.getLogsDir()
return public.getJson({'path': path}) return mw.getJson({'path': path})
def getListApi(self): def getListApi(self):
p = request.form.get('p', '1').strip() p = request.form.get('p', '1').strip()
@@ -151,17 +158,17 @@ class firewall_api:
def getSshInfoApi(self): def getSshInfoApi(self):
file = '/etc/ssh/sshd_config' file = '/etc/ssh/sshd_config'
conf = public.readFile(file) conf = mw.readFile(file)
rep = "#*Port\s+([0-9]+)\s*\n" rep = "#*Port\s+([0-9]+)\s*\n"
port = re.search(rep, conf).groups(0)[0] port = re.search(rep, conf).groups(0)[0]
isPing = True isPing = True
try: try:
if public.isAppleSystem(): if mw.isAppleSystem():
isPing = True isPing = True
else: else:
file = '/etc/sysctl.conf' file = '/etc/sysctl.conf'
conf = public.readFile(file) conf = mw.readFile(file)
rep = "#*net\.ipv4\.icmp_echo_ignore_all\s*=\s*([0-9]+)" rep = "#*net\.ipv4\.icmp_echo_ignore_all\s*=\s*([0-9]+)"
tmp = re.search(rep, conf).groups(0)[0] tmp = re.search(rep, conf).groups(0)[0]
if tmp == '1': if tmp == '1':
@@ -175,17 +182,17 @@ class firewall_api:
if os.path.exists('/usr/bin/apt-get'): if os.path.exists('/usr/bin/apt-get'):
if os.path.exists('/etc/init.d/sshd'): if os.path.exists('/etc/init.d/sshd'):
cmd = "service sshd status | grep -P '(dead|stop)'|grep -v grep" cmd = "service sshd status | grep -P '(dead|stop)'|grep -v grep"
status = public.execShell(cmd) status = mw.execShell(cmd)
else: else:
cmd = "service ssh status | grep -P '(dead|stop)'|grep -v grep" cmd = "service ssh status | grep -P '(dead|stop)'|grep -v grep"
status = public.execShell(cmd) status = mw.execShell(cmd)
else: else:
if version.find(' 7.') != -1: if version.find(' 7.') != -1:
cmd = "systemctl status sshd.service | grep 'dead'|grep -v grep" cmd = "systemctl status sshd.service | grep 'dead'|grep -v grep"
status = public.execShell(cmd) status = mw.execShell(cmd)
else: else:
cmd = "/etc/init.d/sshd status | grep -e 'stopped' -e '已停'|grep -v grep" cmd = "/etc/init.d/sshd status | grep -e 'stopped' -e '已停'|grep -v grep"
status = public.execShell(cmd) status = mw.execShell(cmd)
if len(status[0]) > 3: if len(status[0]) > 3:
status = False status = False
else: else:
@@ -196,54 +203,54 @@ class firewall_api:
data['status'] = status data['status'] = status
data['ping'] = isPing data['ping'] = isPing
if public.isAppleSystem(): if mw.isAppleSystem():
data['firewall_status'] = False data['firewall_status'] = False
else: else:
data['firewall_status'] = self.getFwStatus() data['firewall_status'] = self.getFwStatus()
return public.getJson(data) return mw.getJson(data)
def setSshPortApi(self): def setSshPortApi(self):
port = request.form.get('port', '1').strip() port = request.form.get('port', '1').strip()
if int(port) < 22 or int(port) > 65535: if int(port) < 22 or int(port) > 65535:
return public.returnJson(False, '端口范围必需在22-65535之间!') return mw.returnJson(False, '端口范围必需在22-65535之间!')
ports = ['21', '25', '80', '443', '7200', '8080', '888', '8888'] ports = ['21', '25', '80', '443', '7200', '8080', '888', '8888']
if port in ports: if port in ports:
return public.returnJson(False, '(' + port + ')' + '特殊端口不可设置!') return mw.returnJson(False, '(' + port + ')' + '特殊端口不可设置!')
file = '/etc/ssh/sshd_config' file = '/etc/ssh/sshd_config'
conf = public.readFile(file) conf = mw.readFile(file)
rep = "#*Port\s+([0-9]+)\s*\n" rep = "#*Port\s+([0-9]+)\s*\n"
conf = re.sub(rep, "Port " + port + "\n", conf) conf = re.sub(rep, "Port " + port + "\n", conf)
public.writeFile(file, conf) mw.writeFile(file, conf)
if self.__isFirewalld: if self.__isFirewalld:
public.execShell('setenforce 0') mw.execShell('setenforce 0')
public.execShell( mw.execShell(
'sed -i "s#SELINUX=enforcing#SELINUX=disabled#" /etc/selinux/config') 'sed -i "s#SELINUX=enforcing#SELINUX=disabled#" /etc/selinux/config')
public.execShell("systemctl restart sshd.service") mw.execShell("systemctl restart sshd.service")
elif self.__isUfw: elif self.__isUfw:
public.execShell('ufw allow ' + port + '/tcp') mw.execShell('ufw allow ' + port + '/tcp')
public.execShell("service ssh restart") mw.execShell("service ssh restart")
else: else:
public.execShell( mw.execShell(
'iptables -I INPUT -p tcp -m state --state NEW -m tcp --dport ' + port + ' -j ACCEPT') 'iptables -I INPUT -p tcp -m state --state NEW -m tcp --dport ' + port + ' -j ACCEPT')
public.execShell("/etc/init.d/sshd restart") mw.execShell("/etc/init.d/sshd restart")
self.firewallReload() self.firewallReload()
# public.M('firewall').where( # mw.M('firewall').where(
# "ps=?", ('SSH远程管理服务',)).setField('port', port) # "ps=?", ('SSH远程管理服务',)).setField('port', port)
msg = public.getInfo('改SSH端口为[{1}]成功!', port) msg = mw.getInfo('改SSH端口为[{1}]成功!', port)
public.writeLog("防火墙管理", msg) mw.writeLog("防火墙管理", msg)
return public.returnJson(True, '修改成功!') return mw.returnJson(True, '修改成功!')
def setSshStatusApi(self): def setSshStatusApi(self):
if public.isAppleSystem(): if mw.isAppleSystem():
return public.returnJson(True, '开发机不能操作!') return mw.returnJson(True, '开发机不能操作!')
status = request.form.get('status', '1').strip() status = request.form.get('status', '1').strip()
version = public.readFile('/etc/redhat-release') version = mw.readFile('/etc/redhat-release')
if int(status) == 1: if int(status) == 1:
msg = 'SSH服务已停用' msg = 'SSH服务已停用'
act = 'stop' act = 'stop'
@@ -252,66 +259,68 @@ class firewall_api:
act = 'start' act = 'start'
if not os.path.exists('/etc/redhat-release'): if not os.path.exists('/etc/redhat-release'):
public.execShell('service ssh ' + act) mw.execShell('service ssh ' + act)
elif version.find(' 7.') != -1: elif version.find(' 7.') != -1:
public.execShell("systemctl " + act + " sshd.service") mw.execShell("systemctl " + act + " sshd.service")
else: else:
public.execShell("/etc/init.d/sshd " + act) mw.execShell("/etc/init.d/sshd " + act)
public.writeLog("防火墙管理", msg) mw.writeLog("防火墙管理", msg)
return public.returnJson(True, '操作成功!') return mw.returnJson(True, '操作成功!')
def setPingApi(self): def setPingApi(self):
if public.isAppleSystem(): if mw.isAppleSystem():
return public.returnJson(True, '开发机不能操作!') return mw.returnJson(True, '开发机不能操作!')
status = request.form.get('status') status = request.form.get('status')
filename = '/etc/sysctl.conf' filename = '/etc/sysctl.conf'
conf = public.readFile(filename) conf = mw.readFile(filename)
if conf.find('net.ipv4.icmp_echo') != -1: if conf.find('net.ipv4.icmp_echo') != -1:
rep = u"net\.ipv4\.icmp_echo.*" rep = u"net\.ipv4\.icmp_echo.*"
conf = re.sub(rep, 'net.ipv4.icmp_echo_ignore_all=' + status, conf) conf = re.sub(rep, 'net.ipv4.icmp_echo_ignore_all=' + status, conf)
else: else:
conf += "\nnet.ipv4.icmp_echo_ignore_all=" + status conf += "\nnet.ipv4.icmp_echo_ignore_all=" + status
public.writeFile(filename, conf) mw.writeFile(filename, conf)
public.execShell('sysctl -p') mw.execShell('sysctl -p')
return public.returnJson(True, '设置成功!') return mw.returnJson(True, '设置成功!')
def setFwApi(self): def setFwApi(self):
if public.isAppleSystem(): if mw.isAppleSystem():
return public.returnJson(True, '开发机不能设置!') return mw.returnJson(True, '开发机不能设置!')
status = request.form.get('status', '1') status = request.form.get('status', '1')
if status == '1': if status == '1':
if self.__isUfw: if self.__isUfw:
public.execShell('/usr/sbin/ufw stop') mw.execShell('/usr/sbin/ufw stop')
return return
if self.__isFirewalld: if self.__isFirewalld:
public.execShell('systemctl stop firewalld.service') mw.execShell('systemctl stop firewalld.service')
mw.execShell('systemctl disable firewalld.service')
elif self.__isMac: elif self.__isMac:
pass pass
else: else:
public.execShell('/etc/init.d/iptables save') mw.execShell('/etc/init.d/iptables save')
public.execShell('/etc/init.d/iptables stop') mw.execShell('/etc/init.d/iptables stop')
else: else:
if self.__isUfw: if self.__isUfw:
public.execShell('/usr/sbin/ufw start') mw.execShell('/usr/sbin/ufw start')
return return
if self.__isFirewalld: if self.__isFirewalld:
public.execShell('systemctl start firewalld.service') mw.execShell('systemctl start firewalld.service')
mw.execShell('systemctl enable firewalld.service')
elif self.__isMac: elif self.__isMac:
pass pass
else: else:
public.execShell('/etc/init.d/iptables save') mw.execShell('/etc/init.d/iptables save')
public.execShell('/etc/init.d/iptables restart') mw.execShell('/etc/init.d/iptables restart')
return public.returnJson(True, '设置成功!') return mw.returnJson(True, '设置成功!')
def delPanelLogsApi(self): def delPanelLogsApi(self):
public.M('logs').where('id>?', (0,)).delete() mw.M('logs').where('id>?', (0,)).delete()
public.writeLog('面板设置', '面板操作日志已清空!') mw.writeLog('面板设置', '面板操作日志已清空!')
return public.returnJson(True, '面板操作日志已清空!') return mw.returnJson(True, '面板操作日志已清空!')
##### ----- start ----- ### ##### ----- start ----- ###
@@ -319,19 +328,19 @@ class firewall_api:
start = (page - 1) * limit start = (page - 1) * limit
_list = public.M('firewall').field('id,port,ps,addtime').limit( _list = mw.M('firewall').field('id,port,ps,addtime').limit(
str(start) + ',' + str(limit)).order('id desc').select() str(start) + ',' + str(limit)).order('id desc').select()
data = {} data = {}
data['data'] = _list data['data'] = _list
count = public.M('firewall').count() count = mw.M('firewall').count()
_page = {} _page = {}
_page['count'] = count _page['count'] = count
_page['tojs'] = 'showAccept' _page['tojs'] = 'showAccept'
_page['p'] = page _page['p'] = page
data['page'] = public.getPage(_page) data['page'] = mw.getPage(_page)
return public.getJson(data) return mw.getJson(data)
def getLogList(self, page, limit, search=''): def getLogList(self, page, limit, search=''):
find_search = '' find_search = ''
@@ -341,56 +350,56 @@ class firewall_api:
start = (page - 1) * limit start = (page - 1) * limit
_list = public.M('logs').where(find_search, ()).field( _list = mw.M('logs').where(find_search, ()).field(
'id,type,log,addtime').limit(str(start) + ',' + str(limit)).order('id desc').select() 'id,type,log,addtime').limit(str(start) + ',' + str(limit)).order('id desc').select()
data = {} data = {}
data['data'] = _list data['data'] = _list
count = public.M('logs').where(find_search, ()).count() count = mw.M('logs').where(find_search, ()).count()
_page = {} _page = {}
_page['count'] = count _page['count'] = count
_page['tojs'] = 'getLogs' _page['tojs'] = 'getLogs'
_page['p'] = page _page['p'] = page
data['page'] = public.getPage(_page) data['page'] = mw.getPage(_page)
return public.getJson(data) return mw.getJson(data)
def addAcceptPort(self, port): def addAcceptPort(self, port):
if self.__isUfw: if self.__isUfw:
public.execShell('ufw allow ' + port + '/tcp') mw.execShell('ufw allow ' + port + '/tcp')
else: else:
if self.__isFirewalld: if self.__isFirewalld:
port = port.replace(':', '-') port = port.replace(':', '-')
cmd = 'firewall-cmd --permanent --zone=public --add-port=' + port + '/tcp' cmd = 'firewall-cmd --permanent --zone=public --add-port=' + port + '/tcp'
public.execShell(cmd) mw.execShell(cmd)
elif self.__isMac: elif self.__isMac:
pass pass
else: else:
cmd = 'iptables -I INPUT -p tcp -m state --state NEW -m tcp --dport ' + port + ' -j ACCEPT' cmd = 'iptables -I INPUT -p tcp -m state --state NEW -m tcp --dport ' + port + ' -j ACCEPT'
public.execShell(cmd) mw.execShell(cmd)
def firewallReload(self): def firewallReload(self):
if self.__isUfw: if self.__isUfw:
public.execShell('/usr/sbin/ufw reload') mw.execShell('/usr/sbin/ufw reload')
return return
if self.__isFirewalld: if self.__isFirewalld:
public.execShell('firewall-cmd --reload') mw.execShell('firewall-cmd --reload')
elif self.__isMac: elif self.__isMac:
pass pass
else: else:
public.execShell('/etc/init.d/iptables save') mw.execShell('/etc/init.d/iptables save')
public.execShell('/etc/init.d/iptables restart') mw.execShell('/etc/init.d/iptables restart')
def getFwStatus(self): def getFwStatus(self):
if self.__isUfw: if self.__isUfw:
cmd = "ps -ef|grep ufw |grep -v grep | awk '{print $2}'" cmd = "ps -ef|grep ufw |grep -v grep | awk '{print $2}'"
data = public.execShell(cmd) data = mw.execShell(cmd)
if data[0] == '': if data[0] == '':
return False return False
return True return True
if self.__isFirewalld: if self.__isFirewalld:
cmd = "ps -ef|grep firewalld |grep -v grep | awk '{print $2}'" cmd = "ps -ef|grep firewalld |grep -v grep | awk '{print $2}'"
data = public.execShell(cmd) data = mw.execShell(cmd)
if data[0] == '': if data[0] == '':
return False return False
return True return True
@@ -398,7 +407,7 @@ class firewall_api:
return False return False
else: else:
cmd = "ps -ef|grep iptables |grep -v grep | awk '{print $2}'" cmd = "ps -ef|grep iptables |grep -v grep | awk '{print $2}'"
data = public.execShell(cmd) data = mw.execShell(cmd)
if data[0] == '': if data[0] == '':
return False return False
return True return True
+2 -2
View File
@@ -429,7 +429,7 @@ def writeSpeed(title, used, total, speed=0):
def getSpeed(): def getSpeed():
# 取进度 # 取进度
path = public.getRootDir() path = getRootDir()
data = readFile(path + '/tmp/panelSpeed.pl') data = readFile(path + '/tmp/panelSpeed.pl')
if not data: if not data:
data = json.dumps({'title': None, 'progress': 0, data = json.dumps({'title': None, 'progress': 0,
@@ -882,7 +882,7 @@ def get_string_arr(t):
def getSSHPort(): def getSSHPort():
try: try:
file = '/etc/ssh/sshd_config' file = '/etc/ssh/sshd_config'
conf = ReadFile(file) conf = readFile(file)
rep = "#*Port\s+([0-9]+)\s*\n" rep = "#*Port\s+([0-9]+)\s*\n"
port = re.search(rep, conf).groups(0)[0] port = re.search(rep, conf).groups(0)[0]
return int(port) return int(port)
+2 -2
View File
@@ -2,7 +2,7 @@
import math import math
import string import string
import public import mw
class Page(): class Page():
@@ -29,7 +29,7 @@ class Page():
__END_NUM = None # 结束行 __END_NUM = None # 结束行
def __init__(self): def __init__(self):
# tmp = public.getMsg('PAGE') # tmp = mw.getMsg('PAGE')
if False: if False:
self.__PREV = tmp['PREV'] self.__PREV = tmp['PREV']
self.__NEXT = tmp['NEXT'] self.__NEXT = tmp['NEXT']
+98 -95
View File
@@ -3,7 +3,7 @@
import psutil import psutil
import time import time
import os import os
import public import mw
import re import re
import json import json
@@ -50,7 +50,7 @@ class plugins_api:
sPage = request.args.get('p', '1') sPage = request.args.get('p', '1')
# print sPage # print sPage
data = self.getPluginList(sType, int(sPage)) data = self.getPluginList(sType, int(sPage))
return public.getJson(data) return mw.getJson(data)
def fileApi(self): def fileApi(self):
name = request.args.get('name', '') name = request.args.get('name', '')
@@ -65,24 +65,24 @@ class plugins_api:
if not os.path.exists(file): if not os.path.exists(file):
return '' return ''
c = public.readFile(file) c = mw.readFile(file)
return c return c
def indexListApi(self): def indexListApi(self):
data = self.getIndexList() data = self.getIndexList()
return public.getJson(data) return mw.getJson(data)
def indexSortApi(self): def indexSortApi(self):
sort = request.form.get('ssort', '') sort = request.form.get('ssort', '')
if sort.strip() == '': if sort.strip() == '':
return public.returnJson(False, '排序数据不能为空!') return mw.returnJson(False, '排序数据不能为空!')
data = self.setIndexSort(sort) data = self.setIndexSort(sort)
if data: if data:
return public.returnJson(True, '成功!') return mw.returnJson(True, '成功!')
return public.returnJson(False, '失败!') return mw.returnJson(False, '失败!')
def installApi(self): def installApi(self):
rundir = public.getRunDir() rundir = mw.getRunDir()
name = request.form.get('name', '') name = request.form.get('name', '')
version = request.form.get('version', '') version = request.form.get('version', '')
@@ -92,18 +92,18 @@ class plugins_api:
mmsg = 'upgrade' mmsg = 'upgrade'
if name.strip() == '': if name.strip() == '':
return public.returnJson(False, '缺少插件名称!', ()) return mw.returnJson(False, '缺少插件名称!', ())
if version.strip() == '': if version.strip() == '':
return public.returnJson(False, '缺少版本信息!', ()) return mw.returnJson(False, '缺少版本信息!', ())
infoJsonPos = self.__plugin_dir + '/' + name + '/' + 'info.json' infoJsonPos = self.__plugin_dir + '/' + name + '/' + 'info.json'
print infoJsonPos # print infoJsonPos
if not os.path.exists(infoJsonPos): if not os.path.exists(infoJsonPos):
return public.retJson(False, '配置文件不存在!', ()) return mw.returnJson(False, '配置文件不存在!', ())
pluginInfo = json.loads(public.readFile(infoJsonPos)) pluginInfo = json.loads(mw.readFile(infoJsonPos))
execstr = "cd " + os.getcwd() + "/plugins/" + \ execstr = "cd " + os.getcwd() + "/plugins/" + \
name + " && /bin/bash " + pluginInfo["shell"] \ name + " && /bin/bash " + pluginInfo["shell"] \
@@ -112,25 +112,25 @@ class plugins_api:
taskAdd = (None, mmsg + '[' + name + '-' + version + ']', taskAdd = (None, mmsg + '[' + name + '-' + version + ']',
'execshell', '0', time.strftime('%Y-%m-%d %H:%M:%S'), execstr) 'execshell', '0', time.strftime('%Y-%m-%d %H:%M:%S'), execstr)
public.M('tasks').add('id,name,type,status,addtime, execstr', taskAdd) mw.M('tasks').add('id,name,type,status,addtime, execstr', taskAdd)
return public.returnJson(True, '已将安装任务添加到队列!') return mw.returnJson(True, '已将安装任务添加到队列!')
def uninstallOldApi(self): def uninstallOldApi(self):
rundir = public.getRunDir() rundir = mw.getRunDir()
name = request.form.get('name', '') name = request.form.get('name', '')
version = request.form.get('version', '') version = request.form.get('version', '')
if name.strip() == '': if name.strip() == '':
return public.returnJson(False, "缺少插件名称!", ()) return mw.returnJson(False, "缺少插件名称!", ())
if version.strip() == '': if version.strip() == '':
return public.returnJson(False, "缺少版本信息!", ()) return mw.returnJson(False, "缺少版本信息!", ())
infoJsonPos = self.__plugin_dir + '/' + name + '/' + 'info.json' infoJsonPos = self.__plugin_dir + '/' + name + '/' + 'info.json'
if not os.path.exists(infoJsonPos): if not os.path.exists(infoJsonPos):
return public.retJson(False, "配置文件不存在!", ()) return mw.returnJson(False, "配置文件不存在!", ())
pluginInfo = json.loads(public.readFile(infoJsonPos)) pluginInfo = json.loads(mw.readFile(infoJsonPos))
execstr = "cd " + os.getcwd() + "/plugins/" + \ execstr = "cd " + os.getcwd() + "/plugins/" + \
name + " && /bin/bash " + pluginInfo["shell"] \ name + " && /bin/bash " + pluginInfo["shell"] \
@@ -139,47 +139,50 @@ class plugins_api:
taskAdd = (None, '卸载[' + name + '-' + version + ']', taskAdd = (None, '卸载[' + name + '-' + version + ']',
'execshell', '0', time.strftime('%Y-%m-%d %H:%M:%S'), execstr) 'execshell', '0', time.strftime('%Y-%m-%d %H:%M:%S'), execstr)
public.M('tasks').add('id,name,type,status,addtime, execstr', taskAdd) mw.M('tasks').add('id,name,type,status,addtime, execstr', taskAdd)
return public.returnJson(True, '已将卸载任务添加到队列!') return mw.returnJson(True, '已将卸载任务添加到队列!')
# 卸载时间短,不加入任务中... # 卸载时间短,不加入任务中...
def uninstallApi(self): def uninstallApi(self):
rundir = public.getRunDir() rundir = mw.getRunDir()
name = request.form.get('name', '') name = request.form.get('name', '')
version = request.form.get('version', '') version = request.form.get('version', '')
if name.strip() == '': if name.strip() == '':
return public.returnJson(False, "缺少插件名称!", ()) return mw.returnJson(False, "缺少插件名称!", ())
if version.strip() == '': if version.strip() == '':
return public.returnJson(False, "缺少版本信息!", ()) return mw.returnJson(False, "缺少版本信息!", ())
infoJsonPos = self.__plugin_dir + '/' + name + '/' + 'info.json' infoJsonPos = self.__plugin_dir + '/' + name + '/' + 'info.json'
if not os.path.exists(infoJsonPos): if not os.path.exists(infoJsonPos):
return public.retJson(False, "配置文件不存在!", ()) return mw.returnJson(False, "配置文件不存在!", ())
pluginInfo = json.loads(public.readFile(infoJsonPos)) pluginInfo = json.loads(mw.readFile(infoJsonPos))
execstr = "cd " + os.getcwd() + "/plugins/" + \ execstr = "cd " + os.getcwd() + "/plugins/" + \
name + " && /bin/bash " + pluginInfo["shell"] \ name + " && /bin/bash " + pluginInfo["shell"] \
+ " uninstall " + version + " uninstall " + version
data = public.execShell(execstr) data = mw.execShell(execstr)
return public.returnJson(True, '卸载执行成功!') if mw.isAppleSystem():
print execstr
print data[0], data[1]
return mw.returnJson(True, '卸载执行成功!')
# if data[1] == '': # if data[1] == '':
# return public.returnJson(True, '已将卸载成功!') # return mw.returnJson(True, '已将卸载成功!')
# else: # else:
# return public.returnJson(False, '卸载出现错误信息!' + data[1]) # return mw.returnJson(False, '卸载出现错误信息!' + data[1])
def checkApi(self): def checkApi(self):
name = request.form.get('name', '') name = request.form.get('name', '')
if name.strip() == '': if name.strip() == '':
return public.returnJson(False, "缺少插件名称!", ()) return mw.returnJson(False, "缺少插件名称!", ())
infoJsonPos = self.__plugin_dir + '/' + name + '/' + 'info.json' infoJsonPos = self.__plugin_dir + '/' + name + '/' + 'info.json'
if not os.path.exists(infoJsonPos): if not os.path.exists(infoJsonPos):
return public.returnJson(False, "配置文件不存在!", ()) return mw.returnJson(False, "配置文件不存在!", ())
return public.returnJson(True, "插件存在!", ()) return mw.returnJson(True, "插件存在!", ())
def setIndexApi(self): def setIndexApi(self):
name = request.form.get('name', '') name = request.form.get('name', '')
@@ -192,7 +195,7 @@ class plugins_api:
def settingApi(self): def settingApi(self):
name = request.args.get('name', '') name = request.args.get('name', '')
html = self.__plugin_dir + '/' + name + '/index.html' html = self.__plugin_dir + '/' + name + '/index.html'
return public.readFile(html) return mw.readFile(html)
def runApi(self): def runApi(self):
name = request.form.get('name', '') name = request.form.get('name', '')
@@ -203,8 +206,8 @@ class plugins_api:
data = self.run(name, func, version, args, script) data = self.run(name, func, version, args, script)
if data[1] == '': if data[1] == '':
return public.returnJson(True, "OK", data[0].strip()) return mw.returnJson(True, "OK", data[0].strip())
return public.returnJson(False, data[1].strip()) return mw.returnJson(False, data[1].strip())
def callbackApi(self): def callbackApi(self):
name = request.form.get('name', '') name = request.form.get('name', '')
@@ -214,23 +217,23 @@ class plugins_api:
data = self.callback(name, func, args, script) data = self.callback(name, func, args, script)
if data[0]: if data[0]:
return public.returnJson(True, "OK", data[1]) return mw.returnJson(True, "OK", data[1])
return public.returnJson(False, data[1]) return mw.returnJson(False, data[1])
def updateZipApi(self): def updateZipApi(self):
tmp_path = public.getRootDir() + '/temp' tmp_path = mw.getRootDir() + '/temp'
if not os.path.exists(tmp_path): if not os.path.exists(tmp_path):
os.makedirs(tmp_path) os.makedirs(tmp_path)
public.execShell("rm -rf " + tmp_path + '/*') mw.execShell("rm -rf " + tmp_path + '/*')
tmp_file = tmp_path + '/plugin_tmp.zip' tmp_file = tmp_path + '/plugin_tmp.zip'
from werkzeug.utils import secure_filename from werkzeug.utils import secure_filename
from flask import request from flask import request
f = request.files['plugin_zip'] f = request.files['plugin_zip']
if f.filename[-4:] != '.zip': if f.filename[-4:] != '.zip':
return public.returnJson(False, '仅支持zip文件!') return mw.returnJson(False, '仅支持zip文件!')
f.save(tmp_file) f.save(tmp_file)
public.execShell('cd ' + tmp_path + ' && unzip ' + tmp_file) mw.execShell('cd ' + tmp_path + ' && unzip ' + tmp_file)
os.remove(tmp_file) os.remove(tmp_file)
p_info = tmp_path + '/info.json' p_info = tmp_path + '/info.json'
@@ -250,47 +253,47 @@ class plugins_api:
tmp_path = d_path tmp_path = d_path
p_info = tmp_path + '/info.json' p_info = tmp_path + '/info.json'
try: try:
data = json.loads(public.readFile(p_info)) data = json.loads(mw.readFile(p_info))
data['size'] = public.getPathSize(tmp_path) data['size'] = mw.getPathSize(tmp_path)
if not 'author' in data: if not 'author' in data:
data['author'] = '未知' data['author'] = '未知'
if not 'home' in data: if not 'home' in data:
data['home'] = 'https://www.bt.cn/bbs/forum-40-1.html' data['home'] = 'https://www.bt.cn/bbs/forum-40-1.html'
plugin_path = public.getPluginDir() + data['name'] + '/info.json' plugin_path = mw.getPluginDir() + data['name'] + '/info.json'
data['old_version'] = '0' data['old_version'] = '0'
data['tmp_path'] = tmp_path data['tmp_path'] = tmp_path
if os.path.exists(plugin_path): if os.path.exists(plugin_path):
try: try:
old_info = json.loads(public.ReadFile(plugin_path)) old_info = json.loads(mw.ReadFile(plugin_path))
data['old_version'] = old_info['versions'] data['old_version'] = old_info['versions']
except: except:
pass pass
except: except:
public.execShell("rm -rf " + tmp_path) mw.execShell("rm -rf " + tmp_path)
return public.returnJson(False, '在压缩包中没有找到插件信息,请检查插件包!') return mw.returnJson(False, '在压缩包中没有找到插件信息,请检查插件包!')
protectPlist = ('openresty', 'mysql', 'php', 'csvn', 'gogs', 'pureftp') protectPlist = ('openresty', 'mysql', 'php', 'csvn', 'gogs', 'pureftp')
if data['name'] in protectPlist: if data['name'] in protectPlist:
return public.returnJson(False, '[' + data['name'] + '],重要插件不可修改!') return mw.returnJson(False, '[' + data['name'] + '],重要插件不可修改!')
return public.getJson(data) return mw.getJson(data)
def inputZipApi(self): def inputZipApi(self):
plugin_name = request.form.get('plugin_name', '') plugin_name = request.form.get('plugin_name', '')
tmp_path = request.form.get('tmp_path', '') tmp_path = request.form.get('tmp_path', '')
if not os.path.exists(tmp_path): if not os.path.exists(tmp_path):
return public.returnJson(False, '临时文件不存在,请重新上传!') return mw.returnJson(False, '临时文件不存在,请重新上传!')
plugin_path = public.getPluginDir() + '/' + plugin_name plugin_path = mw.getPluginDir() + '/' + plugin_name
if not os.path.exists(plugin_path): if not os.path.exists(plugin_path):
print public.execShell('mkdir -p ' + plugin_path) print mw.execShell('mkdir -p ' + plugin_path)
public.execShell("\cp -rf " + tmp_path + '/* ' + plugin_path + '/') mw.execShell("\cp -rf " + tmp_path + '/* ' + plugin_path + '/')
public.execShell('chmod -R 755 ' + plugin_path) mw.execShell('chmod -R 755 ' + plugin_path)
p_info = public.readFile(plugin_path + '/info.json') p_info = mw.readFile(plugin_path + '/info.json')
if p_info: if p_info:
public.writeLog('软件管理', '安装第三方插件[%s]' % mw.writeLog('软件管理', '安装第三方插件[%s]' %
json.loads(p_info)['title']) json.loads(p_info)['title'])
return public.returnJson(True, '安装成功!') return mw.returnJson(True, '安装成功!')
public.execShell("rm -rf " + plugin_path) mw.execShell("rm -rf " + plugin_path)
return public.returnJson(False, '安装失败!') return mw.returnJson(False, '安装失败!')
##### ----- end ----- ### ##### ----- end ----- ###
# 进程是否存在 # 进程是否存在
@@ -316,11 +319,11 @@ class plugins_api:
# 检查是否正在安装 # 检查是否正在安装
def checkSetupTask(self, sName, sVer, sCoexist): def checkSetupTask(self, sName, sVer, sCoexist):
if not self.__tasks: if not self.__tasks:
self.__tasks = public.M('tasks').where( self.__tasks = mw.M('tasks').where(
"status!=?", ('1',)).field('status,name').select() "status!=?", ('1',)).field('status,name').select()
isTask = '1' isTask = '1'
for task in self.__tasks: for task in self.__tasks:
tmpt = public.getStrBetween('[', ']', task['name']) tmpt = mw.getStrBetween('[', ']', task['name'])
if not tmpt: if not tmpt:
continue continue
tmp1 = tmpt.split('-') tmp1 = tmpt.split('-')
@@ -404,9 +407,9 @@ class plugins_api:
def checkDisplayIndex(self, name, version): def checkDisplayIndex(self, name, version):
if not os.path.exists(self.__index): if not os.path.exists(self.__index):
public.writeFile(self.__index, '[]') mw.writeFile(self.__index, '[]')
indexList = json.loads(public.readFile(self.__index)) indexList = json.loads(mw.readFile(self.__index))
if type(version) == list: if type(version) == list:
for index in range(len(version)): for index in range(len(version)):
vname = name + '-' + version[index] vname = name + '-' + version[index]
@@ -421,7 +424,7 @@ class plugins_api:
def getVersion(self, path): def getVersion(self, path):
version_f = path + '/version.pl' version_f = path + '/version.pl'
if os.path.exists(version_f): if os.path.exists(version_f):
return public.readFile(version_f).strip() return mw.readFile(version_f).strip()
return '' return ''
# 构造本地插件信息 # 构造本地插件信息
@@ -433,13 +436,13 @@ class plugins_api:
if info["checks"][0:1] == '/': if info["checks"][0:1] == '/':
checks = info["checks"] checks = info["checks"]
else: else:
checks = public.getRootDir() + '/' + info['checks'] checks = mw.getRootDir() + '/' + info['checks']
if info.has_key('path'): if info.has_key('path'):
path = info['path'] path = info['path']
if path[0:1] != '/': if path[0:1] != '/':
path = public.getRootDir() + '/' + path path = mw.getRootDir() + '/' + path
if info.has_key('coexist') and info['coexist']: if info.has_key('coexist') and info['coexist']:
coexist = True coexist = True
@@ -535,7 +538,7 @@ class plugins_api:
json_file = path + '/info.json' json_file = path + '/info.json'
if os.path.exists(json_file): if os.path.exists(json_file):
try: try:
data = json.loads(public.readFile(json_file)) data = json.loads(mw.readFile(json_file))
tmp_data = self.makeList(data, sType) tmp_data = self.makeList(data, sType)
for index in range(len(tmp_data)): for index in range(len(tmp_data)):
plugins_info.append(tmp_data[index]) plugins_info.append(tmp_data[index])
@@ -553,7 +556,7 @@ class plugins_api:
json_file = path + '/info.json' json_file = path + '/info.json'
if os.path.exists(json_file): if os.path.exists(json_file):
try: try:
data = json.loads(public.readFile(json_file)) data = json.loads(mw.readFile(json_file))
tmp_data = self.makeList(data, sType) tmp_data = self.makeList(data, sType)
for index in range(len(tmp_data)): for index in range(len(tmp_data)):
plugins_info.append(tmp_data[index]) plugins_info.append(tmp_data[index])
@@ -603,7 +606,7 @@ class plugins_api:
if os.path.isdir(path): if os.path.isdir(path):
json_file = path + '/info.json' json_file = path + '/info.json'
if os.path.exists(json_file): if os.path.exists(json_file):
data = json.loads(public.readFile(json_file)) data = json.loads(mw.readFile(json_file))
if sType == '0': if sType == '0':
tmp_list.append(data) tmp_list.append(data)
@@ -664,7 +667,7 @@ class plugins_api:
if os.path.isdir(path): if os.path.isdir(path):
json_file = path + '/info.json' json_file = path + '/info.json'
if os.path.exists(json_file): if os.path.exists(json_file):
data = json.loads(public.readFile(json_file)) data = json.loads(mw.readFile(json_file))
if sType == '0': if sType == '0':
tmp_list.append(data) tmp_list.append(data)
@@ -692,7 +695,7 @@ class plugins_api:
# print sType, sPage, sPageSize # print sType, sPage, sPageSize
ret = {} ret = {}
ret['type'] = json.loads(public.readFile(self.__type)) ret['type'] = json.loads(mw.readFile(self.__type))
# plugins_info = self.getAllListThread(sType) # plugins_info = self.getAllListThread(sType)
# plugins_info = self.getAllListProcess(sType) # plugins_info = self.getAllListProcess(sType)
data = self.getAllListPage(sType, sPage, sPageSize) data = self.getAllListPage(sType, sPage, sPageSize)
@@ -704,14 +707,14 @@ class plugins_api:
args['tojs'] = 'getSList' args['tojs'] = 'getSList'
args['row'] = sPageSize args['row'] = sPageSize
ret['list'] = public.getPage(args) ret['list'] = mw.getPage(args)
return ret return ret
def getIndexList(self): def getIndexList(self):
if not os.path.exists(self.__index): if not os.path.exists(self.__index):
public.writeFile(self.__index, '[]') mw.writeFile(self.__index, '[]')
indexList = json.loads(public.readFile(self.__index)) indexList = json.loads(mw.readFile(self.__index))
plist = [] plist = []
app = [] app = []
for i in indexList: for i in indexList:
@@ -723,7 +726,7 @@ class plugins_api:
json_file = path + '/info.json' json_file = path + '/info.json'
if os.path.exists(json_file): if os.path.exists(json_file):
try: try:
data = json.loads(public.readFile(json_file)) data = json.loads(mw.readFile(json_file))
tmp_data = self.makeList(data) tmp_data = self.makeList(data)
for index in range(len(tmp_data)): for index in range(len(tmp_data)):
if tmp_data[index]['versions'] == info[1] or info[1] in tmp_data[index]['versions']: if tmp_data[index]['versions'] == info[1] or info[1] in tmp_data[index]['versions']:
@@ -740,40 +743,40 @@ class plugins_api:
def setIndexSort(self, sort): def setIndexSort(self, sort):
data = sort.split('|') data = sort.split('|')
public.writeFile(self.__index, json.dumps(data)) mw.writeFile(self.__index, json.dumps(data))
return True return True
def addIndex(self, name, version): def addIndex(self, name, version):
if not os.path.exists(self.__index): if not os.path.exists(self.__index):
public.writeFile(self.__index, '[]') mw.writeFile(self.__index, '[]')
indexList = json.loads(public.readFile(self.__index)) indexList = json.loads(mw.readFile(self.__index))
vname = name + '-' + version vname = name + '-' + version
if vname in indexList: if vname in indexList:
return public.returnJson(False, '请不要重复添加!') return mw.returnJson(False, '请不要重复添加!')
if len(indexList) >= 12: if len(indexList) >= 12:
return public.returnJson(False, '首页最多只能显示12个软件!') return mw.returnJson(False, '首页最多只能显示12个软件!')
indexList.append(vname) indexList.append(vname)
public.writeFile(self.__index, json.dumps(indexList)) mw.writeFile(self.__index, json.dumps(indexList))
return public.returnJson(True, '添加成功!') return mw.returnJson(True, '添加成功!')
def removeIndex(self, name, version): def removeIndex(self, name, version):
if not os.path.exists(self.__index): if not os.path.exists(self.__index):
public.writeFile(self.__index, '[]') mw.writeFile(self.__index, '[]')
indexList = json.loads(public.readFile(self.__index)) indexList = json.loads(mw.readFile(self.__index))
vname = name + '-' + version vname = name + '-' + version
if not vname in indexList: if not vname in indexList:
return public.returnJson(True, '删除成功!') return mw.returnJson(True, '删除成功!')
indexList.remove(vname) indexList.remove(vname)
public.writeFile(self.__index, json.dumps(indexList)) mw.writeFile(self.__index, json.dumps(indexList))
return public.returnJson(True, '删除成功!') return mw.returnJson(True, '删除成功!')
# shell 调用 # shell 调用
def run(self, name, func, version, args='', script='index'): def run(self, name, func, version, args='', script='index'):
path = public.getRunDir() + '/' + self.__plugin_dir + \ path = mw.getRunDir() + '/' + self.__plugin_dir + \
'/' + name + '/' + script + '.py' '/' + name + '/' + script + '.py'
py = 'python ' + path py = 'python ' + path
@@ -784,24 +787,24 @@ class plugins_api:
if not os.path.exists(path): if not os.path.exists(path):
return ('', '') return ('', '')
data = public.execShell(py_cmd) data = mw.execShell(py_cmd)
# data = os.popen(py_cmd).read() # data = os.popen(py_cmd).read()
if public.isAppleSystem(): if mw.isAppleSystem():
print 'run', py_cmd print 'run', py_cmd
# print os.path.exists(py_cmd) # print os.path.exists(py_cmd)
return (data[0].strip(), data[1].strip()) return (data[0].strip(), data[1].strip())
# 映射包调用 # 映射包调用
def callback(self, name, func, args='', script='index'): def callback(self, name, func, args='', script='index'):
package = public.getRunDir() + '/plugins/' + name package = mw.getRunDir() + '/plugins/' + name
if not os.path.exists(package): if not os.path.exists(package):
return (False, "插件不存在!") return (False, "插件不存在!")
sys.path.append(package) sys.path.append(package)
eval_str = "__import__('" + script + "')." + func + '(' + args + ')' eval_str = "__import__('" + script + "')." + func + '(' + args + ')'
newRet = eval(eval_str) newRet = eval(eval_str)
if public.isAppleSystem(): if mw.isAppleSystem():
print 'callback', eval_str print 'callback', eval_str
return (True, newRet) return (True, newRet)
+490 -442
View File
File diff suppressed because it is too large Load Diff
+94 -90
View File
@@ -11,7 +11,8 @@ from flask import Flask, session
from flask import request from flask import request
import db import db
import public import mw
import requests
import config_api import config_api
@@ -31,12 +32,12 @@ class system_api:
pids = None pids = None
def __init__(self): def __init__(self):
self.setupPath = public.getServerDir() self.setupPath = mw.getServerDir()
##### ----- start ----- ### ##### ----- start ----- ###
def networkApi(self): def networkApi(self):
data = self.getNetWork() data = self.getNetWork()
return public.getJson(data) return mw.getJson(data)
def updateServerApi(self): def updateServerApi(self):
stype = request.args.get('type', 'check') stype = request.args.get('type', 'check')
@@ -45,11 +46,11 @@ class system_api:
def systemTotalApi(self): def systemTotalApi(self):
data = self.getSystemTotal() data = self.getSystemTotal()
return public.getJson(data) return mw.getJson(data)
def diskInfoApi(self): def diskInfoApi(self):
diskInfo = self.getDiskInfo() diskInfo = self.getDiskInfo()
return public.getJson(diskInfo) return mw.getJson(diskInfo)
def setControlApi(self): def setControlApi(self):
stype = request.form.get('type', '') stype = request.form.get('type', '')
@@ -61,57 +62,58 @@ class system_api:
start = request.args.get('start', '') start = request.args.get('start', '')
end = request.args.get('end', '') end = request.args.get('end', '')
data = self.getLoadAverageData(start, end) data = self.getLoadAverageData(start, end)
return public.getJson(data) return mw.getJson(data)
def getCpuIoApi(self): def getCpuIoApi(self):
start = request.args.get('start', '') start = request.args.get('start', '')
end = request.args.get('end', '') end = request.args.get('end', '')
data = self.getCpuIoData(start, end) data = self.getCpuIoData(start, end)
return public.getJson(data) return mw.getJson(data)
def getDiskIoApi(self): def getDiskIoApi(self):
start = request.args.get('start', '') start = request.args.get('start', '')
end = request.args.get('end', '') end = request.args.get('end', '')
data = self.getDiskIoData(start, end) data = self.getDiskIoData(start, end)
return public.getJson(data) return mw.getJson(data)
def getNetworkIoApi(self): def getNetworkIoApi(self):
start = request.args.get('start', '') start = request.args.get('start', '')
end = request.args.get('end', '') end = request.args.get('end', '')
data = self.getNetWorkIoData(start, end) data = self.getNetWorkIoData(start, end)
return public.getJson(data) return mw.getJson(data)
def rememoryApi(self): def rememoryApi(self):
os.system('sync') os.system('sync')
scriptFile = public.getRunDir() + '/script/rememory.sh' scriptFile = mw.getRunDir() + '/script/rememory.sh'
public.execShell("/bin/bash " + scriptFile) mw.execShell("/bin/bash " + scriptFile)
data = self.getMemInfo() data = self.getMemInfo()
return public.getJson(data) return mw.getJson(data)
# 重启面板 # 重启面板
def restartApi(self): def restartApi(self):
self.restartMw() self.restartMw()
return public.returnJson(True, '面板已重启!') return mw.returnJson(True, '面板已重启!')
def restartServerApi(self): def restartServerApi(self):
if public.isAppleSystem(): if mw.isAppleSystem():
return public.returnJson(False, "开发环境不可重起") return mw.returnJson(False, "开发环境不可重起")
self.restartServer() self.restartServer()
return public.returnJson(True, '正在重启服务器!') return mw.returnJson(True, '正在重启服务器!')
##### ----- end ----- ### ##### ----- end ----- ###
@async @async
def restartMw(self): def restartMw(self):
sleep(1) sleep(0.3)
cmd = public.getRunDir() + '/scripts/init.d/mw reload' # cmd = mw.getRunDir() + '/scripts/init.d/mw restart'
public.execShell(cmd) # print cmd
mw.execShell('service mw restart')
@async @async
def restartServer(self): def restartServer(self):
if not public.isRestart(): if not mw.isRestart():
return public.returnJson(False, '请等待所有安装任务完成再执行!') return mw.returnJson(False, '请等待所有安装任务完成再执行!')
public.execShell("sync && init 6 &") mw.execShell("sync && init 6 &")
return public.returnJson(True, '命令发送成功!') return mw.returnJson(True, '命令发送成功!')
# 名取PID # 名取PID
def getPid(self, pname): def getPid(self, pname):
@@ -149,30 +151,30 @@ class system_api:
def getPanelInfo(self, get=None): def getPanelInfo(self, get=None):
# 取面板配置 # 取面板配置
address = public.GetLocalIp() address = mw.GetLocalIp()
try: try:
try: try:
port = web.ctx.host.split(':')[1] port = web.ctx.host.split(':')[1]
except: except:
port = public.readFile('data/port.pl') port = mw.readFile('data/port.pl')
except: except:
port = '8888' port = '8888'
domain = '' domain = ''
if os.path.exists('data/domain.conf'): if os.path.exists('data/domain.conf'):
domain = public.readFile('data/domain.conf') domain = mw.readFile('data/domain.conf')
autoUpdate = '' autoUpdate = ''
if os.path.exists('data/autoUpdate.pl'): if os.path.exists('data/autoUpdate.pl'):
autoUpdate = 'checked' autoUpdate = 'checked'
limitip = '' limitip = ''
if os.path.exists('data/limitip.conf'): if os.path.exists('data/limitip.conf'):
limitip = public.readFile('data/limitip.conf') limitip = mw.readFile('data/limitip.conf')
templates = [] templates = []
for template in os.listdir('templates/'): for template in os.listdir('templates/'):
if os.path.isdir('templates/' + template): if os.path.isdir('templates/' + template):
templates.append(template) templates.append(template)
template = public.readFile('data/templates.pl') template = mw.readFile('data/templates.pl')
check502 = '' check502 = ''
if os.path.exists('data/502Task.pl'): if os.path.exists('data/502Task.pl'):
@@ -187,7 +189,7 @@ class system_api:
data['cpuRealUsed'] = cpu[0] data['cpuRealUsed'] = cpu[0]
data['time'] = self.getBootTime() data['time'] = self.getBootTime()
data['system'] = self.getSystemVersion() data['system'] = self.getSystemVersion()
data['isuser'] = public.M('users').where( data['isuser'] = mw.M('users').where(
'username=?', ('admin',)).count() 'username=?', ('admin',)).count()
data['version'] = '0.0.1' data['version'] = '0.0.1'
return data return data
@@ -224,22 +226,22 @@ class system_api:
titlePl = 'data/title.pl' titlePl = 'data/title.pl'
title = 'Linux面板' title = 'Linux面板'
if os.path.exists(titlePl): if os.path.exists(titlePl):
title = public.readFile(titlePl).strip() title = mw.readFile(titlePl).strip()
return title return title
def getSystemVersion(self): def getSystemVersion(self):
# 取操作系统版本 # 取操作系统版本
if public.getOs() == 'darwin': if mw.getOs() == 'darwin':
data = public.execShell('sw_vers')[0] data = mw.execShell('sw_vers')[0]
data_list = data.strip().split("\n") data_list = data.strip().split("\n")
mac_version = '' mac_version = ''
for x in data_list: for x in data_list:
mac_version += x.split("\t")[1] + ' ' mac_version += x.split("\t")[1] + ' '
return mac_version return mac_version
version = public.readFile('/etc/redhat-release') version = mw.readFile('/etc/redhat-release')
if not version: if not version:
version = public.readFile( version = mw.readFile(
'/etc/issue').strip().split("\n")[0].replace('\\n', '').replace('\l', '').strip() '/etc/issue').strip().split("\n")[0].replace('\\n', '').replace('\l', '').strip()
else: else:
version = version.replace('release ', '').strip() version = version.replace('release ', '').strip()
@@ -249,14 +251,14 @@ class system_api:
# 取系统启动时间 # 取系统启动时间
start_time = psutil.boot_time() start_time = psutil.boot_time()
run_time = time.time() - start_time run_time = time.time() - start_time
# conf = public.readFile('/proc/uptime').split() # conf = mw.readFile('/proc/uptime').split()
tStr = float(run_time) tStr = float(run_time)
min = tStr / 60 min = tStr / 60
hours = min / 60 hours = min / 60
days = math.floor(hours / 24) days = math.floor(hours / 24)
hours = math.floor(hours - (days * 24)) hours = math.floor(hours - (days * 24))
min = math.floor(min - (days * 60 * 24) - (hours * 60)) min = math.floor(min - (days * 60 * 24) - (hours * 60))
return public.getInfo('已不间断运行: {1}天{2}小时{3}分钟', (str(int(days)), str(int(hours)), str(int(min)))) return mw.getInfo('已不间断运行: {1}天{2}小时{3}分钟', (str(int(days)), str(int(hours)), str(int(min))))
def getCpuInfo(self, interval=1): def getCpuInfo(self, interval=1):
# 取CPU信息 # 取CPU信息
@@ -267,7 +269,7 @@ class system_api:
def getMemInfo(self): def getMemInfo(self):
# 取内存信息 # 取内存信息
mem = psutil.virtual_memory() mem = psutil.virtual_memory()
if public.getOs() == 'darwin': if mw.getOs() == 'darwin':
memInfo = { memInfo = {
'memTotal': mem.total / 1024 / 1024 'memTotal': mem.total / 1024 / 1024
} }
@@ -291,7 +293,7 @@ class system_api:
import psutil import psutil
mem = psutil.virtual_memory() mem = psutil.virtual_memory()
if public.getOs() == 'darwin': if mw.getOs() == 'darwin':
return mem.percent return mem.percent
memInfo = {'memTotal': mem.total / 1024 / 1024, 'memFree': mem.free / 1024 / 1024, memInfo = {'memTotal': mem.total / 1024 / 1024, 'memFree': mem.free / 1024 / 1024,
@@ -322,9 +324,9 @@ class system_api:
def getDiskInfo2(self): def getDiskInfo2(self):
# 取磁盘分区信息 # 取磁盘分区信息
temp = public.execShell( temp = mw.execShell(
"df -h -P|grep '/'|grep -v tmpfs | grep -v devfs")[0] "df -h -P|grep '/'|grep -v tmpfs | grep -v devfs")[0]
tempInodes = public.execShell( tempInodes = mw.execShell(
"df -i -P|grep '/'|grep -v tmpfs | grep -v devfs")[0] "df -i -P|grep '/'|grep -v tmpfs | grep -v devfs")[0]
temp1 = temp.split('\n') temp1 = temp.split('\n')
tempInodes1 = tempInodes.split('\n') tempInodes1 = tempInodes.split('\n')
@@ -422,7 +424,7 @@ class system_api:
else: else:
os.remove(filename) os.remove(filename)
count += 1 count += 1
public.serviceReload() mw.serviceReload()
os.system('echo > /tmp/panelBoot.pl') os.system('echo > /tmp/panelBoot.pl')
return total, count return total, count
@@ -469,10 +471,10 @@ class system_api:
networkIo = psutil.net_io_counters()[:4] networkIo = psutil.net_io_counters()[:4]
if not os.path.exists(tmpfile): if not os.path.exists(tmpfile):
public.writeFile(tmpfile, str( mw.writeFile(tmpfile, str(
networkIo[0]) + '|' + str(networkIo[1]) + '|' + str(int(time.time()))) networkIo[0]) + '|' + str(networkIo[1]) + '|' + str(int(time.time())))
lastValue = public.readFile(tmpfile).split('|') lastValue = mw.readFile(tmpfile).split('|')
ntime = time.time() ntime = time.time()
networkInfo = {} networkInfo = {}
@@ -485,7 +487,7 @@ class system_api:
networkInfo['downPackets'] = networkIo[3] networkInfo['downPackets'] = networkIo[3]
networkInfo['upPackets'] = networkIo[2] networkInfo['upPackets'] = networkIo[2]
public.writeFile(tmpfile, str( mw.writeFile(tmpfile, str(
networkIo[0]) + '|' + str(networkIo[1]) + '|' + str(int(time.time()))) networkIo[0]) + '|' + str(networkIo[1]) + '|' + str(int(time.time())))
# networkInfo['cpu'] = self.GetCpuInfo(0.1) # networkInfo['cpu'] = self.GetCpuInfo(0.1)
@@ -495,24 +497,24 @@ class system_api:
def getNetWorkIoData(self, start, end): def getNetWorkIoData(self, start, end):
# 取指定时间段的网络Io # 取指定时间段的网络Io
data = public.M('network').dbfile('system').where("addtime>=? AND addtime<=?", (start, end)).field( data = mw.M('network').dbfile('system').where("addtime>=? AND addtime<=?", (start, end)).field(
'id,up,down,total_up,total_down,down_packets,up_packets,addtime').order('id asc').select() 'id,up,down,total_up,total_down,down_packets,up_packets,addtime').order('id asc').select()
return self.toAddtime(data) return self.toAddtime(data)
def getDiskIoData(self, start, end): def getDiskIoData(self, start, end):
# 取指定时间段的磁盘Io # 取指定时间段的磁盘Io
data = public.M('diskio').dbfile('system').where("addtime>=? AND addtime<=?", (start, end)).field( data = mw.M('diskio').dbfile('system').where("addtime>=? AND addtime<=?", (start, end)).field(
'id,read_count,write_count,read_bytes,write_bytes,read_time,write_time,addtime').order('id asc').select() 'id,read_count,write_count,read_bytes,write_bytes,read_time,write_time,addtime').order('id asc').select()
return self.toAddtime(data) return self.toAddtime(data)
def getCpuIoData(self, start, end): def getCpuIoData(self, start, end):
# 取指定时间段的CpuIo # 取指定时间段的CpuIo
data = public.M('cpuio').dbfile('system').where("addtime>=? AND addtime<=?", data = mw.M('cpuio').dbfile('system').where("addtime>=? AND addtime<=?",
(start, end)).field('id,pro,mem,addtime').order('id asc').select() (start, end)).field('id,pro,mem,addtime').order('id asc').select()
return self.toAddtime(data, True) return self.toAddtime(data, True)
def getLoadAverageData(self, start, end): def getLoadAverageData(self, start, end):
data = public.M('load_average').dbfile('system').where("addtime>=? AND addtime<=?", ( data = mw.M('load_average').dbfile('system').where("addtime>=? AND addtime<=?", (
start, end)).field('id,pro,one,five,fifteen,addtime').order('id asc').select() start, end)).field('id,pro,one,five,fifteen,addtime').order('id asc').select()
return self.toAddtime(data) return self.toAddtime(data)
@@ -558,37 +560,37 @@ class system_api:
filename = 'data/control.conf' filename = 'data/control.conf'
if stype == '0': if stype == '0':
public.execShell("rm -f " + filename) mw.execShell("rm -f " + filename)
elif stype == '1': elif stype == '1':
_day = int(day) _day = int(day)
if _day < 1: if _day < 1:
return public.returnJson(False, "设置失败!") return mw.returnJson(False, "设置失败!")
public.writeFile(filename, day) mw.writeFile(filename, day)
elif stype == 'del': elif stype == 'del':
if not public.isRestart(): if not mw.isRestart():
return public.returnJson(False, '请等待所有安装任务完成再执行') return mw.returnJson(False, '请等待所有安装任务完成再执行')
os.remove("data/system.db") os.remove("data/system.db")
sql = db.Sql().dbfile('system') sql = db.Sql().dbfile('system')
csql = public.readFile('data/sql/system.sql') csql = mw.readFile('data/sql/system.sql')
csql_list = csql.split(';') csql_list = csql.split(';')
for index in range(len(csql_list)): for index in range(len(csql_list)):
sql.execute(csql_list[index], ()) sql.execute(csql_list[index], ())
return public.returnJson(True, "监控服务已关闭") return mw.returnJson(True, "监控服务已关闭")
else: else:
data = {} data = {}
if os.path.exists(filename): if os.path.exists(filename):
try: try:
data['day'] = int(public.readFile(filename)) data['day'] = int(mw.readFile(filename))
except: except:
data['day'] = 30 data['day'] = 30
data['status'] = True data['status'] = True
else: else:
data['day'] = 30 data['day'] = 30
data['status'] = False data['status'] = False
return public.getJson(data) return mw.getJson(data)
return public.returnJson(True, "设置成功!") return mw.returnJson(True, "设置成功!")
def versionDiff(self, old, new): def versionDiff(self, old, new):
''' '''
@@ -602,18 +604,21 @@ class system_api:
old_list = old.split('.') old_list = old.split('.')
ret = 'none' ret = 'none'
for i in range(len(old_list)):
tm_new = int(new_list[i]) isHasNew = True
tm_old = int(old_list[i]) if int(new_list[0]) == int(old_list[0]) and int(new_list[1]) == int(old_list[1]) and int(new_list[2]) == int(old_list[2]):
if tm_new > tm_old: isHasNew = False
return 'new'
if isHasNew:
return 'new'
return ret return ret
def getServerInfo(self): def getServerInfo(self):
upAddr = 'https://raw.githubusercontent.com/midoks/mdserver-web/master/version/info.json' upAddr = 'https://raw.githubusercontent.com/midoks/mdserver-web/master/version/info.json'
try: try:
version = public.httpGet(upAddr) requests.adapters.DEFAULT_RETRIES = 2
version = json.loads(version) r = requests.get(upAddr, verify=False)
version = json.loads(r.content)
return version[0] return version[0]
except Exception as e: except Exception as e:
print 'getServerInfo', e print 'getServerInfo', e
@@ -622,70 +627,69 @@ class system_api:
def updateServer(self, stype, version=''): def updateServer(self, stype, version=''):
# 更新服务 # 更新服务
try: try:
if not public.isRestart(): if not mw.isRestart():
return public.returnJson(False, '请等待所有安装任务完成再执行!') return mw.returnJson(False, '请等待所有安装任务完成再执行!')
if stype == 'check': if stype == 'check':
version_now = config_api.config_api().getVersion() version_now = config_api.config_api().getVersion()
version_new_info = self.getServerInfo() version_new_info = self.getServerInfo()
if not 'version' in version_new_info: if not 'version' in version_new_info:
return public.returnJson(False, '服务器数据有问题!') return mw.returnJson(False, '服务器数据或网络有问题!')
diff = self.versionDiff( diff = self.versionDiff(
version_now, version_new_info['version']) version_now, version_new_info['version'])
if diff == 'new': if diff == 'new':
return public.returnJson(True, '有新版本!', version_new_info['version']) return mw.returnJson(True, '有新版本!', version_new_info['version'])
elif diff == 'test': elif diff == 'test':
return public.returnJson(True, '有测试版本!', version_new_info['version']) return mw.returnJson(True, '有测试版本!', version_new_info['version'])
else: else:
return public.returnJson(False, '已经是最新,无需更新!') return mw.returnJson(False, '已经是最新,无需更新!')
if stype == 'info': if stype == 'info':
version_new_info = self.getServerInfo() version_new_info = self.getServerInfo()
version_now = config_api.config_api().getVersion() version_now = config_api.config_api().getVersion()
if not 'version' in version_new_info: if not 'version' in version_new_info:
return public.returnJson(False, '服务器数据有问题!') return mw.returnJson(False, '服务器数据有问题!')
diff = self.versionDiff( diff = self.versionDiff(
version_now, version_new_info['version']) version_now, version_new_info['version'])
return public.returnJson(True, '更新信息!', version_new_info) return mw.returnJson(True, '更新信息!', version_new_info)
if stype == 'update': if stype == 'update':
if version == '': if version == '':
return public.returnJson(False, '缺少版本信息!') return mw.returnJson(False, '缺少版本信息!')
v_new_info = self.getServerInfo() v_new_info = self.getServerInfo()
if v_new_info['version'] != version: if v_new_info['version'] != version:
return public.returnJson(False, '更新失败,请重试!') return mw.returnJson(False, '更新失败,请重试!')
if not 'path' in v_new_info or v_new_info['path'] == '': if not 'path' in v_new_info or v_new_info['path'] == '':
return public.returnJson(False, '下载地址不存在!') return mw.returnJson(False, '下载地址不存在!')
newUrl = v_new_info['path'] newUrl = v_new_info['path']
toPath = public.getRootDir() + '/temp' toPath = mw.getRootDir() + '/temp'
if not os.path.exists(toPath): if not os.path.exists(toPath):
public.execShell('mkdir -p ' + toPath) mw.execShell('mkdir -p ' + toPath)
if not os.path.exists(toPath + '/mw.zip'): mw.execShell('wget -O ' + toPath + '/mw.zip ' + newUrl)
public.execShell('wget -O ' + toPath + '/mw.zip ' + newUrl)
public.execShell('unzip -o ' + toPath + '/mw.zip' + ' -d ./') mw.execShell('unzip -o ' + toPath + '/mw.zip' + ' -d ./')
public.execShell('unzip -o mdserver-web.zip -d ./') mw.execShell('unzip -o mw.zip -d ./')
public.execShell('rm -f mdserver-web.zip') mw.execShell('rm -f mw.zip')
return public.returnJson(True, '安装更新成功!') return mw.returnJson(True, '安装更新成功,需自己重启!')
return public.returnJson(False, '已经是最新,无需更新!') return mw.returnJson(False, '已经是最新,无需更新!')
except Exception as ex: except Exception as ex:
print 'updateServer', ex print 'updateServer', ex
return public.returnJson(False, "连接服务器失败!") return mw.returnJson(False, "连接服务器失败!")
# 修复面板 # 修复面板
def repPanel(self, get): def repPanel(self, get):
vp = '' vp = ''
if public.readFile('/www/server/mdserver-web/class/common.py').find('checkSafe') != -1: if mw.readFile('/www/server/mdserver-web/class/common.py').find('checkSafe') != -1:
vp = '_pro' vp = '_pro'
public.ExecShell("wget -O update.sh " + public.get_url() + mw.ExecShell("wget -O update.sh " + mw.get_url() +
"/install/update" + vp + ".sh && bash update.sh") "/install/update" + vp + ".sh && bash update.sh")
if hasattr(web.ctx.session, 'getCloudPlugin'): if hasattr(web.ctx.session, 'getCloudPlugin'):
del(web.ctx.session['getCloudPlugin']) del(web.ctx.session['getCloudPlugin'])
return True return True
+18 -18
View File
@@ -4,7 +4,7 @@ import psutil
import time import time
import os import os
import sys import sys
import public import mw
import re import re
import json import json
import pwd import pwd
@@ -19,7 +19,7 @@ class task_api:
pass pass
def countApi(self): def countApi(self):
c = public.M('tasks').where("status!=?", ('1',)).count() c = mw.M('tasks').where("status!=?", ('1',)).count()
return str(c) return str(c)
def listApi(self): def listApi(self):
@@ -31,36 +31,36 @@ class task_api:
start = (int(p) - 1) * int(limit) start = (int(p) - 1) * int(limit)
limit_str = str(start) + ',' + str(limit) limit_str = str(start) + ',' + str(limit)
_list = public.M('tasks').where('', ()).field( _list = mw.M('tasks').where('', ()).field(
'id,name,type,status,addtime,start,end').limit(limit_str).order('id desc').select() 'id,name,type,status,addtime,start,end').limit(limit_str).order('id desc').select()
_ret = {} _ret = {}
_ret['data'] = _list _ret['data'] = _list
count = public.M('tasks').where('', ()).count() count = mw.M('tasks').where('', ()).count()
_page = {} _page = {}
_page['count'] = count _page['count'] = count
_page['tojs'] = 'remind' _page['tojs'] = 'remind'
_page['p'] = p _page['p'] = p
_ret['page'] = public.getPage(_page) _ret['page'] = mw.getPage(_page)
return public.getJson(_ret) return mw.getJson(_ret)
def getExecLogApi(self): def getExecLogApi(self):
file = os.getcwd() + "/tmp/panelExec.log" file = os.getcwd() + "/tmp/panelExec.log"
v = public.getLastLine(file, 100) v = mw.getLastLine(file, 100)
return v return v
def getTaskSpeedApi(self): def getTaskSpeedApi(self):
tempFile = os.getcwd() + '/tmp/panelExec.log' tempFile = os.getcwd() + '/tmp/panelExec.log'
freshFile = os.getcwd() + '/tmp/panelFresh' freshFile = os.getcwd() + '/tmp/panelFresh'
find = public.M('tasks').where('status=? OR status=?', find = mw.M('tasks').where('status=? OR status=?',
('-1', '0')).field('id,type,name,execstr').find() ('-1', '0')).field('id,type,name,execstr').find()
if not len(find): if not len(find):
return public.returnJson(False, '当前没有任务队列在执行-2!') return mw.returnJson(False, '当前没有任务队列在执行-2!')
isTask = os.getcwd() + '/tmp/panelTask.pl' isTask = os.getcwd() + '/tmp/panelTask.pl'
public.writeFile(isTask, 'True') mw.writeFile(isTask, 'True')
echoMsg = {} echoMsg = {}
echoMsg['name'] = find['name'] echoMsg['name'] = find['name']
@@ -68,19 +68,19 @@ class task_api:
if find['type'] == 'download': if find['type'] == 'download':
import json import json
try: try:
tmp = public.readFile(tempFile) tmp = mw.readFile(tempFile)
if len(tmp) < 10: if len(tmp) < 10:
return public.returnJson(False, '当前没有任务队列在执行-3!') return mw.returnJson(False, '当前没有任务队列在执行-3!')
echoMsg['msg'] = json.loads(tmp) echoMsg['msg'] = json.loads(tmp)
echoMsg['isDownload'] = True echoMsg['isDownload'] = True
except: except:
public.M('tasks').where( mw.M('tasks').where(
"id=?", (find['id'],)).save('status', ('0',)) "id=?", (find['id'],)).save('status', ('0',))
return public.returnJson(False, '当前没有任务队列在执行-4!') return mw.returnJson(False, '当前没有任务队列在执行-4!')
else: else:
echoMsg['msg'] = public.getLastLine(tempFile, 10) echoMsg['msg'] = mw.getLastLine(tempFile, 10)
echoMsg['isDownload'] = False echoMsg['isDownload'] = False
echoMsg['task'] = public.M('tasks').where("status!=?", ('1',)).field( echoMsg['task'] = mw.M('tasks').where("status!=?", ('1',)).field(
'id,status,name,type').order("id asc").select() 'id,status,name,type').order("id asc").select()
return public.getJson(echoMsg) return mw.getJson(echoMsg)
Executable
+7
View File
@@ -0,0 +1,7 @@
#!/bin/bash
PATH=/bin:/sbin:/usr/bin:/usr/sbin:/usr/local/bin:/usr/local/sbin:~/bin:/usr/local/lib/python2.7/bin
find . -name .DS_Store | xargs rm -rf
find . -type d -name "*.pyc" | xargs rm -rf
-1
View File
@@ -1 +0,0 @@
qpzw99oc
+1
View File
@@ -0,0 +1 @@
t.vvv
+3 -2
View File
@@ -47,8 +47,9 @@ CREATE TABLE IF NOT EXISTS `firewall` (
INSERT INTO `firewall` (`id`, `port`, `ps`, `addtime`) VALUES INSERT INTO `firewall` (`id`, `port`, `ps`, `addtime`) VALUES
(1, '80', '网站默认端口', '0000-00-00 00:00:00'), (1, '80', '网站默认端口', '0000-00-00 00:00:00'),
(2, '7200', 'WEB面板', '0000-00-00 00:00:00'), (2, '7200', 'WEB面板', '0000-00-00 00:00:00'),
(3, '22', 'SSH远程管理服务', '0000-00-00 00:00:00') (3, '22', 'SSH远程管理服务', '0000-00-00 00:00:00'),
(3, '888', 'phpMyAdmin默认端口', '0000-00-00 00:00:00'); (4, '888', 'phpMyAdmin默认端口', '0000-00-00 00:00:00'),
(5, '3306', 'MySQL端口', '0000-00-00 00:00:00');
+1 -1
View File
@@ -47,6 +47,6 @@ server
access_log /dev/null; access_log /dev/null;
} }
access_log {$LOGPATH}/{$SERVER_NAME}.log; access_log {$LOGPATH}/{$SERVER_NAME}.log main;
error_log {$LOGPATH}/{$SERVER_NAME}.error.log; error_log {$LOGPATH}/{$SERVER_NAME}.error.log;
} }
+102
View File
@@ -0,0 +1,102 @@
## 文件保存相关 ##
# 文件的保存路径(可使用绝对路径或相对路径), 默认: 当前启动位置
dir=/tmp/aria2
# 设置日志等级
log-level=error
# 日志保存路径
log={$SERVER_PATH}/aria2.log
# 启用磁盘缓存, 0为禁用缓存, 需1.16以上版本, 默认:16M
disk-cache=32M
# 文件预分配方式, 能有效降低磁盘碎片, 默认:prealloc
# 预分配所需时间: none < falloc ? trunc < prealloc
# falloc和trunc则需要文件系统和内核支持
# NTFS建议使用falloc, EXT3/4建议trunc, MAC 下需要注释此项
#file-allocation=none
# 断点续传
continue=true
## 下载连接相关 ##
# 最大同时下载任务数, 运行时可修改, 默认:5
max-concurrent-downloads=5
# 同一服务器连接数, 添加时可指定, 默认:1
max-connection-per-server=10
# 最小文件分片大小, 添加时可指定, 取值范围1M -1024M, 默认:20M
# 假定size=10M, 文件为20MiB 则使用两个来源下载; 文件为15MiB 则使用一个来源下载
min-split-size=10M
# 单个任务最大线程数, 添加时可指定, 默认:5
split=128
# 整体下载速度限制, 运行时可修改, 默认:0
#max-overall-download-limit=0
# 单个任务下载速度限制, 默认:0
#max-download-limit=0
# 整体上传速度限制, 运行时可修改, 默认:0
#max-overall-upload-limit=0
# 单个任务上传速度限制, 默认:0
#max-upload-limit=0
# 禁用IPv6, 默认:false
disable-ipv6=true
## 进度保存相关 ##
# 从会话文件中读取下载任务
input-file={$SERVER_PATH}/aria2.session
# 在Aria2退出时保存`错误/未完成`的下载任务到会话文件
save-session={$SERVER_PATH}/aria2.session
# 定时保存会话, 0为退出时才保存, 需1.16.1以上版本, 默认:0
#save-session-interval=60
## RPC相关设置 ##
# 启用RPC, 默认:false
enable-rpc=true
# 允许所有来源, 默认:false
rpc-allow-origin-all=true
# 允许非外部访问, 默认:false
rpc-listen-all=true
# 事件轮询方式, 取值:[epoll, kqueue, port, poll, select], 不同系统默认值不同
#event-poll=select
# RPC监听端口, 端口被占用时可以修改, 默认:6800
rpc-listen-port=6800
# 设置的RPC授权令牌, v1.18.4新增功能, 取代 --rpc-user 和 --rpc-passwd 选项
#rpc-secret=sark
# 设置的RPC访问用户名, 此选项新版已废弃, 建议改用 --rpc-secret 选项
#rpc-user=<USER>
# 设置的RPC访问密码, 此选项新版已废弃, 建议改用 --rpc-secret 选项
#rpc-passwd=<PASSWD>
## BT/PT下载相关 ##
# 当下载的是一个种子(以.torrent结尾)时, 自动开始BT任务, 默认:true
#follow-torrent=true
# BT监听端口, 当端口被屏蔽时使用, 默认:6881-6999
listen-port=51413
# 单个种子最大连接数, 默认:55
#bt-max-peers=55
# 打开DHT功能, PT需要禁用, 默认:true
enable-dht=false
# 打开IPv6 DHT功能, PT需要禁用
#enable-dht6=false
# DHT网络监听端口, 默认:6881-6999
#dht-listen-port=6881-6999
# 本地节点查找, PT需要禁用, 默认:false
#bt-enable-lpd=false
# 种子交换, PT需要禁用, 默认:true
enable-peer-exchange=false
# 每个种子限速, 对少种的PT很有用, 默认:50K
#bt-request-peer-speed-limit=50K
# 客户端伪装, PT需要
peer-id-prefix=-TR2770-
user-agent=Transmission/2.77
# 当种子的分享率达到这个数时, 自动停止做种, 0为一直做种, 默认:1.0
seed-ratio=0
# 强制保存会话, 即使任务已经完成, 默认:false
# 较新的版本开启后会在任务完成后依然保留.aria2文件
#force-save=false
# BT校验相关, 默认:true
#bt-hash-check-seed=true
# 继续之前的BT任务时, 无需再次校验, 默认:false
bt-seed-unverified=true
# 保存磁力链接元数据为种子文件(.torrent文件), 默认:false
bt-save-metadata=true
Binary file not shown.

After

Width:  |  Height:  |  Size: 1.7 KiB

+19
View File
@@ -0,0 +1,19 @@
<div class="bt-form">
<div class="bt-w-main">
<div class="bt-w-menu">
<p class="bgw" onclick="pluginService('aria2');">服务</p>
<p onclick="pluginInitD('aria2');">自启动</p>
<p onclick="pluginConfig('aria2');">配置修改</p>
<p onclick="pluginLogs('aria2','','run_log');">运行日志</p>
<p onclick="readme();">说明</p>
</div>
<div class="bt-w-con pd15">
<div class="soft-man-con"></div>
</div>
</div>
</div>
<script type="text/javascript">
$.getScript( "/plugins/file?name=aria2&f=js/aria2.js", function(){
pluginService('aria2');
});
</script>
+211
View File
@@ -0,0 +1,211 @@
# coding:utf-8
import sys
import io
import os
import time
import shutil
sys.path.append(os.getcwd() + "/class/core")
import mw
app_debug = False
if mw.isAppleSystem():
app_debug = True
def getPluginName():
return 'aria2'
def getPluginDir():
return mw.getPluginDir() + '/' + getPluginName()
def getServerDir():
return mw.getServerDir() + '/' + getPluginName()
def getInitDTpl():
path = getPluginDir() + "/init.d/aria2.tpl"
return path
def getArgs():
args = sys.argv[2:]
tmp = {}
args_len = len(args)
if args_len == 1:
t = args[0].strip('{').strip('}')
t = t.split(':')
tmp[t[0]] = t[1]
elif args_len > 1:
for i in range(len(args)):
t = args[i].split(':')
tmp[t[0]] = t[1]
return tmp
def initDreplace():
file_tpl = getInitDTpl()
service_path = os.path.dirname(os.getcwd())
initD_path = getServerDir() + '/init.d'
file_bin = initD_path + '/' + getPluginName()
if not os.path.exists(initD_path):
os.mkdir(initD_path)
# initd replace
content = mw.readFile(file_tpl)
content = content.replace('{$SERVER_PATH}', service_path)
mw.writeFile(file_bin, content)
mw.execShell('chmod +x ' + file_bin)
aria2_path = getServerDir() + '/aria2'
mw.execShell('mkdir -p /tmp/download')
if not os.path.exists(aria2_path):
mw.execShell('mkdir -p ' + aria2_path)
mw.execShell('touch ' + aria2_path + '/aria2.session')
path = getPluginDir() + "/conf/aria2.conf"
content = mw.readFile(path)
content = content.replace('{$SERVER_PATH}', aria2_path)
mw.writeFile(aria2_path + '/aria2.conf', content)
return file_bin
def checkArgs(data, ck=[]):
for i in range(len(ck)):
if not ck[i] in data:
return (False, mw.returnJson(False, '参数:(' + ck[i] + ')没有!'))
return (True, mw.returnJson(True, 'ok'))
def status():
cmd = "ps -ef|grep aria2 |grep -v grep | grep -v 'mdserver-web'| awk '{print $2}'"
data = mw.execShell(cmd)
if data[0] == '':
return 'stop'
return 'start'
def start():
file = initDreplace()
data = mw.execShell(file + ' start')
if data[1] == '':
return 'ok'
return data[1]
def stop():
file = initDreplace()
data = mw.execShell(file + ' stop')
# print data
if data[1] == '':
return 'ok'
return data[1]
def restart():
file = initDreplace()
data = mw.execShell(file + ' reload')
if data[1] == '':
return 'ok'
return data[1]
def reload():
file = initDreplace()
data = mw.execShell(file + ' reload')
if data[1] == '':
return 'ok'
return data[1]
def getPathFile():
if mw.isAppleSystem():
user = mw.execShell(
"who | sed -n '2, 1p' |awk '{print $1}'")[0].strip()
return '/Users/' + user + '/.aria2/aria2.conf'
return getServerDir() + '/aria2/aria2.conf'
def getInitDFile():
if app_debug:
return '/tmp/' + getPluginName()
return '/etc/init.d/' + getPluginName()
def initdStatus():
if not app_debug:
if mw.isAppleSystem():
return "Apple Computer does not support"
initd_bin = getInitDFile()
if os.path.exists(initd_bin):
return 'ok'
return 'fail'
def initdInstall():
source_bin = initDreplace()
initd_bin = getInitDFile()
shutil.copyfile(source_bin, initd_bin)
mw.execShell('chmod +x ' + initd_bin)
if not app_debug:
mw.execShell('chkconfig --add ' + getPluginName())
return 'ok'
def initdUinstall():
if not app_debug:
mw.execShell('chkconfig --del ' + getPluginName())
initd_bin = getInitDFile()
if os.path.exists(initd_bin):
os.remove(initd_bin)
return 'ok'
def getLog():
if mw.isAppleSystem():
user = mw.execShell(
"who | sed -n '2, 1p' |awk '{print $1}'")[0].strip()
return '/Users/' + user + '/.aria2/aria2.log'
return getServerDir() + '/aria2/aria2.log'
if __name__ == "__main__":
func = sys.argv[1]
if func == 'status':
print status()
elif func == 'start':
print start()
elif func == 'stop':
print stop()
elif func == 'restart':
print restart()
elif func == 'reload':
print reload()
elif func == 'conf':
print getPathFile()
elif func == 'initd_status':
print initdStatus()
elif func == 'initd_install':
print initdInstall()
elif func == 'initd_uninstall':
print initdUinstall()
elif func == 'run_log':
print getLog()
else:
print 'error'
+15
View File
@@ -0,0 +1,15 @@
{
"title":"aria2",
"tip":"soft",
"name":"aria2",
"type":"其他插件",
"ps":"一款下载神器",
"versions":"1.0",
"shell":"install.sh",
"checks":"server/aria2",
"path": "server/aria2",
"author":"midoks",
"home":"https://github.com/aria2/aria2",
"date":"2020-06-08",
"pid": "5"
}
+49
View File
@@ -0,0 +1,49 @@
#!/bin/sh
# chkconfig: 2345 55 25
# description: aria2 Service
### BEGIN INIT INFO
# Provides: aria2
# Required-Start: $all
# Required-Stop: $all
# Default-Start: 2 3 4 5
# Default-Stop: 0 1 6
# Short-Description: starts aria2
# Description: starts the MDW-Web
### END INIT INFO
app_start(){
# aria2c -D
aria2c --daemon --enable-rpc --rpc-listen-all -c -D --conf-path={$SERVER_PATH}/aria2/aria2/aria2.conf
echo "aria2 started"
}
app_stop(){
echo "Stopping ..."
arr=`ps -ef | grep "aria2" | grep -v 'grep' | grep -v '/bin/sh'|grep -v 'index.py' | awk '{print $2}'`
echo $arr
for p in ${arr[@]}
do
kill -9 $p &>/dev/null
done
echo "aria2 stopped"
}
case "$1" in
start)
app_start
;;
stop)
app_stop
;;
restart|reload)
app_stop
sleep 0.3
app_start
;;
*)
echo "Please use start or stop as first argument"
;;
esac
+49
View File
@@ -0,0 +1,49 @@
#!/bin/bash
PATH=/bin:/sbin:/usr/bin:/usr/sbin:/usr/local/bin:/usr/local/sbin:~/bin
export PATH
curPath=`pwd`
rootPath=$(dirname "$curPath")
rootPath=$(dirname "$rootPath")
serverPath=$(dirname "$rootPath")
install_tmp=${rootPath}/tmp/mw_install.pl
SYSOS=`uname`
Install_aria2()
{
isStart=""
echo '正在安装脚本文件...' > $install_tmp
mkdir -p $serverPath/aria2
echo '1.0' > $serverPath/aria2/version.pl
if [ "Darwin" == "$SYSOS" ];then
echo 'macosx unavailable' > $install_tmp
find_sh=`which aria2c`
if [ "$?" != "0" ];then
brew install aria2
fi
else
find_sh=`which aria2c`
if [ "$?" != "0" ];then
yum install aria2 -y
fi
fi
echo 'Install complete' > $install_tmp
}
Uninstall_aria2()
{
rm -rf $serverPath/aria2
echo "Uninstall completed" > $install_tmp
}
action=$1
if [ "${1}" == 'install' ];then
Install_aria2
else
Uninstall_aria2
fi
+92
View File
@@ -0,0 +1,92 @@
function str2Obj(str){
var data = {};
kv = str.split('&');
for(i in kv){
v = kv[i].split('=');
data[v[0]] = v[1];
}
return data;
}
function lpPost(method,args,callback, title){
var _args = null;
if (typeof(args) == 'string'){
_args = JSON.stringify(str2Obj(args));
} else {
_args = JSON.stringify(args);
}
var _title = '正在获取...';
if (typeof(title) != 'undefined'){
_title = title;
}
var loadT = layer.msg(_title, { icon: 16, time: 0, shade: 0.3 });
$.post('/plugins/run', {name:'aria2', func:method, args:_args}, function(data) {
layer.close(loadT);
if (!data.status){
layer.msg(data.msg,{icon:0,time:2000,shade: [0.3, '#000']});
return;
}
if(typeof(callback) == 'function'){
callback(data);
}
},'json');
}
function lpAsyncPost(method,args){
var _args = null;
if (typeof(args) == 'string'){
_args = JSON.stringify(str2Obj(args));
} else {
_args = JSON.stringify(args);
}
var loadT = layer.msg('正在获取...', { icon: 16, time: 0, shade: 0.3 });
return syncPost('/plugins/run', {name:'l2tp', func:method, args:_args});
}
function userList(){
lpPost('user_list', '' ,function(data){
var rdata = $.parseJSON(data['data']);
if (!rdata['status']){
layer.msg(rdata.msg,{icon:0,time:2000,shade: [0.3, '#000']});
return;
}
var list = rdata['data'];
var con = '';
con += '<div class="divtable" style="margin-top:5px;"><table class="table table-hover" width="100%" cellspacing="0" cellpadding="0" border="0">';
con += '<thead><tr>';
con += '<th>用户</th>';
con += '<th>密码</th>';
con += '<th>操作(<a class="btlink" onclick="addUser()">添加</a>)</th>';
con += '</tr></thead>';
con += '<tbody>';
for (var i = 0; i < list.length; i++) {
con += '<tr>'+
'<td>' + list[i]['user']+'</td>' +
'<td>' + list[i]['pwd']+'</td>' +
'<td><a class="btlink" onclick="modUser(\''+list[i]['user']+'\')">改密</a>|<a class="btlink" onclick="delUser(\''+list[i]['user']+'\')">删除</a></td></tr>';
}
con += '</tbody>';
con += '</table></div>';
$(".soft-man-con").html(con);
});
}
function readme(){
var readme = '<ul class="help-info-text c7">';
readme += '<li>使用时,查看对应的端口</li>';
readme += '</ul>';
$('.soft-man-con').html(readme);
}
Binary file not shown.

After

Width:  |  Height:  |  Size: 498 B

+17
View File
@@ -0,0 +1,17 @@
<div class="bt-form">
<div class="bt-w-main">
<div class="bt-w-menu">
<p class="bgw" onclick="pluginService('bbr');">服务</p>
<p onclick="readme();">说明</p>
</div>
<div class="bt-w-con pd15">
<div class="soft-man-con"></div>
</div>
</div>
</div>
<script type="text/javascript">
$.getScript( "/plugins/file?name=bbr&f=js/bbr.js", function() {
pluginService('bbr');
});
</script>
+109
View File
@@ -0,0 +1,109 @@
# coding: utf-8
import time
import random
import os
import json
import re
import sys
sys.path.append(os.getcwd() + "/class/core")
import mw
app_debug = False
if mw.isAppleSystem():
app_debug = True
def getPluginName():
return 'bbr'
def getPluginDir():
return mw.getPluginDir() + '/' + getPluginName()
def getServerDir():
return mw.getServerDir() + '/' + getPluginName()
def getInitDFile():
if app_debug:
return '/tmp/' + getPluginName()
return '/etc/init.d/' + getPluginName()
def getArgs():
args = sys.argv[2:]
tmp = {}
args_len = len(args)
if args_len == 1:
t = args[0].strip('{').strip('}')
t = t.split(':')
tmp[t[0]] = t[1]
elif args_len > 1:
for i in range(len(args)):
t = args[i].split(':')
tmp[t[0]] = t[1]
return tmp
def status():
if not app_debug:
if mw.isAppleSystem():
return "stop"
data = mw.execShell('sudo sysctl -n net.ipv4.tcp_congestion_control')
r = data[0].strip()
if r == 'bbr':
return 'start'
return 'stop'
def start():
if not app_debug:
if mw.isAppleSystem():
return "Apple Computer does not support"
mw.execShell('echo "net.core.default_qdisc=fq" >> /etc/sysctl.conf')
cmd = 'echo "net.ipv4.tcp_congestion_control=bbr" >> /etc/sysctl.conf'
mw.execShell(cmd)
mw.execShell('sysctl -p')
return '执行成功!重启系统生效'
def stop():
if not app_debug:
if mw.isAppleSystem():
return "Apple Computer does not support"
cmd1 = "sed -i '/net\.core\.default_qdisc/d' /etc/sysctl.conf"
mw.execShell(cmd1)
cmd2 = "sed -i '/net\.ipv4\.tcp_congestion_control/d' /etc/sysctl.conf"
mw.execShell(cmd2)
mw.execShell("sysctl -p")
return '执行成功!重启系统生效'
def restart():
return '无效'
def reload():
return '无效'
if __name__ == "__main__":
func = sys.argv[1]
if func == 'status':
print status()
elif func == 'start':
print start()
elif func == 'stop':
print stop()
elif func == 'restart':
print restart()
elif func == 'reload':
print reload()
+16
View File
@@ -0,0 +1,16 @@
{
"id":4,
"title":"BBR",
"tip":"soft",
"name":"bbr",
"type":"软件",
"ps":"[DEV][谨慎]BBR是Google提出的一种新型拥塞控制算法",
"versions":"1.0",
"shell":"install.sh",
"checks":"server/bbr",
"path":"server/bbr",
"author":"Google",
"home":"https://github.com/google/bbr",
"date":"2019-03-29",
"pid":"5"
}
+36
View File
@@ -0,0 +1,36 @@
#!/bin/bash
PATH=/bin:/sbin:/usr/bin:/usr/sbin:/usr/local/bin:/usr/local/sbin:~/bin
export PATH
curPath=`pwd`
rootPath=$(dirname "$curPath")
rootPath=$(dirname "$rootPath")
serverPath=$(dirname "$rootPath")
install_tmp=${rootPath}/tmp/mw_install.pl
Install_bbr()
{
echo '正在安装脚本文件...' > $install_tmp
chmod +x $curPath/scripts/bbr.sh
sh $curPath/scripts/bbr.sh
mkdir -p $serverPath/bbr
echo '1.0' > $serverPath/bbr/version.pl
echo '安装完成' > $install_tmp
}
Uninstall_bbr()
{
rm -rf $serverPath/bbr
echo "卸载完成" > $install_tmp
}
action=$1
if [ "${1}" == 'install' ];then
Install_bbr
else
Uninstall_bbr
fi
+13
View File
@@ -0,0 +1,13 @@
function readme(){
var con = '<ul class="help-info-text c7">';
con += '<li>一旦安装无法退回!谨慎使用</li>';
con += '<li>只有KVM架构的VPS才能使用</li>';
con += '<li>安装 Google BBR 需升级系统内核,而安装锐速则需降级系统内核,<br/>故两者不能同时安装。</li>';
con += '<li>安装 Google BBR 需升级系统内核,有可能造成系统不稳定,<br/>故不建议将其应用在重要的生产环境中</li>';
con += '<hr/>';
con += '<li>安装升级后,可删除无用的旧内核[谨慎操作]</li>';
con += '<li>yum remove $(rpm -qa | grep kernel | grep -v $(uname -r))</li>';
con += '</ul>';
$(".soft-man-con").html(con);
}
+389
View File
@@ -0,0 +1,389 @@
#!/usr/bin/env bash
#
# Auto install latest kernel for TCP BBR
#
# System Required: CentOS 6+, Debian7+, Ubuntu12+
#
# Copyright (C) 2016-2018 Teddysun <i@teddysun.com>
#
# URL: https://teddysun.com/489.html
#
red='\033[0;31m'
green='\033[0;32m'
yellow='\033[0;33m'
plain='\033[0m'
cur_dir=$(pwd)
[[ $EUID -ne 0 ]] && echo -e "${red}Error:${plain} This script must be run as root!" && exit 1
[[ -d "/proc/vz" ]] && echo -e "${red}Error:${plain} Your VPS is based on OpenVZ, which is not supported." && exit 1
if [ -f /etc/redhat-release ]; then
release="centos"
elif cat /etc/issue | grep -Eqi "debian"; then
release="debian"
elif cat /etc/issue | grep -Eqi "ubuntu"; then
release="ubuntu"
elif cat /etc/issue | grep -Eqi "centos|red hat|redhat"; then
release="centos"
elif cat /proc/version | grep -Eqi "debian"; then
release="debian"
elif cat /proc/version | grep -Eqi "ubuntu"; then
release="ubuntu"
elif cat /proc/version | grep -Eqi "centos|red hat|redhat"; then
release="centos"
else
release=""
fi
is_digit(){
local input=${1}
if [[ "$input" =~ ^[0-9]+$ ]]; then
return 0
else
return 1
fi
}
is_64bit(){
if [ $(getconf WORD_BIT) = '32' ] && [ $(getconf LONG_BIT) = '64' ]; then
return 0
else
return 1
fi
}
get_valid_valname(){
local val=${1}
local new_val=$(eval echo $val | sed 's/[-.]/_/g')
echo ${new_val}
}
get_hint(){
local val=${1}
local new_val=$(get_valid_valname $val)
eval echo "\$hint_${new_val}"
}
#Display Memu
display_menu(){
local soft=${1}
local default=${2}
eval local arr=(\${${soft}_arr[@]})
local default_prompt
if [[ "$default" != "" ]]; then
if [[ "$default" == "last" ]]; then
default=${#arr[@]}
fi
default_prompt="(default ${arr[$default-1]})"
fi
local pick
local hint
local vname
local prompt="which ${soft} you'd select ${default_prompt}: "
while :
do
echo -e "\n------------ ${soft} setting ------------\n"
for ((i=1;i<=${#arr[@]};i++ )); do
vname="$(get_valid_valname ${arr[$i-1]})"
hint="$(get_hint $vname)"
[[ "$hint" == "" ]] && hint="${arr[$i-1]}"
echo -e "${green}${i}${plain}) $hint"
done
echo
read -p "${prompt}" pick
if [[ "$pick" == "" && "$default" != "" ]]; then
pick=${default}
break
fi
if ! is_digit "$pick"; then
prompt="Input error, please input a number"
continue
fi
if [[ "$pick" -lt 1 || "$pick" -gt ${#arr[@]} ]]; then
prompt="Input error, please input a number between 1 and ${#arr[@]}: "
continue
fi
break
done
eval ${soft}=${arr[$pick-1]}
vname="$(get_valid_valname ${arr[$pick-1]})"
hint="$(get_hint $vname)"
[[ "$hint" == "" ]] && hint="${arr[$pick-1]}"
echo -e "\nyour selection: $hint\n"
}
version_ge(){
test "$(echo "$@" | tr " " "\n" | sort -rV | head -n 1)" == "$1"
}
get_latest_version() {
latest_version=($(wget -qO- https://kernel.ubuntu.com/~kernel-ppa/mainline/ | awk -F'\"v' '/v[4-9]./{print $2}' | cut -d/ -f1 | grep -v - | sort -V))
[ ${#latest_version[@]} -eq 0 ] && echo -e "${red}Error:${plain} Get latest kernel version failed." && exit 1
kernel_arr=()
for i in ${latest_version[@]}; do
if version_ge $i 4.14; then
kernel_arr+=($i);
fi
done
display_menu kernel last
if [[ `getconf WORD_BIT` == "32" && `getconf LONG_BIT` == "64" ]]; then
deb_name=$(wget -qO- https://kernel.ubuntu.com/~kernel-ppa/mainline/v${kernel}/ | grep "linux-image" | grep "generic" | awk -F'\">' '/amd64.deb/{print $2}' | cut -d'<' -f1 | head -1)
deb_kernel_url="https://kernel.ubuntu.com/~kernel-ppa/mainline/v${kernel}/${deb_name}"
deb_kernel_name="linux-image-${kernel}-amd64.deb"
modules_deb_name=$(wget -qO- https://kernel.ubuntu.com/~kernel-ppa/mainline/v${kernel}/ | grep "linux-modules" | grep "generic" | awk -F'\">' '/amd64.deb/{print $2}' | cut -d'<' -f1 | head -1)
deb_kernel_modules_url="https://kernel.ubuntu.com/~kernel-ppa/mainline/v${kernel}/${modules_deb_name}"
deb_kernel_modules_name="linux-modules-${kernel}-amd64.deb"
else
deb_name=$(wget -qO- https://kernel.ubuntu.com/~kernel-ppa/mainline/v${kernel}/ | grep "linux-image" | grep "generic" | awk -F'\">' '/i386.deb/{print $2}' | cut -d'<' -f1 | head -1)
deb_kernel_url="https://kernel.ubuntu.com/~kernel-ppa/mainline/v${kernel}/${deb_name}"
deb_kernel_name="linux-image-${kernel}-i386.deb"
modules_deb_name=$(wget -qO- https://kernel.ubuntu.com/~kernel-ppa/mainline/v${kernel}/ | grep "linux-modules" | grep "generic" | awk -F'\">' '/i386.deb/{print $2}' | cut -d'<' -f1 | head -1)
deb_kernel_modules_url="https://kernel.ubuntu.com/~kernel-ppa/mainline/v${kernel}/${modules_deb_name}"
deb_kernel_modules_name="linux-modules-${kernel}-i386.deb"
fi
[ -z ${deb_name} ] && echo -e "${red}Error:${plain} Getting Linux kernel binary package name failed, maybe kernel build failed. Please choose other one and try again." && exit 1
}
get_opsy() {
[ -f /etc/redhat-release ] && awk '{print ($1,$3~/^[0-9]/?$3:$4)}' /etc/redhat-release && return
[ -f /etc/os-release ] && awk -F'[= "]' '/PRETTY_NAME/{print $3,$4,$5}' /etc/os-release && return
[ -f /etc/lsb-release ] && awk -F'[="]+' '/DESCRIPTION/{print $2}' /etc/lsb-release && return
}
opsy=$( get_opsy )
arch=$( uname -m )
lbit=$( getconf LONG_BIT )
kern=$( uname -r )
get_char() {
SAVEDSTTY=`stty -g`
stty -echo
stty cbreak
dd if=/dev/tty bs=1 count=1 2> /dev/null
stty -raw
stty echo
stty $SAVEDSTTY
}
getversion() {
if [[ -s /etc/redhat-release ]]; then
grep -oE "[0-9.]+" /etc/redhat-release
else
grep -oE "[0-9.]+" /etc/issue
fi
}
centosversion() {
if [ x"${release}" == x"centos" ]; then
local code=$1
local version="$(getversion)"
local main_ver=${version%%.*}
if [ "$main_ver" == "$code" ]; then
return 0
else
return 1
fi
else
return 1
fi
}
check_bbr_status() {
local param=$(sysctl net.ipv4.tcp_congestion_control | awk '{print $3}')
if [[ x"${param}" == x"bbr" ]]; then
return 0
else
return 1
fi
}
check_kernel_version() {
local kernel_version=$(uname -r | cut -d- -f1)
if version_ge ${kernel_version} 4.9; then
return 0
else
return 1
fi
}
install_elrepo() {
if centosversion 5; then
echo -e "${red}Error:${plain} not supported CentOS 5."
exit 1
fi
rpm --import https://www.elrepo.org/RPM-GPG-KEY-elrepo.org
if centosversion 6; then
rpm -Uvh https://www.elrepo.org/elrepo-release-6-8.el6.elrepo.noarch.rpm
elif centosversion 7; then
rpm -Uvh https://www.elrepo.org/elrepo-release-7.0-3.el7.elrepo.noarch.rpm
fi
if [ ! -f /etc/yum.repos.d/elrepo.repo ]; then
echo -e "${red}Error:${plain} Install elrepo failed, please check it."
exit 1
fi
}
sysctl_config() {
sed -i '/net.core.default_qdisc/d' /etc/sysctl.conf
sed -i '/net.ipv4.tcp_congestion_control/d' /etc/sysctl.conf
echo "net.core.default_qdisc = fq" >> /etc/sysctl.conf
echo "net.ipv4.tcp_congestion_control = bbr" >> /etc/sysctl.conf
sysctl -p >/dev/null 2>&1
}
install_config() {
if [[ x"${release}" == x"centos" ]]; then
if centosversion 6; then
if [ ! -f "/boot/grub/grub.conf" ]; then
echo -e "${red}Error:${plain} /boot/grub/grub.conf not found, please check it."
exit 1
fi
sed -i 's/^default=.*/default=0/g' /boot/grub/grub.conf
elif centosversion 7; then
if [ ! -f "/boot/grub2/grub.cfg" ]; then
echo -e "${red}Error:${plain} /boot/grub2/grub.cfg not found, please check it."
exit 1
fi
grub2-set-default 0
fi
elif [[ x"${release}" == x"debian" || x"${release}" == x"ubuntu" ]]; then
/usr/sbin/update-grub
fi
}
reboot_os() {
echo
echo -e "${green}Info:${plain} The system needs to reboot."
# read -p "Do you want to restart system? [y/n]" is_reboot
# if [[ ${is_reboot} == "y" || ${is_reboot} == "Y" ]]; then
# reboot
# else
# echo -e "${green}Info:${plain} Reboot has been canceled..."
# exit 0
# fi
}
install_bbr() {
check_bbr_status
if [ $? -eq 0 ]; then
echo
echo -e "${green}Info:${plain} TCP BBR has already been installed. nothing to do..."
exit 0
fi
check_kernel_version
if [ $? -eq 0 ]; then
echo
echo -e "${green}Info:${plain} Your kernel version is greater than 4.9, directly setting TCP BBR..."
sysctl_config
echo -e "${green}Info:${plain} Setting TCP BBR completed..."
exit 0
fi
if [[ x"${release}" == x"centos" ]]; then
install_elrepo
[ ! "$(command -v yum-config-manager)" ] && yum install -y yum-utils > /dev/null 2>&1
[ x"$(yum-config-manager elrepo-kernel | grep -w enabled | awk '{print $3}')" != x"True" ] && yum-config-manager --enable elrepo-kernel > /dev/null 2>&1
if centosversion 6; then
if is_64bit; then
rpm_kernel_name="kernel-ml-4.18.20-1.el6.elrepo.x86_64.rpm"
rpm_kernel_devel_name="kernel-ml-devel-4.18.20-1.el6.elrepo.x86_64.rpm"
rpm_kernel_url_1="http://repos.lax.quadranet.com/elrepo/archive/kernel/el6/x86_64/RPMS/"
else
rpm_kernel_name="kernel-ml-4.18.20-1.el6.elrepo.i686.rpm"
rpm_kernel_devel_name="kernel-ml-devel-4.18.20-1.el6.elrepo.i686.rpm"
rpm_kernel_url_1="http://repos.lax.quadranet.com/elrepo/archive/kernel/el6/i386/RPMS/"
fi
rpm_kernel_url_2="https://dl.lamp.sh/files/"
wget -c -t3 -T60 -O ${rpm_kernel_name} ${rpm_kernel_url_1}${rpm_kernel_name}
if [ $? -ne 0 ]; then
rm -rf ${rpm_kernel_name}
wget -c -t3 -T60 -O ${rpm_kernel_name} ${rpm_kernel_url_2}${rpm_kernel_name}
fi
wget -c -t3 -T60 -O ${rpm_kernel_devel_name} ${rpm_kernel_url_1}${rpm_kernel_devel_name}
if [ $? -ne 0 ]; then
rm -rf ${rpm_kernel_devel_name}
wget -c -t3 -T60 -O ${rpm_kernel_devel_name} ${rpm_kernel_url_2}${rpm_kernel_devel_name}
fi
if [ -f "${rpm_kernel_name}" ]; then
rpm -ivh ${rpm_kernel_name}
else
echo -e "${red}Error:${plain} Download ${rpm_kernel_name} failed, please check it."
exit 1
fi
if [ -f "${rpm_kernel_devel_name}" ]; then
rpm -ivh ${rpm_kernel_devel_name}
else
echo -e "${red}Error:${plain} Download ${rpm_kernel_devel_name} failed, please check it."
exit 1
fi
rm -f ${rpm_kernel_name} ${rpm_kernel_devel_name}
elif centosversion 7; then
yum -y install kernel-ml kernel-ml-devel
if [ $? -ne 0 ]; then
echo -e "${red}Error:${plain} Install latest kernel failed, please check it."
exit 1
fi
fi
elif [[ x"${release}" == x"debian" || x"${release}" == x"ubuntu" ]]; then
[[ ! -e "/usr/bin/wget" ]] && apt-get -y update && apt-get -y install wget
echo -e "${green}Info:${plain} Getting latest kernel version..."
get_latest_version
if [ -n ${modules_deb_name} ]; then
wget -c -t3 -T60 -O ${deb_kernel_modules_name} ${deb_kernel_modules_url}
if [ $? -ne 0 ]; then
echo -e "${red}Error:${plain} Download ${deb_kernel_modules_name} failed, please check it."
exit 1
fi
fi
wget -c -t3 -T60 -O ${deb_kernel_name} ${deb_kernel_url}
if [ $? -ne 0 ]; then
echo -e "${red}Error:${plain} Download ${deb_kernel_name} failed, please check it."
exit 1
fi
[ -f ${deb_kernel_modules_name} ] && dpkg -i ${deb_kernel_modules_name}
dpkg -i ${deb_kernel_name}
rm -f ${deb_kernel_name} ${deb_kernel_modules_name}
else
echo -e "${red}Error:${plain} OS is not be supported, please change to CentOS/Debian/Ubuntu and try again."
exit 1
fi
install_config
sysctl_config
reboot_os
}
clear
echo "---------- System Information ----------"
echo " OS : $opsy"
echo " Arch : $arch ($lbit Bit)"
echo " Kernel : $kern"
echo "----------------------------------------"
echo " Auto install latest kernel for TCP BBR"
echo
echo " URL: https://teddysun.com/489.html"
echo "----------------------------------------"
echo
# echo "Press any key to start...or Press Ctrl+C to cancel"
# char=`get_char`
#install_bbr 2>&1 | tee ${cur_dir}/install_bbr.log
install_bbr
+51 -51
View File
@@ -11,11 +11,11 @@ import sys
import subprocess import subprocess
sys.path.append(os.getcwd() + "/class/core") sys.path.append(os.getcwd() + "/class/core")
import public import mw
app_debug = False app_debug = False
if public.isAppleSystem(): if mw.isAppleSystem():
app_debug = True app_debug = True
@@ -24,11 +24,11 @@ def getPluginName():
def getPluginDir(): def getPluginDir():
return public.getPluginDir() + '/' + getPluginName() return mw.getPluginDir() + '/' + getPluginName()
def getServerDir(): def getServerDir():
return public.getServerDir() + '/' + getPluginName() return mw.getServerDir() + '/' + getPluginName()
def getInitDFile(): def getInitDFile():
@@ -64,7 +64,7 @@ def initDreplace():
def status(): def status():
data = public.execShell( data = mw.execShell(
"ps -ef|grep " + getPluginName() + " |grep -v grep | grep -v python | awk '{print $2}'") "ps -ef|grep " + getPluginName() + " |grep -v grep | grep -v python | awk '{print $2}'")
if data[0] == '': if data[0] == '':
return 'stop' return 'stop'
@@ -74,7 +74,7 @@ def status():
def csvnOp(method): def csvnOp(method):
if app_debug: if app_debug:
os_name = public.getOs() os_name = mw.getOs()
if os_name == 'darwin': if os_name == 'darwin':
return "Apple Computer does not support" return "Apple Computer does not support"
@@ -83,8 +83,8 @@ def csvnOp(method):
#_csvn = getServerDir() + '/bin/csvn' #_csvn = getServerDir() + '/bin/csvn'
#_csvn_httpd = getServerDir() + '/bin/csvn-httpd' #_csvn_httpd = getServerDir() + '/bin/csvn-httpd'
ret_csvn_httpd = public.execShell(_initd_csvn_httpd + ' ' + method) ret_csvn_httpd = mw.execShell(_initd_csvn_httpd + ' ' + method)
# ret_csvn = public.execShell(_initd_csvn + ' ' + method) # ret_csvn = mw.execShell(_initd_csvn + ' ' + method)
subprocess.Popen(_initd_csvn + ' ' + method, subprocess.Popen(_initd_csvn + ' ' + method,
stdout=subprocess.PIPE, shell=True) stdout=subprocess.PIPE, shell=True)
if ret_csvn_httpd[1] == '': if ret_csvn_httpd[1] == '':
@@ -110,7 +110,7 @@ def reload():
def initdStatus(): def initdStatus():
if not app_debug: if not app_debug:
if public.isAppleSystem(): if mw.isAppleSystem():
return "Apple Computer does not support" return "Apple Computer does not support"
_initd_csvn = '/etc/init.d/csvn' _initd_csvn = '/etc/init.d/csvn'
@@ -124,14 +124,14 @@ def initdStatus():
def initdInstall(): def initdInstall():
import shutil import shutil
if not app_debug: if not app_debug:
if public.isAppleSystem(): if mw.isAppleSystem():
return "Apple Computer does not support" return "Apple Computer does not support"
_csvn = getServerDir() + '/bin/csvn' _csvn = getServerDir() + '/bin/csvn'
_csvn_httpd = getServerDir() + '/bin/csvn-httpd' _csvn_httpd = getServerDir() + '/bin/csvn-httpd'
ret_csvn = public.execShell(_csvn + ' install') ret_csvn = mw.execShell(_csvn + ' install')
ret_csvn_httpd = public.execShell(_csvn_httpd + ' install') ret_csvn_httpd = mw.execShell(_csvn_httpd + ' install')
if ret_csvn[1] == '' and ret_csvn_httpd[1] == '': if ret_csvn[1] == '' and ret_csvn_httpd[1] == '':
return 'ok' return 'ok'
return 'fail' return 'fail'
@@ -139,14 +139,14 @@ def initdInstall():
def initdUinstall(): def initdUinstall():
if not app_debug: if not app_debug:
if public.isAppleSystem(): if mw.isAppleSystem():
return "Apple Computer does not support" return "Apple Computer does not support"
_csvn = getServerDir() + '/bin/csvn' _csvn = getServerDir() + '/bin/csvn'
_csvn_httpd = getServerDir() + '/bin/csvn-httpd' _csvn_httpd = getServerDir() + '/bin/csvn-httpd'
ret_csvn = public.execShell(_csvn + ' remove') ret_csvn = mw.execShell(_csvn + ' remove')
ret_csvn_httpd = public.execShell(_csvn_httpd + ' remove') ret_csvn_httpd = mw.execShell(_csvn_httpd + ' remove')
return 'ok' return 'ok'
@@ -155,7 +155,7 @@ def csvnEdit():
data['svn_access_file'] = getServerDir() + '/data/conf/svn_access_file' data['svn_access_file'] = getServerDir() + '/data/conf/svn_access_file'
data['commit_tpl'] = getPluginDir() + '/hook/commit.tpl' data['commit_tpl'] = getPluginDir() + '/hook/commit.tpl'
data['post_commit_tpl'] = getPluginDir() + '/hook/post-commit.tpl' data['post_commit_tpl'] = getPluginDir() + '/hook/post-commit.tpl'
return public.getJson(data) return mw.getJson(data)
def userAdd(): def userAdd():
@@ -170,7 +170,7 @@ def userAdd():
svn_auth_file = getServerDir() + "/data/conf/svn_auth_file" svn_auth_file = getServerDir() + "/data/conf/svn_auth_file"
cmd = htpasswd + ' -b ' + svn_auth_file + ' ' + \ cmd = htpasswd + ' -b ' + svn_auth_file + ' ' + \
args['username'] + ' ' + args['password'] args['username'] + ' ' + args['password']
data = public.execShell(cmd) data = mw.execShell(cmd)
# print data # print data
if data[0] == '': if data[0] == '':
return 'ok' return 'ok'
@@ -185,7 +185,7 @@ def userDel():
htpasswd = getServerDir() + "/bin/htpasswd" htpasswd = getServerDir() + "/bin/htpasswd"
svn_auth_file = getServerDir() + "/data/conf/svn_auth_file" svn_auth_file = getServerDir() + "/data/conf/svn_auth_file"
cmd = htpasswd + ' -D ' + svn_auth_file + ' ' + args['username'] cmd = htpasswd + ' -D ' + svn_auth_file + ' ' + args['username']
data = public.execShell(cmd) data = mw.execShell(cmd)
if data[0] == '': if data[0] == '':
return 'ok' return 'ok'
return 'fail' return 'fail'
@@ -194,8 +194,8 @@ def userDel():
def getAllUser(search=''): def getAllUser(search=''):
svn_auth_file = getServerDir() + '/data/conf/svn_auth_file' svn_auth_file = getServerDir() + '/data/conf/svn_auth_file'
if not os.path.exists(svn_auth_file): if not os.path.exists(svn_auth_file):
return public.getJson([]) return mw.getJson([])
auth = public.readFile(svn_auth_file) auth = mw.readFile(svn_auth_file)
auth = auth.strip() auth = auth.strip()
auth_list = auth.split("\n") auth_list = auth.split("\n")
@@ -232,14 +232,14 @@ def userList():
page_info = {'count': ulist_sum, 'p': page, page_info = {'count': ulist_sum, 'p': page,
'row': 10, 'tojs': 'csvnUserList'} 'row': 10, 'tojs': 'csvnUserList'}
data = {} data = {}
data['list'] = public.getPage(page_info) data['list'] = mw.getPage(page_info)
data['page'] = page data['page'] = page
data['page_size'] = page_size data['page_size'] = page_size
data['page_count'] = int(math.ceil(ulist_sum / page_size)) data['page_count'] = int(math.ceil(ulist_sum / page_size))
start = (page - 1) * page_size start = (page - 1) * page_size
data['data'] = ulist[start:start + page_size] data['data'] = ulist[start:start + page_size]
return public.getJson(data) return mw.getJson(data)
def projectAdd(): def projectAdd():
@@ -249,9 +249,9 @@ def projectAdd():
path = getServerDir() + '/bin/svnadmin' path = getServerDir() + '/bin/svnadmin'
dest = getServerDir() + '/data/repositories/' + args['name'] dest = getServerDir() + '/data/repositories/' + args['name']
cmd = path + ' create ' + dest cmd = path + ' create ' + dest
data = public.execShell(cmd) data = mw.execShell(cmd)
if data[1] == '': if data[1] == '':
public.execShell('chown -R csvn:csvn ' + dest) mw.execShell('chown -R csvn:csvn ' + dest)
return 'ok' return 'ok'
return 'fail' return 'fail'
@@ -263,7 +263,7 @@ def projectDel():
dest = getServerDir() + '/data/repositories/' + args['name'] dest = getServerDir() + '/data/repositories/' + args['name']
cmd = 'rm -rf ' + dest cmd = 'rm -rf ' + dest
data = public.execShell(cmd) data = mw.execShell(cmd)
if data[0] == '': if data[0] == '':
return 'ok' return 'ok'
return 'fail' return 'fail'
@@ -273,7 +273,7 @@ def getHttpPort():
http_main_conf = getServerDir() + '/data/conf/csvn_main_httpd.conf' http_main_conf = getServerDir() + '/data/conf/csvn_main_httpd.conf'
try: try:
if os.path.exists(http_main_conf): if os.path.exists(http_main_conf):
content = public.readFile(http_main_conf) content = mw.readFile(http_main_conf)
return re.search('Listen\s(\d+)', content).groups()[0] return re.search('Listen\s(\d+)', content).groups()[0]
except Exception as e: except Exception as e:
pass # print e pass # print e
@@ -284,7 +284,7 @@ def getCsvnPort():
http_main_conf = getServerDir() + '/data/conf/csvn-wrapper.conf' http_main_conf = getServerDir() + '/data/conf/csvn-wrapper.conf'
try: try:
if os.path.exists(http_main_conf): if os.path.exists(http_main_conf):
content = public.readFile(http_main_conf) content = mw.readFile(http_main_conf)
return re.search('wrapper.java.additional.3=-Djetty.port=(\d+)', content).groups()[0] return re.search('wrapper.java.additional.3=-Djetty.port=(\d+)', content).groups()[0]
except Exception as e: except Exception as e:
pass # print e pass # print e
@@ -347,18 +347,18 @@ def projectList():
data = {} data = {}
data['data'] = ret_data data['data'] = ret_data
data['list'] = public.getPage( data['list'] = mw.getPage(
{'count': dlist_sum, 'p': page, 'row': 10, 'tojs': 'csvnProjectList'}) {'count': dlist_sum, 'p': page, 'row': 10, 'tojs': 'csvnProjectList'})
data['ip'] = public.getLocalIp() data['ip'] = mw.getLocalIp()
data['port'] = getHttpPort() data['port'] = getHttpPort()
data['csvn_port'] = getCsvnPort() data['csvn_port'] = getCsvnPort()
return public.getJson(data) return mw.getJson(data)
def getAllAclList(): def getAllAclList():
svn_access_file = getServerDir() + '/data/conf/svn_access_file' svn_access_file = getServerDir() + '/data/conf/svn_access_file'
aData = public.readFile(svn_access_file) aData = mw.readFile(svn_access_file)
aData = re.sub('#.*', '', aData) aData = re.sub('#.*', '', aData)
aData = aData.strip().split('[')[1:] aData = aData.strip().split('[')[1:]
allAcl = {} allAcl = {}
@@ -394,7 +394,7 @@ def makeAclFile(content):
tmp += v[iv]['user'] + ' = ' + v[iv]['acl'] + "\n" tmp += v[iv]['user'] + ' = ' + v[iv]['acl'] + "\n"
tmp += "\n" tmp += "\n"
# svn_tmp_path = getServerDir() + '/data/conf/svn_access_file.log' # svn_tmp_path = getServerDir() + '/data/conf/svn_access_file.log'
return public.writeFile(svn_access_file, tmp) return mw.writeFile(svn_access_file, tmp)
def projectAclList(): def projectAclList():
@@ -405,7 +405,7 @@ def projectAclList():
acl = getAllAclList() acl = getAllAclList()
if name in acl: if name in acl:
return public.getJson(acl[name]) return mw.getJson(acl[name])
else: else:
return 'fail' return 'fail'
@@ -543,19 +543,19 @@ def getCsvnPwd(user):
pwd_file = 'data/csvn_sync.pl' pwd_file = 'data/csvn_sync.pl'
if os.path.exists(pwd_file): if os.path.exists(pwd_file):
return public.readFile(pwd_file).strip() return mw.readFile(pwd_file).strip()
import time import time
cur_time = time.time() cur_time = time.time()
rand_pwd = public.md5(str(cur_time)) rand_pwd = mw.md5(str(cur_time))
pwd = user + rand_pwd[:5] pwd = user + rand_pwd[:5]
htpasswd = getServerDir() + "/bin/htpasswd" htpasswd = getServerDir() + "/bin/htpasswd"
svn_auth_file = getServerDir() + "/data/conf/svn_auth_file" svn_auth_file = getServerDir() + "/data/conf/svn_auth_file"
cmd = htpasswd + ' -b ' + svn_auth_file + ' ' + user + ' ' + pwd cmd = htpasswd + ' -b ' + svn_auth_file + ' ' + user + ' ' + pwd
data = public.execShell(cmd) data = mw.execShell(cmd)
public.writeFile(pwd_file, pwd) mw.writeFile(pwd_file, pwd)
return pwd return pwd
@@ -570,21 +570,21 @@ def projectScriptLoad():
args['pname'] + '/hooks' args['pname'] + '/hooks'
post_commit_file = hook_path + '/post-commit' post_commit_file = hook_path + '/post-commit'
pct_content = public.readFile(post_commit_tpl) pct_content = mw.readFile(post_commit_tpl)
public.writeFile(post_commit_file, pct_content) mw.writeFile(post_commit_file, pct_content)
public.execShell('chmod 777 ' + post_commit_file) mw.execShell('chmod 777 ' + post_commit_file)
commit_tpl = getPluginDir() + '/hook/commit.tpl' commit_tpl = getPluginDir() + '/hook/commit.tpl'
commit_file = hook_path + '/commit' commit_file = hook_path + '/commit'
ct_content = public.readFile(commit_tpl) ct_content = mw.readFile(commit_tpl)
ct_content = ct_content.replace('{$PROJECT_DIR}', public.getRootDir()) ct_content = ct_content.replace('{$PROJECT_DIR}', mw.getRootDir())
ct_content = ct_content.replace('{$PORT}', getHttpPort()) ct_content = ct_content.replace('{$PORT}', getHttpPort())
ct_content = ct_content.replace('{$CSVN_USER}', getCsvnUser()) ct_content = ct_content.replace('{$CSVN_USER}', getCsvnUser())
ct_content = ct_content.replace('{$CSVN_PWD}', getCsvnPwd(getCsvnUser())) ct_content = ct_content.replace('{$CSVN_PWD}', getCsvnPwd(getCsvnUser()))
public.writeFile(commit_file, ct_content) mw.writeFile(commit_file, ct_content)
public.execShell('chmod 777 ' + commit_file) mw.execShell('chmod 777 ' + commit_file)
return 'ok' return 'ok'
@@ -596,11 +596,11 @@ def projectScriptUnload():
post_commit_file = getServerDir() + '/data/repositories/' + '/' + \ post_commit_file = getServerDir() + '/data/repositories/' + '/' + \
args['pname'] + '/hooks/post-commit' args['pname'] + '/hooks/post-commit'
public.execShell('rm -f ' + post_commit_file) mw.execShell('rm -f ' + post_commit_file)
commit_file = getServerDir() + '/data/repositories/' + '/' + \ commit_file = getServerDir() + '/data/repositories/' + '/' + \
args['pname'] + '/hooks/commit' args['pname'] + '/hooks/commit'
public.execShell('rm -f ' + commit_file) mw.execShell('rm -f ' + commit_file)
return 'ok' return 'ok'
@@ -619,7 +619,7 @@ def projectScriptEdit():
data['status'] = False data['status'] = False
data['msg'] = 'file does not exist' data['msg'] = 'file does not exist'
return public.getJson(data) return mw.getJson(data)
def projectScriptDebug(): def projectScriptDebug():
@@ -637,7 +637,7 @@ def projectScriptDebug():
data['status'] = False data['status'] = False
data['msg'] = 'file does not exist' data['msg'] = 'file does not exist'
return public.getJson(data) return mw.getJson(data)
def getTotalStatistics(): def getTotalStatistics():
@@ -647,12 +647,12 @@ def getTotalStatistics():
svn_path = getServerDir() + '/data/repositories' svn_path = getServerDir() + '/data/repositories'
data['status'] = True data['status'] = True
data['count'] = len(os.listdir(svn_path)) data['count'] = len(os.listdir(svn_path))
data['ver'] = public.readFile(getServerDir() + '/version.pl').strip() data['ver'] = mw.readFile(getServerDir() + '/version.pl').strip()
return public.returnJson(True, 'ok', data) return mw.returnJson(True, 'ok', data)
else: else:
data['status'] = False data['status'] = False
data['count'] = 0 data['count'] = 0
return public.returnJson(False, 'fail', data) return mw.returnJson(False, 'fail', data)
if __name__ == "__main__": if __name__ == "__main__":
+1
View File
@@ -8,6 +8,7 @@
"updates":"5.1.4", "updates":"5.1.4",
"tip": "soft", "tip": "soft",
"checks": "server/csvn", "checks": "server/csvn",
"path":"server/csvn",
"author": "midoks", "author": "midoks",
"date": "2017-04-01", "date": "2017-04-01",
"home": "https://www.collab.net", "home": "https://www.collab.net",
+18 -18
View File
@@ -8,7 +8,7 @@ import re
import sys import sys
sys.path.append(os.getcwd() + "/class/core") sys.path.append(os.getcwd() + "/class/core")
import public import mw
def getPluginName(): def getPluginName():
@@ -16,11 +16,11 @@ def getPluginName():
def getPluginDir(): def getPluginDir():
return public.getPluginDir() + '/' + getPluginName() return mw.getPluginDir() + '/' + getPluginName()
def getServerDir(): def getServerDir():
return public.getServerDir() + '/' + getPluginName() return mw.getServerDir() + '/' + getPluginName()
def getInitDFile(): def getInitDFile():
@@ -51,7 +51,7 @@ def status():
def getAllProjectList(search): def getAllProjectList(search):
path = public.getWwwDir() path = mw.getWwwDir()
dlist = [] dlist = []
if os.path.exists(path): if os.path.exists(path):
for filename in os.listdir(path): for filename in os.listdir(path):
@@ -92,7 +92,7 @@ def projectListEdit():
file = getServerDir() + '/' + args['name'] + '.json' file = getServerDir() + '/' + args['name'] + '.json'
if not os.path.exists(file): if not os.path.exists(file):
public.execShell('touch ' + file) mw.execShell('touch ' + file)
return file return file
@@ -103,17 +103,17 @@ def projectListDel():
file = getServerDir() + '/' + args['name'] + '.json' file = getServerDir() + '/' + args['name'] + '.json'
if os.path.exists(file): if os.path.exists(file):
content = public.readFile(file) content = mw.readFile(file)
contentObj = json.loads(content) contentObj = json.loads(content)
asyncUser = contentObj['client_email'] asyncUser = contentObj['client_email']
cmd = getServerDir() + '/google-cloud-sdk/bin/' cmd = getServerDir() + '/google-cloud-sdk/bin/'
public.execShell(cmd + 'gcloud auth revoke ' + asyncUser) mw.execShell(cmd + 'gcloud auth revoke ' + asyncUser)
public.execShell('rm -rf ' + file) mw.execShell('rm -rf ' + file)
return 'ok' return 'ok'
def checkUserExist(cmd, user): def checkUserExist(cmd, user):
data = public.execShell(cmd + 'gcloud auth list | grep ' + user) data = mw.execShell(cmd + 'gcloud auth list | grep ' + user)
if data[0] == '': if data[0] == '':
return False return False
return True return True
@@ -129,14 +129,14 @@ def projectListAsync():
if not os.path.exists(file): if not os.path.exists(file):
return 'not configured file!' return 'not configured file!'
content = public.readFile(file) content = mw.readFile(file)
contentObj = json.loads(content) contentObj = json.loads(content)
asyncUser = contentObj['client_email'] asyncUser = contentObj['client_email']
cmd = getServerDir() + '/google-cloud-sdk/bin/' cmd = getServerDir() + '/google-cloud-sdk/bin/'
projectDir = public.getWwwDir() + '/' + args['name'] projectDir = mw.getWwwDir() + '/' + args['name']
if not checkUserExist(cmd, asyncUser): if not checkUserExist(cmd, asyncUser):
public.execShell( mw.execShell(
cmd + 'gcloud auth activate-service-account --key-file ' + file) cmd + 'gcloud auth activate-service-account --key-file ' + file)
pName = contentObj['project_id'] pName = contentObj['project_id']
@@ -147,7 +147,7 @@ def projectListAsync():
taskAdd = (None, 'gae[async]', taskAdd = (None, 'gae[async]',
'execshell', '0', time.strftime('%Y-%m-%d %H:%M:%S'), asyncCmd) 'execshell', '0', time.strftime('%Y-%m-%d %H:%M:%S'), asyncCmd)
public.M('tasks').add('id,name,type,status,addtime, execstr', taskAdd) mw.M('tasks').add('id,name,type,status,addtime, execstr', taskAdd)
return 'ok' return 'ok'
@@ -160,12 +160,12 @@ def projectListCmd():
if not os.path.exists(file): if not os.path.exists(file):
return 'not configured file!' return 'not configured file!'
content = public.readFile(file) content = mw.readFile(file)
contentObj = json.loads(content) contentObj = json.loads(content)
asyncUser = contentObj['client_email'] asyncUser = contentObj['client_email']
cmd = getServerDir() + '/google-cloud-sdk/bin/' cmd = getServerDir() + '/google-cloud-sdk/bin/'
pName = contentObj['project_id'] pName = contentObj['project_id']
projectDir = public.getWwwDir() + '/' + args['name'] projectDir = mw.getWwwDir() + '/' + args['name']
setUserCmd = 'sudo ' + cmd + 'gcloud config set account ' + asyncUser setUserCmd = 'sudo ' + cmd + 'gcloud config set account ' + asyncUser
setUserCmd += ' && sudo ' + cmd + 'gcloud config set project ' + pName setUserCmd += ' && sudo ' + cmd + 'gcloud config set project ' + pName
@@ -183,7 +183,7 @@ def projectListUrl():
if not os.path.exists(file): if not os.path.exists(file):
return 'not configured file!' return 'not configured file!'
content = public.readFile(file) content = mw.readFile(file)
contentObj = json.loads(content) contentObj = json.loads(content)
asyncUser = contentObj['client_email'] asyncUser = contentObj['client_email']
plist = asyncUser.split('@') plist = asyncUser.split('@')
@@ -216,9 +216,9 @@ def projectList():
data = {} data = {}
data['data'] = ret_data data['data'] = ret_data
data['list'] = public.getPage( data['list'] = mw.getPage(
{'count': dlist_sum, 'p': page, 'row': 10, 'tojs': 'projectList'}) {'count': dlist_sum, 'p': page, 'row': 10, 'tojs': 'projectList'})
return public.getJson(data) return mw.getJson(data)
if __name__ == "__main__": if __name__ == "__main__":
func = sys.argv[1] func = sys.argv[1]
+1 -1
View File
@@ -2,7 +2,7 @@
"title":"GAE", "title":"GAE",
"tip":"soft", "tip":"soft",
"name":"gae", "name":"gae",
"ps":"GAE(Google App Engine)。它是Google管理的数据中心中用于WEB应用程序的开发和托管的平台", "ps":"GAE是Google用于WEB应用程序的开发和托管的平台",
"versions": "0.1", "versions": "0.1",
"shell":"install.sh", "shell":"install.sh",
"checks":"server/gae", "checks":"server/gae",
Binary file not shown.

After

Width:  |  Height:  |  Size: 4.4 KiB

+21
View File
@@ -0,0 +1,21 @@
<div class="bt-form">
<div class="bt-w-main">
<div class="bt-w-menu">
<p class="bgw" onclick="pluginService('go-fastdfs-web');">服务</p>
<p onclick="pluginInitD('go-fastdfs-web');">自启动</p>
<p onclick="pluginConfig('go-fastdfs-web');">配置</p>
<p onclick="pluginLogs('go-fastdfs-web','','run_log');">运行日志</p>
<p onclick="pRead()">说明</p>
</div>
<div class="bt-w-con pd15">
<div class="soft-man-con"></div>
</div>
</div>
</div>
<script type="text/javascript">
resetPluginWinWidth(700);
$.getScript( "/plugins/file?name=go-fastdfs-web&f=js/fastdfs.js", function() {
pluginService('go-fastdfs');
});
</script>
+196
View File
@@ -0,0 +1,196 @@
# coding: utf-8
import time
import random
import os
import json
import re
import sys
import subprocess
import threading
sys.path.append(os.getcwd() + "/class/core")
import mw
app_debug = False
if mw.isAppleSystem():
app_debug = True
def getPluginName():
return 'go-fastdfs-web'
def getPluginDir():
return mw.getPluginDir() + '/' + getPluginName()
def getServerDir():
return mw.getServerDir() + '/' + getPluginName()
def getInitDFile():
if app_debug:
return '/tmp/' + getPluginName()
return '/etc/init.d/' + getPluginName()
def getInitDTpl():
return getPluginDir() + "/init.d/" + getPluginName() + ".tpl"
def getLog():
return getServerDir() + "/log/fileserver.log"
def gfBreakpointLog():
return getServerDir() + "/log/tusd.log"
def getArgs():
args = sys.argv[2:]
tmp = {}
args_len = len(args)
if args_len == 1:
t = args[0].strip('{').strip('}')
t = t.split(':')
tmp[t[0]] = t[1]
elif args_len > 1:
for i in range(len(args)):
t = args[i].split(':')
tmp[t[0]] = t[1]
return tmp
def checkArgs(data, ck=[]):
for i in range(len(ck)):
if not ck[i] in data:
return (False, mw.returnJson(False, '参数:(' + ck[i] + ')没有!'))
return (True, mw.returnJson(True, 'ok'))
def status():
pn = getPluginName()
data = mw.execShell(
"ps -ef|grep " + pn + " | grep -v grep | grep -v python | awk '{print $2}'")
if data[0] == '':
return 'stop'
return 'start'
def initDreplace():
file_tpl = getInitDTpl()
service_path = os.path.dirname(os.getcwd())
initD_path = getServerDir() + '/init.d'
if not os.path.exists(initD_path):
os.mkdir(initD_path)
file_bin = initD_path + '/' + getPluginName()
if not os.path.exists(file_bin):
content = mw.readFile(file_tpl)
content = content.replace('{$SERVER_PATH}', service_path)
mw.writeFile(file_bin, content)
mw.execShell('chmod +x ' + file_bin)
return file_bin
def start():
file = initDreplace()
data = mw.execShell(file + ' start')
if data[1] == '':
return 'ok'
return 'fail'
def stop():
file = initDreplace()
data = mw.execShell(file + ' stop')
if data[1] == '':
return 'ok'
return 'fail'
def restart():
file = initDreplace()
data = mw.execShell(file + ' restart')
if data[1] == '':
return 'ok'
return 'fail'
def reload():
file = initDreplace()
data = mw.execShell(file + ' reload')
if data[1] == '':
return 'ok'
return 'fail'
def initdStatus():
initd_bin = getInitDFile()
if os.path.exists(initd_bin):
return 'ok'
return 'fail'
def initdInstall():
import shutil
source_bin = initDreplace()
initd_bin = getInitDFile()
shutil.copyfile(source_bin, initd_bin)
mw.execShell('chmod +x ' + initd_bin)
if not app_debug:
mw.execShell('chkconfig --add ' + getPluginName())
return 'ok'
def initdUinstall():
if not app_debug:
mw.execShell('chkconfig --del ' + getPluginName())
initd_bin = getInitDFile()
if os.path.exists(initd_bin):
os.remove(initd_bin)
return 'ok'
def gfConf():
return getServerDir() + "/config/application-prod.properties"
def getLog():
return getServerDir() + "/logs/go-fastdfs-web.log"
if __name__ == "__main__":
func = sys.argv[1]
if func == 'status':
print status()
elif func == 'start':
print start()
elif func == 'stop':
print stop()
elif func == 'restart':
print restart()
elif func == 'reload':
print reload()
elif func == 'initd_status':
print initdStatus()
elif func == 'initd_install':
print initdInstall()
elif func == 'initd_uninstall':
print initdUinstall()
elif func == 'run_log':
print getLog()
elif func == 'conf':
print gfConf()
else:
print 'error'
+16
View File
@@ -0,0 +1,16 @@
{
"id":10,
"title":"go-fastdfs-web",
"tip":"soft",
"name":"go-fastdfs-web",
"type":"软件",
"ps":"Go-Fastdfs web管理平台",
"versions":"1.1.2",
"shell":"install.sh",
"checks":"server/go-fastdfs-web",
"path": "server/go-fastdfs-web",
"author":"midoks",
"home":"https://github.com/perfree/go-fastdfs-web",
"date":"2019-08-07",
"pid":"2"
}
@@ -0,0 +1,91 @@
#!/bin/bash
# chkconfig: 2345 55 25
# description: go-fastdfs-web Cloud Service
### BEGIN INIT INFO
# Provides: bt
# Required-Start: $all
# Required-Stop: $all
# Default-Start: 2 3 4 5
# Default-Stop: 0 1 6
# Short-Description: starts go-fastdfs-web
# Description: starts the go-fastdfs-web
### END INIT INFO
PATH=/bin:/sbin:/usr/bin:/usr/sbin:/usr/local/bin:/usr/local/sbin:~/bin
SpringBoot=go-fastdfs-web.jar
gf_path={$SERVER_PATH}/go-fastdfs-web/$SpringBoot
if [ "$1" = "" ];
then
echo -e "\033[0;31m 未输入操作名 \033[0m \033[0;34m {start|stop|restart|status} \033[0m"
exit 1
fi
if [ "$SpringBoot" = "" ];
then
echo -e "\033[0;31m 未输入应用名 \033[0m"
exit 1
fi
function start()
{
count=`ps -ef |grep java|grep $SpringBoot|grep -v grep|wc -l`
if [ $count != 0 ];then
echo "$SpringBoot is running..."
else
echo "Start $SpringBoot success..."
cd $gf_path
nohup java -jar $SpringBoot > /dev/null 2>&1 &
fi
}
function stop()
{
echo "Stop $SpringBoot"
boot_id=`ps -ef |grep java|grep $SpringBoot|grep -v grep|awk '{print $2}'`
count=`ps -ef |grep java|grep $SpringBoot|grep -v grep|wc -l`
if [ $count != 0 ];then
kill $boot_id
count=`ps -ef |grep java|grep $SpringBoot|grep -v grep|wc -l`
boot_id=`ps -ef |grep java|grep $SpringBoot|grep -v grep|awk '{print $2}'`
kill -9 $boot_id
fi
}
function restart()
{
stop
sleep 2
start
}
function status()
{
count=`ps -ef |grep java|grep $SpringBoot|grep -v grep|wc -l`
if [ $count != 0 ];then
echo "$SpringBoot is running..."
else
echo "$SpringBoot is not running..."
fi
}
case $1 in
start)
start;;
stop)
stop;;
restart)
restart;;
status)
status;;
*)
echo -e "\033[0;31m Usage: \033[0m \033[0;34m sh $0 {start|stop|restart|status} {SpringBootJarName} \033[0m
\033[0;31m Example: \033[0m
\033[0;33m sh $0 start esmart-test.jar \033[0m"
esac
+54
View File
@@ -0,0 +1,54 @@
#!/bin/bash
PATH=/bin:/sbin:/usr/bin:/usr/sbin:/usr/local/bin:/usr/local/sbin:~/bin
export PATH
curPath=`pwd`
rootPath=$(dirname "$curPath")
rootPath=$(dirname "$rootPath")
serverPath=$(dirname "$rootPath")
sysName=`uname`
install_tmp=${rootPath}/tmp/mw_install.pl
action=$1
version=$2
Install_gf()
{
echo '正在安装脚本文件...' > $install_tmp
mkdir -p $serverPath/go-fastdfs-web
FF_DIR=${serverPath}/go-fastdfs-web
cd $FF_DIR
if [ $sysName == 'Darwin' ]; then
FF_SS_DIR=${serverPath}/source/go-fastdfs-web
mkdir -p $FF_SS_DIR
if [ ! -f $FF_SS_DIR/go-fastdfs-web-1.1.2.tar.gz ]; then
wget -O $FF_SS_DIR/go-fastdfs-web-1.1.2.tar.gz https://github.com/perfree/go-fastdfs-web/releases/download/1.1.2/go-fastdfs-web-1.1.2.tar.gz
fi
cd $FF_SS_DIR
if [ ! -d $FF_SS_DIR/go-fastdfs-web ]; then
tar -zxvf $FF_SS_DIR/go-fastdfs-web-1.1.2.tar.gz
fi
if [ ! -d $FF_DIR/config ];then
cp -rf $FF_SS_DIR/go-fastdfs-web/* $FF_DIR/
fi
fi
echo "$version" > $FF_DIR/version.pl
echo '安装完成' > $install_tmp
}
Uninstall_gf()
{
rm -rf $serverPath/go-fastdfs-web
echo "卸载完成" > $install_tmp
}
if [ "${1}" == 'install' ];then
Install_gf $version
else
Uninstall_gf $version
fi
+47
View File
@@ -0,0 +1,47 @@
function str2Obj(str){
var data = {};
kv = str.split('&');
for(i in kv){
v = kv[i].split('=');
data[v[0]] = v[1];
}
return data;
}
function pPost(method,args,callback, title){
var _args = null;
if (typeof(args) == 'string'){
_args = JSON.stringify(str2Obj(args));
} else {
_args = JSON.stringify(args);
}
var _title = '正在获取...';
if (typeof(title) != 'undefined'){
_title = title;
}
var loadT = layer.msg(_title, { icon: 16, time: 0, shade: 0.3 });
$.post('/plugins/run', {name:'go-fastdfs-web', func:method, args:_args}, function(data) {
layer.close(loadT);
if (!data.status){
layer.msg(data.msg,{icon:0,time:2000,shade: [0.3, '#000']});
return;
}
if(typeof(callback) == 'function'){
callback(data);
}
},'json');
}
function pRead(){
var readme = '<ul class="help-info-text c7">';
readme += '<li>根据配置查看,开启相应防火墙端口</li>';
readme += '</ul>';
$('.soft-man-con').html(readme);
}
Binary file not shown.

After

Width:  |  Height:  |  Size: 4.4 KiB

+23
View File
@@ -0,0 +1,23 @@
<div class="bt-form">
<div class="bt-w-main">
<div class="bt-w-menu">
<p class="bgw" onclick="pluginService('go-fastdfs');">服务</p>
<p onclick="pluginInitD('go-fastdfs');">自启动</p>
<p onclick="pluginConfig('go-fastdfs');">配置文件</p>
<p onclick="gfConfigSet()">重要配置查看</p>
<p onclick="pluginLogs('go-fastdfs','','run_log');">运行日志</p>
<p onclick="pluginLogs('go-fastdfs','','breakpoint_log');">断点日志</p>
<p onclick="pRead()">说明</p>
</div>
<div class="bt-w-con pd15">
<div class="soft-man-con"></div>
</div>
</div>
</div>
<script type="text/javascript">
resetPluginWinWidth(700);
$.getScript( "/plugins/file?name=go-fastdfs&f=js/fastdfs.js", function() {
pluginService('go-fastdfs');
});
</script>
+224
View File
@@ -0,0 +1,224 @@
# coding: utf-8
import time
import random
import os
import json
import re
import sys
import subprocess
import threading
sys.path.append(os.getcwd() + "/class/core")
import mw
app_debug = False
if mw.isAppleSystem():
app_debug = True
def getPluginName():
return 'go-fastdfs'
def getPluginDir():
return mw.getPluginDir() + '/' + getPluginName()
def getServerDir():
return mw.getServerDir() + '/' + getPluginName()
def getInitDFile():
if app_debug:
return '/tmp/' + getPluginName()
return '/etc/init.d/' + getPluginName()
def getInitDTpl():
return getPluginDir() + "/init.d/" + getPluginName() + ".tpl"
def getLog():
return getServerDir() + "/log/fileserver.log"
def gfBreakpointLog():
return getServerDir() + "/log/tusd.log"
def getArgs():
args = sys.argv[2:]
tmp = {}
args_len = len(args)
if args_len == 1:
t = args[0].strip('{').strip('}')
t = t.split(':')
tmp[t[0]] = t[1]
elif args_len > 1:
for i in range(len(args)):
t = args[i].split(':')
tmp[t[0]] = t[1]
return tmp
def checkArgs(data, ck=[]):
for i in range(len(ck)):
if not ck[i] in data:
return (False, mw.returnJson(False, '参数:(' + ck[i] + ')没有!'))
return (True, mw.returnJson(True, 'ok'))
def status():
pn = getPluginName()
data = mw.execShell(
"ps -ef|grep " + pn + " |grep -v grep |grep -v .jar | grep -v python | awk '{print $2}'")
if data[0] == '':
return 'stop'
return 'start'
def initDreplace():
file_tpl = getInitDTpl()
service_path = os.path.dirname(os.getcwd())
initD_path = getServerDir() + '/init.d'
if not os.path.exists(initD_path):
os.mkdir(initD_path)
file_bin = initD_path + '/' + getPluginName()
if not os.path.exists(file_bin):
content = mw.readFile(file_tpl)
content = content.replace('{$SERVER_PATH}', service_path)
mw.writeFile(file_bin, content)
mw.execShell('chmod +x ' + file_bin)
return file_bin
def start():
file = initDreplace()
data = mw.execShell(file + ' start')
if data[1] == '':
return 'ok'
return 'fail'
def stop():
file = initDreplace()
data = mw.execShell(file + ' stop')
if data[1] == '':
return 'ok'
return 'fail'
def restart():
file = initDreplace()
data = mw.execShell(file + ' restart')
if data[1] == '':
return 'ok'
return 'fail'
def reload():
file = initDreplace()
data = mw.execShell(file + ' reload')
if data[1] == '':
return 'ok'
return 'fail'
def initdStatus():
initd_bin = getInitDFile()
if os.path.exists(initd_bin):
return 'ok'
return 'fail'
def initdInstall():
import shutil
source_bin = initDreplace()
initd_bin = getInitDFile()
shutil.copyfile(source_bin, initd_bin)
mw.execShell('chmod +x ' + initd_bin)
if not app_debug:
mw.execShell('chkconfig --add ' + getPluginName())
return 'ok'
def initdUinstall():
if not app_debug:
mw.execShell('chkconfig --del ' + getPluginName())
initd_bin = getInitDFile()
if os.path.exists(initd_bin):
os.remove(initd_bin)
return 'ok'
def gfConf():
return getServerDir() + "/conf/cfg.json"
def gfConfSet():
gets = [
{'name': 'addr', 'type': -1, 'ps': '绑定端口'},
{'name': 'peer_id', 'type': -1, 'ps': '集群内唯一,请使用0-9的单字符'},
{'name': 'host', 'type': -1, 'ps': '本主机地址'},
{'name': 'group', 'type': -1, 'ps': '组号'},
{'name': 'support_group_manage', 'type': 0, 'ps': '是否支持按组(集群)管理'},
{'name': 'enable_merge_small_file', 'type': 0, 'ps': '是否合并小文件'},
{'name': 'refresh_interval', 'type': 1, 'ps': '重试同步失败文件的时间'},
{'name': 'rename_file', 'type': 0, 'ps': '是否自动重命名'},
{'name': 'enable_web_upload', 'type': 0, 'ps': '是否支持web上传,方便调试'},
{'name': 'enable_custom_path', 'type': 0, 'ps': '是否支持非日期路径'},
{'name': 'enable_migrate', 'type': 0, 'ps': '是否启用迁移'},
{'name': 'enable_cross_origin', 'type': 0, 'ps': '是否开启跨站访问'},
{'name': 'enable_tus', 'type': 0, 'ps': '是否开启断点续传'}
]
file = mw.readFile(gfConf())
data = json.loads(file)
result = []
for g in gets:
if g['name'] in data:
g['value'] = data[g['name']]
result.append(g)
return mw.getJson(result)
if __name__ == "__main__":
func = sys.argv[1]
if func == 'status':
print status()
elif func == 'start':
print start()
elif func == 'stop':
print stop()
elif func == 'restart':
print restart()
elif func == 'reload':
print reload()
elif func == 'initd_status':
print initdStatus()
elif func == 'initd_install':
print initdInstall()
elif func == 'initd_uninstall':
print initdUinstall()
elif func == 'run_log':
print getLog()
elif func == 'breakpoint_log':
print gfBreakpointLog()
elif func == 'conf':
print gfConf()
elif func == 'gf_conf_set':
print gfConfSet()
else:
print 'error'
+16
View File
@@ -0,0 +1,16 @@
{
"id":10,
"title":"go-fastdfs",
"tip":"soft",
"name":"go-fastdfs",
"type":"软件",
"ps":"一个基于http协议的分布式文件系统",
"versions":"1.3.1",
"shell":"install.sh",
"checks":"server/go-fastdfs",
"path": "server/go-fastdfs",
"author":"midoks",
"home":"https://github.com/sjqzhang/go-fastdfs",
"date":"2019-08-02",
"pid":"2"
}
+72
View File
@@ -0,0 +1,72 @@
#!/bin/bash
# chkconfig: 2345 55 25
# description: go-fastdfs Cloud Service
### BEGIN INIT INFO
# Provides: bt
# Required-Start: $all
# Required-Stop: $all
# Default-Start: 2 3 4 5
# Default-Stop: 0 1 6
# Short-Description: starts go-fastdfs
# Description: starts the go-fastdfs
### END INIT INFO
PATH=/bin:/sbin:/usr/bin:/usr/sbin:/usr/local/bin:/usr/local/sbin:~/bin
gf_path={$SERVER_PATH}/go-fastdfs
gf_start(){
isStart=`ps -ef| grep -v python|grep -v bash |grep go-fastdfs |grep -v .jar | grep -v grep|awk '{print $2}'`
if [ "$isStart" == '' ];then
echo -e "Starting go-fastdfs... \c"
cd $gf_path
nohup ./go-fastdfs > /dev/null 2>&1 &
echo -e "\033[32mdone\033[0m"
else
echo -e "Starting go-fastdfs(pid $(echo $isStart)) already running"
fi
}
gf_stop()
{
echo -e "Stopping go-fastdfs... \c"
pids=$(ps -ef| grep -v python |grep -v bash |grep go-fastdfs |grep -v .jar | grep -v grep | awk '{print $2}')
arr=($pids)
for p in ${arr[@]}
do
kill -9 $p
done
echo -e "\033[32mdone\033[0m"
}
gf_status()
{
isStart=$(ps -ef | grep -v python | grep -v bash | grep go-fastdfs |grep -v .jar | grep -v grep | awk '{print $2}')
if [ "$isStart" != '' ];then
echo -e "\033[32mgo-fastdfs (pid $(echo $isStart)) already running\033[0m"
else
echo -e "\033[31mgo-fastdfs not running\033[0m"
fi
}
gf_reload()
{
gf_stop
gf_start
}
case "$1" in
'start') gf_start;;
'stop') gf_stop;;
'reload') gf_reload;;
'status') gf_status;;
'restart')
gf_stop
gf_start;;
esac
+75
View File
@@ -0,0 +1,75 @@
#!/bin/bash
PATH=/bin:/sbin:/usr/bin:/usr/sbin:/usr/local/bin:/usr/local/sbin:~/bin
export PATH
curPath=`pwd`
rootPath=$(dirname "$curPath")
rootPath=$(dirname "$rootPath")
serverPath=$(dirname "$rootPath")
sysName=`uname`
install_tmp=${rootPath}/tmp/mw_install.pl
action=$1
version=$2
Install_gf()
{
echo '正在安装脚本文件...' > $install_tmp
mkdir -p $serverPath/go-fastdfs
FF_DIR=${serverPath}/go-fastdfs
cd $FF_DIR
if [ $sysName == 'Darwin' ]; then
FF_SS_DIR=${serverPath}/source/go-fastdfs
mkdir -p $FF_SS_DIR
if [ ! -f $FF_SS_DIR/v1.3.1.tar.gz ]; then
wget -O $FF_SS_DIR/v1.3.1.tar.gz https://github.com/sjqzhang/go-fastdfs/archive/v1.3.1.tar.gz
fi
if [ ! -d $FF_SS_DIR/go-fastdfs-1.3.1 ]; then
cd $FF_SS_DIR && tar -zxvf $FF_SS_DIR/v1.3.1.tar.gz
fi
cd $FF_SS_DIR/go-fastdfs-1.3.1
if [ -d $FF_SS_DIR/go-fastdfs-1.3.1/vendor ];then
mv vendor src
fi
if [ ! -f $FF_SS_DIR/go-fastdfs-1.3.1/fileserver ]; then
pwd=`pwd`
echo "$pwd go build -o fileserver fileserver.go"
GOPATH=$pwd go build -o fileserver fileserver.go
fi
if [ ! -f $FF_DIR/go-fastdfs ];then
cp -f fileserver $FF_DIR/go-fastdfs
cd $FF_DIR
fi
else
cd $FF_DIR
if [ ! -f ${FF_DIR}/fileserver ];then
wget --no-check-certificate https://github.com/sjqzhang/go-fastdfs/releases/download/v1.3.1/fileserver -O fileserver
chmod +x fileserver
fi
fi
echo "$version" > $FF_DIR/version.pl
echo '安装完成' > $install_tmp
}
Uninstall_gf()
{
rm -rf $serverPath/go-fastdfs
echo "卸载完成" > $install_tmp
}
if [ "${1}" == 'install' ];then
Install_gf $version
else
Uninstall_gf $version
fi
+93
View File
@@ -0,0 +1,93 @@
function str2Obj(str){
var data = {};
kv = str.split('&');
for(i in kv){
v = kv[i].split('=');
data[v[0]] = v[1];
}
return data;
}
function pPost(method,args,callback, title){
var _args = null;
if (typeof(args) == 'string'){
_args = JSON.stringify(str2Obj(args));
} else {
_args = JSON.stringify(args);
}
var _title = '正在获取...';
if (typeof(title) != 'undefined'){
_title = title;
}
var loadT = layer.msg(_title, { icon: 16, time: 0, shade: 0.3 });
$.post('/plugins/run', {name:'go-fastdfs', func:method, args:_args}, function(data) {
layer.close(loadT);
if (!data.status){
layer.msg(data.msg,{icon:0,time:2000,shade: [0.3, '#000']});
return;
}
if(typeof(callback) == 'function'){
callback(data);
}
},'json');
}
function gfConfigSet(){
pPost('gf_conf_set', '', function(data){
var rdata = $.parseJSON(data.data);
var mlist = '';
for (var i = 0; i < rdata.length; i++) {
var w = '140';
if (rdata[i].name == 'error_reporting') w = '250';
var ibody = '<input style="width: ' + w + 'px;" class="bt-input-text mr5" name="' + rdata[i].name + '" value="' + rdata[i].value + '" type="text" >';
switch (rdata[i].type) {
case 0:
var selected_1 = (rdata[i].value == 1) ? 'selected' : '';
var selected_0 = (rdata[i].value == 0) ? 'selected' : '';
ibody = '<select class="bt-input-text mr5" name="' + rdata[i].name + '" style="width: ' + w + 'px;">\
<option value="1" ' + selected_1 + '>开启</option>\
<option value="0" ' + selected_0 + '>关闭</option>\
</select>';
break;
case 1:
var selected_1 = (rdata[i].value == 'On') ? 'selected' : '';
var selected_0 = (rdata[i].value == 'Off') ? 'selected' : '';
ibody = '<select class="bt-input-text mr5" name="' + rdata[i].name + '" style="width: ' + w + 'px;">\
<option value="On" ' + selected_1 + '>开启</option>\
<option value="Off" ' + selected_0 + '>关闭</option></select>'
break;
case 2:
var selected_1 = (rdata[i].value == 'true') ? 'selected' : '';
var selected_0 = (rdata[i].value == 'false') ? 'selected' : '';
ibody = '<select class="bt-input-text mr5" name="' + rdata[i].name + '" style="width: ' + w + 'px;">\
<option value="true" ' + selected_1 + '>开启</option>\
<option value="false" ' + selected_0 + '>关闭</option></select>'
break;
}
mlist += '<p><span>' + rdata[i].name + '</span>' + ibody + ', <font>' + rdata[i].ps + '</font></p>'
}
var html = '<style>.conf_p p{margin-bottom: 2px}</style><div class="conf_p" style="margin-bottom:0">\
' + mlist + '\
<div style="margin-top:10px; padding-right:15px" class="text-right">\
</div>';
$(".soft-man-con").html(html);
});
}
function pRead(){
var readme = '<ul class="help-info-text c7">';
readme += '<li>官方地址<a target="_blank" href="https://github.com/sjqzhang/go-fastdfs">查看</a></li>';
readme += '<li>如果开启防火墙,需要放行端口,例如(8080)</li>';
readme += '<li>要自行配置openresty</li>';
readme += '</ul>';
$('.soft-man-con').html(readme);
}
@@ -7,7 +7,7 @@ import sys
sys.path.append("/usr/local/lib/python2.7/site-packages") sys.path.append("/usr/local/lib/python2.7/site-packages")
class mysql: class mysqlDb:
__DB_PASS = None __DB_PASS = None
__DB_USER = 'root' __DB_USER = 'root'
__DB_PORT = 3306 __DB_PORT = 3306
+3 -3
View File
@@ -13,7 +13,7 @@ PATH = data/gogs.db
[repository] [repository]
ROOT = {$ROOT_PATH}/gogs-repositories ROOT = {$ROOT_PATH}/gogs-repositories
FORCE_PRIVATE = false FORCE_PRIVATE = true
[server] [server]
DOMAIN = 127.0.0.1 DOMAIN = 127.0.0.1
@@ -35,9 +35,9 @@ USE_PLAIN_TEXT = true
[service] [service]
REGISTER_EMAIL_CONFIRM = false REGISTER_EMAIL_CONFIRM = false
ENABLE_NOTIFY_MAIL = false ENABLE_NOTIFY_MAIL = false
DISABLE_REGISTRATION = false DISABLE_REGISTRATION = true
ENABLE_CAPTCHA = true ENABLE_CAPTCHA = true
REQUIRE_SIGNIN_VIEW = false REQUIRE_SIGNIN_VIEW = true
[picture] [picture]
DISABLE_GRAVATAR = false DISABLE_GRAVATAR = false
+2
View File
@@ -1,5 +1,7 @@
#!/bin/bash #!/bin/bash
echo `date`
GITADDR="{$GITROOTURL}/{$USERNAME}/{$PROJECT}" GITADDR="{$GITROOTURL}/{$USERNAME}/{$PROJECT}"
GIT_SDIR="{$CODE_DIR}" GIT_SDIR="{$CODE_DIR}"
Binary file not shown.

Before

Width:  |  Height:  |  Size: 1.7 KiB

After

Width:  |  Height:  |  Size: 1.7 KiB

+83 -81
View File
@@ -10,11 +10,11 @@ sys.path.append("/usr/local/lib/python2.7/site-packages")
import psutil import psutil
sys.path.append(os.getcwd() + "/class/core") sys.path.append(os.getcwd() + "/class/core")
import public import mw
app_debug = False app_debug = False
if public.getOs() == 'darwin': if mw.isAppleSystem():
app_debug = True app_debug = True
@@ -23,14 +23,14 @@ def getPluginName():
def getPluginDir(): def getPluginDir():
return public.getPluginDir() + '/' + getPluginName() return mw.getPluginDir() + '/' + getPluginName()
sys.path.append(getPluginDir() + "/class") sys.path.append(getPluginDir() + "/class")
import mysql import mysqlDb
def getServerDir(): def getServerDir():
return public.getServerDir() + '/' + getPluginName() return mw.getServerDir() + '/' + getPluginName()
def getInitDFile(): def getInitDFile():
@@ -77,7 +77,7 @@ def getConfTpl():
def status(): def status():
data = public.execShell( data = mw.execShell(
"ps -ef|grep " + getPluginName() + " |grep -v grep | grep -v python | awk '{print $2}'") "ps -ef|grep " + getPluginName() + " |grep -v grep | grep -v python | awk '{print $2}'")
if data[0] == '': if data[0] == '':
return 'stop' return 'stop'
@@ -85,8 +85,8 @@ def status():
def getHomeDir(): def getHomeDir():
if public.isAppleSystem(): if mw.isAppleSystem():
user = public.execShell( user = mw.execShell(
"who | sed -n '2, 1p' |awk '{print $1}'")[0].strip() "who | sed -n '2, 1p' |awk '{print $1}'")[0].strip()
return '/Users/' + user return '/Users/' + user
else: else:
@@ -94,8 +94,8 @@ def getHomeDir():
def getRunUser(): def getRunUser():
if public.isAppleSystem(): if mw.isAppleSystem():
user = public.execShell( user = mw.execShell(
"who | sed -n '2, 1p' |awk '{print $1}'")[0].strip() "who | sed -n '2, 1p' |awk '{print $1}'")[0].strip()
return user return user
else: else:
@@ -110,8 +110,8 @@ export HOME=%s && ''' % ( getRunUser(), getHomeDir())
def contentReplace(content): def contentReplace(content):
service_path = public.getServerDir() service_path = mw.getServerDir()
content = content.replace('{$ROOT_PATH}', public.getRootDir()) content = content.replace('{$ROOT_PATH}', mw.getRootDir())
content = content.replace('{$SERVER_PATH}', service_path) content = content.replace('{$SERVER_PATH}', service_path)
content = content.replace('{$RUN_USER}', getRunUser()) content = content.replace('{$RUN_USER}', getRunUser())
content = content.replace('{$HOME_DIR}', getHomeDir()) content = content.replace('{$HOME_DIR}', getHomeDir())
@@ -122,7 +122,7 @@ def contentReplace(content):
def initDreplace(): def initDreplace():
file_tpl = getInitdConfTpl() file_tpl = getInitdConfTpl()
service_path = public.getServerDir() service_path = mw.getServerDir()
initD_path = getServerDir() + '/init.d' initD_path = getServerDir() + '/init.d'
if not os.path.exists(initD_path): if not os.path.exists(initD_path):
@@ -130,18 +130,18 @@ def initDreplace():
file_bin = initD_path + '/' + getPluginName() file_bin = initD_path + '/' + getPluginName()
if not os.path.exists(file_bin): if not os.path.exists(file_bin):
content = public.readFile(file_tpl) content = mw.readFile(file_tpl)
content = contentReplace(content) content = contentReplace(content)
public.writeFile(file_bin, content) mw.writeFile(file_bin, content)
public.execShell('chmod +x ' + file_bin) mw.execShell('chmod +x ' + file_bin)
conf_bin = getConf() conf_bin = getConf()
if not os.path.exists(conf_bin): if not os.path.exists(conf_bin):
public.execShell('mkdir -p ' + getServerDir() + '/custom/conf') mw.execShell('mkdir -p ' + getServerDir() + '/custom/conf')
conf_tpl = getConfTpl() conf_tpl = getConfTpl()
content = public.readFile(conf_tpl) content = mw.readFile(conf_tpl)
content = contentReplace(content) content = contentReplace(content)
public.writeFile(conf_bin, content) mw.writeFile(conf_bin, content)
log_path = getServerDir() + '/log' log_path = getServerDir() + '/log'
if not os.path.exists(log_path): if not os.path.exists(log_path):
@@ -151,7 +151,7 @@ def initDreplace():
def getRootUrl(): def getRootUrl():
content = public.readFile(getConf()) content = mw.readFile(getConf())
rep = 'ROOT_URL\s*=\s*(.*)' rep = 'ROOT_URL\s*=\s*(.*)'
tmp = re.search(rep, content) tmp = re.search(rep, content)
if not tmp: if not tmp:
@@ -160,7 +160,7 @@ def getRootUrl():
def getSshPort(): def getSshPort():
content = public.readFile(getConf()) content = mw.readFile(getConf())
rep = 'SSH_PORT\s*=\s*(.*)' rep = 'SSH_PORT\s*=\s*(.*)'
tmp = re.search(rep, content) tmp = re.search(rep, content)
if not tmp: if not tmp:
@@ -169,7 +169,7 @@ def getSshPort():
def getRootPath(): def getRootPath():
content = public.readFile(getConf()) content = mw.readFile(getConf())
rep = 'ROOT\s*=\s*(.*)' rep = 'ROOT\s*=\s*(.*)'
tmp = re.search(rep, content) tmp = re.search(rep, content)
if not tmp: if not tmp:
@@ -178,7 +178,7 @@ def getRootPath():
def getDbConfValue(): def getDbConfValue():
content = public.readFile(getConf()) content = mw.readFile(getConf())
rep_scope = "\[database\](.*?)\[" rep_scope = "\[database\](.*?)\["
tmp = re.findall(rep_scope, content, re.S) tmp = re.findall(rep_scope, content, re.S)
@@ -197,7 +197,7 @@ def pMysqlDb():
conf = getDbConfValue() conf = getDbConfValue()
host = conf['HOST'].split(':') host = conf['HOST'].split(':')
conn = mysql.mysql() conn = mysqlDb.mysqlDb()
conn.setHost(host[0]) conn.setHost(host[0])
conn.setUser(conf['USER']) conn.setUser(conf['USER'])
@@ -212,22 +212,22 @@ def isSqlError(mysqlMsg):
_mysqlMsg = str(mysqlMsg) _mysqlMsg = str(mysqlMsg)
# print _mysqlMsg # print _mysqlMsg
if "MySQLdb" in _mysqlMsg: if "MySQLdb" in _mysqlMsg:
return public.returnData(False, 'MySQLdb组件缺失! <br>进入SSH命令行输入: pip install mysql-python') return mw.returnData(False, 'MySQLdb组件缺失! <br>进入SSH命令行输入: pip install mysql-python')
if "2002," in _mysqlMsg: if "2002," in _mysqlMsg:
return public.returnData(False, '数据库连接失败,请检查数据库服务是否启动!') return mw.returnData(False, '数据库连接失败,请检查数据库服务是否启动!')
if "using password:" in _mysqlMsg: if "using password:" in _mysqlMsg:
return public.returnData(False, '数据库管理密码错误!') return mw.returnData(False, '数据库管理密码错误!')
if "Connection refused" in _mysqlMsg: if "Connection refused" in _mysqlMsg:
return public.returnData(False, '数据库连接失败,请检查数据库服务是否启动!') return mw.returnData(False, '数据库连接失败,请检查数据库服务是否启动!')
if "1133," in _mysqlMsg: if "1133," in _mysqlMsg:
return public.returnData(False, '数据库用户不存在!') return mw.returnData(False, '数据库用户不存在!')
if "1007," in _mysqlMsg: if "1007," in _mysqlMsg:
return public.returnData(False, '数据库已经存在!') return mw.returnData(False, '数据库已经存在!')
if "1044," in _mysqlMsg: if "1044," in _mysqlMsg:
return public.returnData(False, mysqlMsg[1]) return mw.returnData(False, mysqlMsg[1])
if "2003," in _mysqlMsg: if "2003," in _mysqlMsg:
return public.returnData(False, mysqlMsg[1]) return mw.returnData(False, mysqlMsg[1])
return public.returnData(True, 'OK') return mw.returnData(True, 'OK')
def start(): def start():
@@ -248,7 +248,7 @@ def start():
if not data['status']: if not data['status']:
return data['msg'] return data['msg']
data = public.execShell(__SR + file + ' start') data = mw.execShell(__SR + file + ' start')
if data[1] == '': if data[1] == '':
return 'ok' return 'ok'
return data[0] return data[0]
@@ -256,7 +256,7 @@ def start():
def stop(): def stop():
file = initDreplace() file = initDreplace()
data = public.execShell(__SR + file + ' stop') data = mw.execShell(__SR + file + ' stop')
if data[1] == '': if data[1] == '':
return 'ok' return 'ok'
return data[1] return data[1]
@@ -264,7 +264,7 @@ def stop():
def restart(): def restart():
file = initDreplace() file = initDreplace()
data = public.execShell(__SR + file + ' restart') data = mw.execShell(__SR + file + ' restart')
if data[1] == '': if data[1] == '':
return 'ok' return 'ok'
return data[1] return data[1]
@@ -272,7 +272,7 @@ def restart():
def reload(): def reload():
file = initDreplace() file = initDreplace()
data = public.execShell(__SR + file + ' reload') data = mw.execShell(__SR + file + ' reload')
if data[1] == '': if data[1] == '':
return 'ok' return 'ok'
return data[1] return data[1]
@@ -280,7 +280,7 @@ def reload():
def initdStatus(): def initdStatus():
if not app_debug: if not app_debug:
os_name = public.getOs() os_name = mw.getOs()
if os_name == 'darwin': if os_name == 'darwin':
return "Apple Computer does not support" return "Apple Computer does not support"
initd_bin = getInitDFile() initd_bin = getInitDFile()
@@ -292,24 +292,26 @@ def initdStatus():
def initdInstall(): def initdInstall():
import shutil import shutil
if not app_debug: if not app_debug:
os_name = public.getOs() os_name = mw.getOs()
if os_name == 'darwin': if os_name == 'darwin':
return "Apple Computer does not support" return "Apple Computer does not support"
mem_bin = initDreplace() mem_bin = initDreplace()
initd_bin = getInitDFile() initd_bin = getInitDFile()
shutil.copyfile(mem_bin, initd_bin) shutil.copyfile(mem_bin, initd_bin)
public.execShell('chmod +x ' + initd_bin) mw.execShell('chmod +x ' + initd_bin)
mw.execShell('chkconfig --add ' + getPluginName())
return 'ok' return 'ok'
def initdUinstall(): def initdUinstall():
if not app_debug: if not app_debug:
os_name = public.getOs() os_name = mw.getOs()
if os_name == 'darwin': if os_name == 'darwin':
return "Apple Computer does not support" return "Apple Computer does not support"
initd_bin = getInitDFile() initd_bin = getInitDFile()
os.remove(initd_bin) os.remove(initd_bin)
mw.execShell('chkconfig --del ' + getPluginName())
return 'ok' return 'ok'
@@ -344,7 +346,7 @@ def getGogsConf():
{'name': 'SHOW_FOOTER_VERSION', 'type': 2, 'ps': 'Gogs版本信息'}, {'name': 'SHOW_FOOTER_VERSION', 'type': 2, 'ps': 'Gogs版本信息'},
{'name': 'SHOW_FOOTER_TEMPLATE_LOAD_TIME', 'type': 2, 'ps': 'Gogs模板加载时间'}, {'name': 'SHOW_FOOTER_TEMPLATE_LOAD_TIME', 'type': 2, 'ps': 'Gogs模板加载时间'},
] ]
conf = public.readFile(getConf()) conf = mw.readFile(getConf())
result = [] result = []
for g in gets: for g in gets:
@@ -354,7 +356,7 @@ def getGogsConf():
continue continue
g['value'] = tmp.groups()[0] g['value'] = tmp.groups()[0]
result.append(g) result.append(g)
return public.getJson(result) return mw.getJson(result)
def submitGogsConf(): def submitGogsConf():
@@ -374,15 +376,15 @@ def submitGogsConf():
'SHOW_FOOTER_TEMPLATE_LOAD_TIME'] 'SHOW_FOOTER_TEMPLATE_LOAD_TIME']
args = getArgs() args = getArgs()
filename = getConf() filename = getConf()
conf = public.readFile(filename) conf = mw.readFile(filename)
for g in gets: for g in gets:
if g in args: if g in args:
rep = g + '\s*=\s*(.*)' rep = g + '\s*=\s*(.*)'
val = g + ' = ' + args[g] val = g + ' = ' + args[g]
conf = re.sub(rep, val, conf) conf = re.sub(rep, val, conf)
public.writeFile(filename, conf) mw.writeFile(filename, conf)
reload() reload()
return public.returnJson(True, '设置成功') return mw.returnJson(True, '设置成功')
def userList(): def userList():
@@ -415,12 +417,12 @@ def userList():
page_info = {'count': count, 'p': page, page_info = {'count': count, 'p': page,
'row': page_size, 'tojs': 'gogsUserList'} 'row': page_size, 'tojs': 'gogsUserList'}
data['list'] = public.getPage(page_info) data['list'] = mw.getPage(page_info)
data['page'] = page data['page'] = page
data['page_size'] = page_size data['page_size'] = page_size
data['page_count'] = int(math.ceil(count / page_size)) data['page_count'] = int(math.ceil(count / page_size))
data['data'] = list_data data['data'] = list_data
return public.returnJson(True, 'OK', data) return mw.returnJson(True, 'OK', data)
def getAllUserProject(user, search=''): def getAllUserProject(user, search=''):
@@ -463,7 +465,7 @@ def userProjectList():
search = '' search = ''
if not 'name' in args: if not 'name' in args:
return public.returnJson(False, '缺少参数name') return mw.returnJson(False, '缺少参数name')
if 'page' in args: if 'page' in args:
page = int(args['page']) page = int(args['page'])
@@ -485,38 +487,38 @@ def userProjectList():
data['root_url'] = getRootUrl() data['root_url'] = getRootUrl()
data['data'] = ret_data data['data'] = ret_data
data['args'] = args data['args'] = args
data['list'] = public.getPage( data['list'] = mw.getPage(
{'count': dlist_sum, 'p': page, 'row': page_size, 'tojs': 'userProjectList'}) {'count': dlist_sum, 'p': page, 'row': page_size, 'tojs': 'userProjectList'})
return public.returnJson(True, 'OK', data) return mw.returnJson(True, 'OK', data)
def projectScriptEdit(): def projectScriptEdit():
args = getArgs() args = getArgs()
if not 'user' in args: if not 'user' in args:
return public.returnJson(True, 'username missing') return mw.returnJson(True, 'username missing')
if not 'name' in args: if not 'name' in args:
return public.returnJson(True, 'project name missing') return mw.returnJson(True, 'project name missing')
user = args['user'] user = args['user']
name = args['name'] + '.git' name = args['name'] + '.git'
post_receive = getRootPath() + '/' + user + '/' + name + \ post_receive = getRootPath() + '/' + user + '/' + name + \
'/custom_hooks/post-receive' '/custom_hooks/commit'
if os.path.exists(post_receive): if os.path.exists(post_receive):
return public.returnJson(True, 'OK', {'path': post_receive}) return mw.returnJson(True, 'OK', {'path': post_receive})
else: else:
return public.returnJson(False, 'file does not exist') return mw.returnJson(False, 'file does not exist')
def projectScriptLoad(): def projectScriptLoad():
args = getArgs() args = getArgs()
if not 'user' in args: if not 'user' in args:
return public.returnJson(True, 'username missing') return mw.returnJson(True, 'username missing')
if not 'name' in args: if not 'name' in args:
return public.returnJson(True, 'project name missing') return mw.returnJson(True, 'project name missing')
user = args['user'] user = args['user']
name = args['name'] + '.git' name = args['name'] + '.git'
@@ -526,28 +528,28 @@ def projectScriptLoad():
post_receive = path + '/custom_hooks/post-receive' post_receive = path + '/custom_hooks/post-receive'
if not os.path.exists(path + '/custom_hooks'): if not os.path.exists(path + '/custom_hooks'):
public.execShell('mkdir -p ' + path + '/custom_hooks') mw.execShell('mkdir -p ' + path + '/custom_hooks')
pct_content = public.readFile(post_receive_tpl) pct_content = mw.readFile(post_receive_tpl)
pct_content = pct_content.replace('{$PATH}', path + '/custom_hooks') pct_content = pct_content.replace('{$PATH}', path + '/custom_hooks')
public.writeFile(post_receive, pct_content) mw.writeFile(post_receive, pct_content)
public.execShell('chmod 777 ' + post_receive) mw.execShell('chmod 777 ' + post_receive)
commit_tpl = getPluginDir() + '/hook/commit.tpl' commit_tpl = getPluginDir() + '/hook/commit.tpl'
commit = path + '/custom_hooks/commit' commit = path + '/custom_hooks/commit'
codeDir = public.getRootDir() + '/git' codeDir = mw.getRootDir() + '/git'
cc_content = public.readFile(commit_tpl) cc_content = mw.readFile(commit_tpl)
sshUrl = 'ssh://127.0.0.1:' + getSshPort() sshUrl = 'ssh://127.0.0.1:' + getSshPort()
cc_content = cc_content.replace('{$GITROOTURL}', sshUrl) cc_content = cc_content.replace('{$GITROOTURL}', sshUrl)
cc_content = cc_content.replace('{$CODE_DIR}', codeDir) cc_content = cc_content.replace('{$CODE_DIR}', codeDir)
cc_content = cc_content.replace('{$USERNAME}', user) cc_content = cc_content.replace('{$USERNAME}', user)
cc_content = cc_content.replace('{$PROJECT}', args['name']) cc_content = cc_content.replace('{$PROJECT}', args['name'])
cc_content = cc_content.replace('{$WEB_ROOT}', public.getWwwDir()) cc_content = cc_content.replace('{$WEB_ROOT}', mw.getWwwDir())
public.writeFile(commit, cc_content) mw.writeFile(commit, cc_content)
public.execShell('chmod 777 ' + commit) mw.execShell('chmod 777 ' + commit)
return 'ok' return 'ok'
@@ -555,31 +557,31 @@ def projectScriptLoad():
def projectScriptUnload(): def projectScriptUnload():
args = getArgs() args = getArgs()
if not 'user' in args: if not 'user' in args:
return public.returnJson(True, 'username missing') return mw.returnJson(True, 'username missing')
if not 'name' in args: if not 'name' in args:
return public.returnJson(True, 'project name missing') return mw.returnJson(True, 'project name missing')
user = args['user'] user = args['user']
name = args['name'] + '.git' name = args['name'] + '.git'
post_receive = getRootPath() + '/' + user + '/' + name + \ post_receive = getRootPath() + '/' + user + '/' + name + \
'/custom_hooks/post-receive' '/custom_hooks/post-receive'
public.execShell('rm -f ' + post_receive) mw.execShell('rm -f ' + post_receive)
commit = getRootPath() + '/' + user + '/' + name + \ commit = getRootPath() + '/' + user + '/' + name + \
'/custom_hooks/commit' '/custom_hooks/commit'
public.execShell('rm -f ' + commit) mw.execShell('rm -f ' + commit)
return 'ok' return 'ok'
def projectScriptDebug(): def projectScriptDebug():
args = getArgs() args = getArgs()
if not 'user' in args: if not 'user' in args:
return public.returnJson(True, 'username missing') return mw.returnJson(True, 'username missing')
if not 'name' in args: if not 'name' in args:
return public.returnJson(True, 'project name missing') return mw.returnJson(True, 'project name missing')
user = args['user'] user = args['user']
name = args['name'] + '.git' name = args['name'] + '.git'
commit_log = getRootPath() + '/' + user + '/' + name + \ commit_log = getRootPath() + '/' + user + '/' + name + \
@@ -593,25 +595,25 @@ def projectScriptDebug():
data['status'] = False data['status'] = False
data['msg'] = '没有日志文件' data['msg'] = '没有日志文件'
return public.getJson(data) return mw.getJson(data)
def gogsEdit(): def gogsEdit():
data = {} data = {}
data['post_receive'] = getPluginDir() + '/hook/post-receive.tpl' data['post_receive'] = getPluginDir() + '/hook/post-receive.tpl'
data['commit'] = getPluginDir() + '/hook/commit.tpl' data['commit'] = getPluginDir() + '/hook/commit.tpl'
return public.getJson(data) return mw.getJson(data)
def getRsaPublic(): def getRsaPublic():
path = getHomeDir() path = getHomeDir()
path += '/.ssh/id_rsa.pub' path += '/.ssh/id_rsa.pub'
content = public.readFile(path) content = mw.readFile(path)
data = {} data = {}
data['public'] = content data['mw'] = content
return public.getJson(data) return mw.getJson(data)
def getTotalStatistics(): def getTotalStatistics():
@@ -624,12 +626,12 @@ def getTotalStatistics():
data['status'] = True data['status'] = True
data['count'] = count data['count'] = count
data['ver'] = public.readFile(getServerDir() + '/version.pl').strip() data['ver'] = mw.readFile(getServerDir() + '/version.pl').strip()
return public.returnJson(True, 'ok', data) return mw.returnJson(True, 'ok', data)
else: else:
data['status'] = False data['status'] = False
data['count'] = 0 data['count'] = 0
return public.returnJson(False, 'fail', data) return mw.returnJson(False, 'fail', data)
if __name__ == "__main__": if __name__ == "__main__":
+2 -1
View File
@@ -2,9 +2,10 @@
"ps": "Gogs是一款极易搭建的自助Git服务", "ps": "Gogs是一款极易搭建的自助Git服务",
"name": "gogs", "name": "gogs",
"title": "Gogs", "title": "Gogs",
"versions": ["0.11.86","0.11.79"], "versions": ["0.11.86"],
"tip": "soft", "tip": "soft",
"checks": "server/gogs", "checks": "server/gogs",
"path":"server/gogs",
"author": "midoks", "author": "midoks",
"date": "201-04-01", "date": "201-04-01",
"home": "https://gogs.io", "home": "https://gogs.io",
+2 -1
View File
@@ -30,7 +30,8 @@ if [ -f /etc/rc.d/init.d/functions ];then
fi fi
# Default values # Default values
HOME={$HOME_DIR} export HOME={$HOME_DIR}
export USER={$RUN_USER}
NAME=gogs NAME=gogs
GOGS_HOME={$SERVER_PATH}/gogs GOGS_HOME={$SERVER_PATH}/gogs
GOGS_PATH=${GOGS_HOME}/$NAME GOGS_PATH=${GOGS_HOME}/$NAME
+1 -1
View File
@@ -227,7 +227,7 @@ function userProjectList(user, search){
var loadOpen = layer.open({ var loadOpen = layer.open({
type: 1, type: 1,
title: '用户('+user+')项目列表', title: '用户('+user+')项目列表',
area: '300px', area: '500px',
content:"<div class='bt-form pd20 c6'>\ content:"<div class='bt-form pd20 c6'>\
<div>\ <div>\
<div class='divtable' style='margin-top:5px;'>\ <div class='divtable' style='margin-top:5px;'>\
Binary file not shown.

After

Width:  |  Height:  |  Size: 17 KiB

+20
View File
@@ -0,0 +1,20 @@
<div class="bt-form">
<div class="bt-w-main">
<div class="bt-w-menu">
<p class="bgw" onclick="pluginService('jenkins');">服务</p>
<p onclick="pluginInitD('jenkins');">自启动</p>
<p onclick="pluginLogs('jenkins','','run_log');">日志</p>
<p onclick="pRead()">说明</p>
</div>
<div class="bt-w-con pd15">
<div class="soft-man-con"></div>
</div>
</div>
</div>
<script type="text/javascript">
resetPluginWinWidth(700);
$.getScript( "/plugins/file?name=jenkins&f=js/jenkins.js", function() {
pluginService('walle');
});
</script>
+154
View File
@@ -0,0 +1,154 @@
# coding: utf-8
import time
import random
import os
import json
import re
import sys
import subprocess
sys.path.append(os.getcwd() + "/class/core")
import mw
app_debug = False
if mw.isAppleSystem():
app_debug = True
def getPluginName():
return 'jenkins'
def getPluginDir():
return mw.getPluginDir() + '/' + getPluginName()
def getServerDir():
return mw.getServerDir() + '/' + getPluginName()
def getInitDFile():
if app_debug:
return '/tmp/' + getPluginName()
return '/etc/init.d/' + getPluginName()
def getInitDTpl():
return getPluginDir() + "/init.d/" + getPluginName() + ".tpl"
def getLog():
return "/var/log/jenkins/jenkins.log"
def getArgs():
args = sys.argv[2:]
tmp = {}
args_len = len(args)
if args_len == 1:
t = args[0].strip('{').strip('}')
t = t.split(':')
tmp[t[0]] = t[1]
elif args_len > 1:
for i in range(len(args)):
t = args[i].split(':')
tmp[t[0]] = t[1]
return tmp
def checkArgs(data, ck=[]):
for i in range(len(ck)):
if not ck[i] in data:
return (False, mw.returnJson(False, '参数:(' + ck[i] + ')没有!'))
return (True, mw.returnJson(True, 'ok'))
def status():
pn = getPluginName()
cmd = "ps -ef|grep 'jenkins.war' | grep -v grep | awk '{print $2}'"
data = mw.execShell(cmd)
if data[0] == '':
return 'stop'
return 'start'
def start():
if mw.isAppleSystem():
return "Apple Computer does not support"
data = mw.execShell('service jenkins start')
if data[1] == '':
return 'ok'
return 'fail'
def stop():
if mw.isAppleSystem():
return "Apple Computer does not support"
data = mw.execShell('service jenkins stop')
if data[1] == '':
return 'ok'
return 'fail'
def restart():
data = mw.execShell('service jenkins restart')
if data[1] == '':
return 'ok'
return 'fail'
def reload():
data = mw.execShell('service jenkins restart')
if data[1] == '':
return 'ok'
return 'fail'
def initdStatus():
initd_bin = getInitDFile()
if os.path.exists(initd_bin):
return 'ok'
return 'fail'
def initdInstall():
if not app_debug:
mw.execShell('chkconfig --add ' + getPluginName())
return 'ok'
def initdUinstall():
if not app_debug:
mw.execShell('chkconfig --del ' + getPluginName())
return 'ok'
# rsyncdReceive
if __name__ == "__main__":
func = sys.argv[1]
if func == 'status':
print status()
elif func == 'start':
print start()
elif func == 'stop':
print stop()
elif func == 'restart':
print restart()
elif func == 'reload':
print reload()
elif func == 'initd_status':
print initdStatus()
elif func == 'initd_install':
print initdInstall()
elif func == 'initd_uninstall':
print initdUinstall()
elif func == 'run_log':
print getLog()
else:
print 'error'
+16
View File
@@ -0,0 +1,16 @@
{
"id":13,
"title":"jenkins",
"tip":"soft",
"name":"jenkins",
"type":"扩展",
"ps":"开源CI&CD软件领导者",
"versions":"1.0",
"shell":"install.sh",
"checks":"server/jenkins",
"path": "server/jenkins",
"author":"midoks",
"home":"https://jenkins.io/zh/",
"date":"2019-12-06",
"pid":"3"
}
+43
View File
@@ -0,0 +1,43 @@
#!/bin/bash
PATH=/bin:/sbin:/usr/bin:/usr/sbin:/usr/local/bin:/usr/local/sbin:~/bin
export PATH
curPath=`pwd`
rootPath=$(dirname "$curPath")
rootPath=$(dirname "$rootPath")
serverPath=$(dirname "$rootPath")
install_tmp=${rootPath}/tmp/mw_install.pl
sysName=`uname`
Install_walle()
{
echo '正在安装脚本文件...' > $install_tmp
mkdir -p $serverPath/jenkins
echo '1.0' > $serverPath/jenkins/version.pl
if [ $sysName == 'Darwin' ]; then
echo "jenkins mac no install!"
else
wget -O /etc/yum.repos.d/jenkins.repo https://pkg.jenkins.io/redhat-stable/jenkins.repo
rpm --import https://pkg.jenkins.io/redhat-stable/jenkins.io.key
yum -y install jenkins
fi
echo '安装完成' > $install_tmp
}
Uninstall_walle()
{
rm -rf $serverPath/jenkins
echo "卸载完成" > $install_tmp
}
action=$1
if [ "${1}" == 'install' ];then
Install_walle
else
Uninstall_walle
fi
+74
View File
@@ -0,0 +1,74 @@
function str2Obj(str){
var data = {};
kv = str.split('&');
for(i in kv){
v = kv[i].split('=');
data[v[0]] = v[1];
}
return data;
}
function pPost(method,args,callback, title){
var _args = null;
if (typeof(args) == 'string'){
_args = JSON.stringify(str2Obj(args));
} else {
_args = JSON.stringify(args);
}
var _title = '正在获取...';
if (typeof(title) != 'undefined'){
_title = title;
}
var loadT = layer.msg(_title, { icon: 16, time: 0, shade: 0.3 });
$.post('/plugins/run', {name:'walle', func:method, args:_args}, function(data) {
layer.close(loadT);
if (!data.status){
layer.msg(data.msg,{icon:0,time:2000,shade: [0.3, '#000']});
return;
}
if(typeof(callback) == 'function'){
callback(data);
}
},'json');
}
function pPostCallbak(method, version, args,callback){
var loadT = layer.msg('正在获取...', { icon: 16, time: 0, shade: 0.3 });
var req_data = {};
req_data['name'] = 'walle';
req_data['func'] = method;
args['version'] = version;
if (typeof(args) == 'string'){
req_data['args'] = JSON.stringify(str2Obj(args));
} else {
req_data['args'] = JSON.stringify(args);
}
$.post('/plugins/callback', req_data, function(data) {
layer.close(loadT);
if (!data.status){
layer.msg(data.msg,{icon:0,time:2000,shade: [0.3, '#000']});
return;
}
if(typeof(callback) == 'function'){
callback(data);
}
},'json');
}
function pRead(){
var readme = '<ul class="help-info-text c7">';
readme += '<li>修改配置正确后:</li>';
readme += '<li>手动[初始化环境]:cat /var/lib/jenkins/secrets/initialAdminPassword</li>';
readme += '<li><a target="_blank" href="https://jenkins.io/zh/doc/">官方文档</a></li>';
readme += '</ul>';
$('.soft-man-con').html(readme);
}
+21
View File
@@ -0,0 +1,21 @@
MIT License
Copyright (c) 2019 Mr Chen
Permission is hereby granted, free of charge, to any person obtaining a copy
of this software and associated documentation files (the "Software"), to deal
in the Software without restriction, including without limitation the rights
to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
copies of the Software, and to permit persons to whom the Software is
furnished to do so, subject to the following conditions:
The above copyright notice and this permission notice shall be included in all
copies or substantial portions of the Software.
THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
SOFTWARE.
Binary file not shown.

After

Width:  |  Height:  |  Size: 2.4 KiB

+19
View File
@@ -0,0 +1,19 @@
<div class="bt-form">
<div class="bt-w-main">
<div class="bt-w-menu">
<p class="bgw" onclick="pluginService('l2tp');">服务</p>
<p onclick="pluginConfig('l2tp',null, 'conf');">用户配置</p>
<p onclick="pluginConfig('l2tp',null, 'conf_psk');">PSK配置</p>
<p onclick="userList();">用户列表</p>
<p onclick="readme();">说明</p>
</div>
<div class="bt-w-con pd15">
<div class="soft-man-con"></div>
</div>
</div>
</div>
<script type="text/javascript">
$.getScript( "/plugins/file?name=l2tp&f=js/l2tp.js", function(){
pluginService('l2tp');
});
</script>
+233
View File
@@ -0,0 +1,233 @@
# coding:utf-8
import sys
import io
import os
import time
import shutil
sys.path.append(os.getcwd() + "/class/core")
import mw
app_debug = False
if mw.isAppleSystem():
app_debug = True
def getPluginName():
return 'l2tp'
def getPluginDir():
return mw.getPluginDir() + '/' + getPluginName()
def getServerDir():
return mw.getServerDir() + '/' + getPluginName()
def getArgs():
args = sys.argv[2:]
tmp = {}
args_len = len(args)
if args_len == 1:
t = args[0].strip('{').strip('}')
t = t.split(':')
tmp[t[0]] = t[1]
elif args_len > 1:
for i in range(len(args)):
t = args[i].split(':')
tmp[t[0]] = t[1]
return tmp
def checkArgs(data, ck=[]):
for i in range(len(ck)):
if not ck[i] in data:
return (False, mw.returnJson(False, '参数:(' + ck[i] + ')没有!'))
return (True, mw.returnJson(True, 'ok'))
def status():
cmd = "ps -ef|grep xl2tpd |grep -v grep | grep -v python | awk '{print $2}'"
data = mw.execShell(cmd)
if data[0] == '':
return 'stop'
return 'start'
def initConf():
l2tp_cs = getServerDir() + '/chap-secrets'
if not os.path.exists(l2tp_cs):
mw.execShell('cp -rf ' + getPluginDir() +
'/tmp/chap-secrets' + ' ' + getServerDir())
l2tp_is = getServerDir() + '/ipsec.secrets'
if not os.path.exists(l2tp_is):
mw.execShell('cp -rf ' + getPluginDir() +
'/tmp/ipsec.secrets' + ' ' + getServerDir())
def start():
initConf()
if mw.isAppleSystem():
return "Apple Computer does not support"
data = mw.execShell('service xl2tpd start')
if data[0] == '':
return 'ok'
return data[1]
def stop():
if mw.isAppleSystem():
return "Apple Computer does not support"
data = mw.execShell('service xl2tpd stop')
if data[0] == '':
return 'ok'
return data[1]
def restart():
if mw.isAppleSystem():
return "Apple Computer does not support"
data = mw.execShell('service xl2tpd restart')
if data[0] == '':
return 'ok'
return data[1]
def reload():
data = mw.execShell('service xl2tpd reload')
if data[0] == '':
return 'ok'
return data[1]
def getPathFile():
if mw.isAppleSystem():
return getServerDir() + '/chap-secrets'
return '/etc/ppp/chap-secrets'
def getPathFilePsk():
if mw.isAppleSystem():
return getServerDir() + '/ipsec.secrets'
return '/etc/ipsec.secrets'
def getUserList():
import re
path = getPathFile()
if not os.path.exists(path):
return mw.returnJson(False, '密码配置文件不存在!')
conf = mw.readFile(path)
conf = re.sub('#(.*)\n', '', conf)
if conf.strip() == '':
return mw.returnJson(True, 'ok', [])
ulist = conf.strip().split('\n')
user = []
for line in ulist:
line_info = {}
line = re.match(r'(\w*)\s*(\w*)\s*(\w*)\s*(.*)',
line.strip(), re.M | re.I).groups()
line_info['user'] = line[0]
line_info['pwd'] = line[2]
line_info['type'] = line[1]
line_info['ip'] = line[3]
user.append(line_info)
return mw.returnJson(True, 'ok', user)
def addUser():
if mw.isAppleSystem():
return mw.returnJson(False, "Apple Computer does not support")
args = getArgs()
data = checkArgs(args, ['username'])
if not data[0]:
return data[1]
ret = mw.execShell('echo ' + args['username'] + '|l2tp -a')
if ret[1] == '':
return mw.returnJson(True, '添加成功!:' + ret[0])
return mw.returnJson(False, '添加失败:' + ret[0])
def delUser():
if mw.isAppleSystem():
return mw.returnJson(False, "Apple Computer does not support")
args = getArgs()
data = checkArgs(args, ['username'])
if not data[0]:
return data[1]
ret = mw.execShell('echo ' + args['username'] + '|l2tp -d')
if ret[1] == '':
return mw.returnJson(True, '删除成功!:' + ret[0])
return mw.returnJson(False, '删除失败:' + ret[0])
def modUser():
args = getArgs()
data = checkArgs(args, ['username', 'password'])
if not data[0]:
return data[1]
path = getPathFile()
username = args['username']
password = args['password']
# sed -i "/^\<${user}\>/d" /etc/ppp/chap-secrets
# echo "${user} l2tpd ${pass} *" >> /etc/ppp/chap-secrets
if mw.isAppleSystem():
mw.execShell("sed -i .bak '/^\(" + username + "\)/d' " + path)
else:
mw.execShell("sed -i '/^\(" + username + "\)/d' " + path)
# print 'echo "' + username + " l2tpd " + password + " *\" >>"
# + path
ret = mw.execShell("echo \"" + username +
" l2tpd " + password + " *\" >>" + path)
if ret[1] == '':
return mw.returnJson(True, '修改成功!')
return mw.returnJson(False, '修改失败')
if __name__ == "__main__":
func = sys.argv[1]
if func == 'status':
print status()
elif func == 'start':
print start()
elif func == 'stop':
print stop()
elif func == 'restart':
print restart()
elif func == 'reload':
print reload()
elif func == 'conf':
print getPathFile()
elif func == 'conf_psk':
print getPathFilePsk()
elif func == 'user_list':
print getUserList()
elif func == 'add_user':
print addUser()
elif func == 'del_user':
print delUser()
elif func == 'mod_user':
print modUser()
else:
print 'error'
+14
View File
@@ -0,0 +1,14 @@
{
"title":"L2TP",
"tip":"soft",
"name":"l2tp",
"type":"运行环境",
"ps":"VPN网关",
"versions":"1.0",
"shell":"install.sh",
"checks":"server/l2tp",
"author":"teddysun",
"home":"https://github.com/teddysun/across/blob/master/l2tp.sh",
"date":"2019-02-27",
"pid": "4"
}
+46
View File
@@ -0,0 +1,46 @@
#!/bin/bash
PATH=/bin:/sbin:/usr/bin:/usr/sbin:/usr/local/bin:/usr/local/sbin:~/bin
export PATH
curPath=`pwd`
rootPath=$(dirname "$curPath")
rootPath=$(dirname "$rootPath")
serverPath=$(dirname "$rootPath")
install_tmp=${rootPath}/tmp/mw_install.pl
SYSOS=`uname`
Install_l2tp()
{
isStart=""
echo '正在安装脚本文件...' > $install_tmp
mkdir -p $serverPath/l2tp
echo '1.0' > $serverPath/l2tp/version.pl
cp -rf scripts/l2tp.sh $serverPath/l2tp
chmod +x $serverPath/l2tp/l2tp.sh
if [ "Darwin" == "$SYSOS" ];then
echo 'macosx unavailable' > $install_tmp
exit 0
fi
/bin/sh $serverPath/l2tp/l2tp.sh
echo 'install complete' > $install_tmp
}
Uninstall_l2tp()
{
rm -rf $serverPath/l2tp
echo "Uninstall completed" > $install_tmp
}
action=$1
if [ "${1}" == 'install' ];then
Install_l2tp
else
Uninstall_l2tp
fi
+158
View File
@@ -0,0 +1,158 @@
function str2Obj(str){
var data = {};
kv = str.split('&');
for(i in kv){
v = kv[i].split('=');
data[v[0]] = v[1];
}
return data;
}
function lpPost(method,args,callback, title){
var _args = null;
if (typeof(args) == 'string'){
_args = JSON.stringify(str2Obj(args));
} else {
_args = JSON.stringify(args);
}
var _title = '正在获取...';
if (typeof(title) != 'undefined'){
_title = title;
}
var loadT = layer.msg(_title, { icon: 16, time: 0, shade: 0.3 });
$.post('/plugins/run', {name:'l2tp', func:method, args:_args}, function(data) {
layer.close(loadT);
if (!data.status){
layer.msg(data.msg,{icon:0,time:2000,shade: [0.3, '#000']});
return;
}
if(typeof(callback) == 'function'){
callback(data);
}
},'json');
}
function lpAsyncPost(method,args){
var _args = null;
if (typeof(args) == 'string'){
_args = JSON.stringify(str2Obj(args));
} else {
_args = JSON.stringify(args);
}
var loadT = layer.msg('正在获取...', { icon: 16, time: 0, shade: 0.3 });
return syncPost('/plugins/run', {name:'l2tp', func:method, args:_args});
}
function userList(){
lpPost('user_list', '' ,function(data){
var rdata = $.parseJSON(data['data']);
if (!rdata['status']){
layer.msg(rdata.msg,{icon:0,time:2000,shade: [0.3, '#000']});
return;
}
var list = rdata['data'];
var con = '';
con += '<div class="divtable" style="margin-top:5px;"><table class="table table-hover" width="100%" cellspacing="0" cellpadding="0" border="0">';
con += '<thead><tr>';
con += '<th>用户</th>';
con += '<th>密码</th>';
con += '<th>操作(<a class="btlink" onclick="addUser()">添加</a>)</th>';
con += '</tr></thead>';
con += '<tbody>';
for (var i = 0; i < list.length; i++) {
con += '<tr>'+
'<td>' + list[i]['user']+'</td>' +
'<td>' + list[i]['pwd']+'</td>' +
'<td><a class="btlink" onclick="modUser(\''+list[i]['user']+'\')">改密</a>|<a class="btlink" onclick="delUser(\''+list[i]['user']+'\')">删除</a></td></tr>';
}
con += '</tbody>';
con += '</table></div>';
$(".soft-man-con").html(con);
});
}
function addUser(){
var loadOpen = layer.open({
type: 1,
title: '添加用户',
area: '240px',
content:"<div class='bt-form pd20 pb70 c6'>\
<div class='version line'>\
<div><input class='bt-input-text mr5 outline_no' type='text' id='username' name='username' style='height: 28px; border-radius: 3px;width: 200px;' placeholder='输入用户名'></div>\
</div>\
<div class='bt-form-submit-btn'>\
<button type='button' id='add_ok' class='btn btn-success btn-sm btn-title bi-btn'>确认</button>\
</div>\
</div>"
});
$('#add_ok').click(function(){
_data = {};
_data['username'] = $('#username').val();
var loadT = layer.msg('正在获取...', { icon: 16, time: 0, shade: 0.3 });
lpPost('add_user', _data, function(data){
var rdata = $.parseJSON(data.data);
layer.close(loadOpen);
layer.msg(rdata.msg,{icon:rdata.status?1:2,time:2000,shade: [0.3, '#000']});
setTimeout(function(){userList();},2000);
});
});
}
function delUser(username){
lpPost('del_user', {username:username}, function(data){
var rdata = $.parseJSON(data.data);
layer.msg(rdata.msg,{icon:rdata.status?1:2,time:2000,shade: [0.3, '#000']});
setTimeout(function(){userList();},2000);
});
}
function modUser(username){
var loadOpen = layer.open({
type: 1,
title: '修改密码',
area: '240px',
content:"<div class='bt-form pd20 pb70 c6'>\
<div class='version line'>\
<div><input class='bt-input-text mr5 outline_no' type='text' id='password' name='password' style='height: 28px; border-radius: 3px;width: 200px;' placeholder='输入密码'></div>\
</div>\
<div class='bt-form-submit-btn'>\
<button type='button' id='mod_ok' class='btn btn-success btn-sm btn-title bi-btn'>确认</button>\
</div>\
</div>"
});
$('#mod_ok').click(function(){
_data = {};
_data['username'] = username;
_data['password'] = $('#password').val();
var loadT = layer.msg('正在获取...', { icon: 16, time: 0, shade: 0.3 });
lpPost('mod_user', _data, function(data){
var rdata = $.parseJSON(data.data);
layer.close(loadOpen);
layer.msg(rdata.msg,{icon:rdata.status?1:2,time:2000,shade: [0.3, '#000']});
setTimeout(function(){userList();},2000);
});
});
}
function readme(){
var readme = '<ul class="help-info-text c7">';
readme += '<li>PPTP需开放端口:UDP:1723</li>';
readme += '<li>L2TP需开放端口:UDP:500,UDP:4500,UDP:1701</li>';
readme += '</ul>';
$('.soft-man-con').html(readme);
}
+820
View File
@@ -0,0 +1,820 @@
#!/usr/bin/env bash
PATH=/bin:/sbin:/usr/bin:/usr/sbin:/usr/local/bin:/usr/local/sbin:~/bin
export PATH
#=======================================================================#
# System Supported: CentOS 6+ / Debian 7+ / Ubuntu 12+ #
# Description: L2TP VPN Auto Installer #
# Author: Teddysun <i@teddysun.com> #
# Intro: https://teddysun.com/448.html #
#=======================================================================#
cur_dir=`pwd`
libreswan_filename="libreswan-3.27"
download_root_url="https://dl.lamp.sh/files"
rootness(){
if [[ $EUID -ne 0 ]]; then
echo "Error:This script must be run as root!" 1>&2
exit 1
fi
}
tunavailable(){
if [[ ! -e /dev/net/tun ]]; then
echo "Error:TUN/TAP is not available!" 1>&2
exit 1
fi
}
disable_selinux(){
if [ -s /etc/selinux/config ] && grep 'SELINUX=enforcing' /etc/selinux/config; then
sed -i 's/SELINUX=enforcing/SELINUX=disabled/g' /etc/selinux/config
setenforce 0
fi
}
get_opsy(){
[ -f /etc/redhat-release ] && awk '{print ($1,$3~/^[0-9]/?$3:$4)}' /etc/redhat-release && return
[ -f /etc/os-release ] && awk -F'[= "]' '/PRETTY_NAME/{print $3,$4,$5}' /etc/os-release && return
[ -f /etc/lsb-release ] && awk -F'[="]+' '/DESCRIPTION/{print $2}' /etc/lsb-release && return
}
get_os_info(){
IP=$( ip addr | egrep -o '[0-9]{1,3}\.[0-9]{1,3}\.[0-9]{1,3}\.[0-9]{1,3}' | egrep -v "^192\.168|^172\.1[6-9]\.|^172\.2[0-9]\.|^172\.3[0-2]\.|^10\.|^127\.|^255\.|^0\." | head -n 1 )
[ -z ${IP} ] && IP=$( wget -qO- -t1 -T2 ipv4.icanhazip.com )
local cname=$( awk -F: '/model name/ {name=$2} END {print name}' /proc/cpuinfo | sed 's/^[ \t]*//;s/[ \t]*$//' )
local cores=$( awk -F: '/model name/ {core++} END {print core}' /proc/cpuinfo )
local freq=$( awk -F: '/cpu MHz/ {freq=$2} END {print freq}' /proc/cpuinfo | sed 's/^[ \t]*//;s/[ \t]*$//' )
local tram=$( free -m | awk '/Mem/ {print $2}' )
local swap=$( free -m | awk '/Swap/ {print $2}' )
local up=$( awk '{a=$1/86400;b=($1%86400)/3600;c=($1%3600)/60;d=$1%60} {printf("%ddays, %d:%d:%d\n",a,b,c,d)}' /proc/uptime )
local load=$( w | head -1 | awk -F'load average:' '{print $2}' | sed 's/^[ \t]*//;s/[ \t]*$//' )
local opsy=$( get_opsy )
local arch=$( uname -m )
local lbit=$( getconf LONG_BIT )
local host=$( hostname )
local kern=$( uname -r )
echo "########## System Information ##########"
echo
echo "CPU model : ${cname}"
echo "Number of cores : ${cores}"
echo "CPU frequency : ${freq} MHz"
echo "Total amount of ram : ${tram} MB"
echo "Total amount of swap : ${swap} MB"
echo "System uptime : ${up}"
echo "Load average : ${load}"
echo "OS : ${opsy}"
echo "Arch : ${arch} (${lbit} Bit)"
echo "Kernel : ${kern}"
echo "Hostname : ${host}"
echo "IPv4 address : ${IP}"
echo
echo "########################################"
}
check_sys(){
local checkType=$1
local value=$2
local release=''
local systemPackage=''
if [[ -f /etc/redhat-release ]]; then
release="centos"
systemPackage="yum"
elif cat /etc/issue | grep -Eqi "debian"; then
release="debian"
systemPackage="apt"
elif cat /etc/issue | grep -Eqi "ubuntu"; then
release="ubuntu"
systemPackage="apt"
elif cat /etc/issue | grep -Eqi "centos|red hat|redhat"; then
release="centos"
systemPackage="yum"
elif cat /proc/version | grep -Eqi "debian"; then
release="debian"
systemPackage="apt"
elif cat /proc/version | grep -Eqi "ubuntu"; then
release="ubuntu"
systemPackage="apt"
elif cat /proc/version | grep -Eqi "centos|red hat|redhat"; then
release="centos"
systemPackage="yum"
fi
if [[ ${checkType} == "sysRelease" ]]; then
if [ "$value" == "$release" ];then
return 0
else
return 1
fi
elif [[ ${checkType} == "packageManager" ]]; then
if [ "$value" == "$systemPackage" ];then
return 0
else
return 1
fi
fi
}
rand(){
index=0
str=""
for i in {a..z}; do arr[index]=${i}; index=`expr ${index} + 1`; done
for i in {A..Z}; do arr[index]=${i}; index=`expr ${index} + 1`; done
for i in {0..9}; do arr[index]=${i}; index=`expr ${index} + 1`; done
for i in {1..10}; do str="$str${arr[$RANDOM%$index]}"; done
echo ${str}
}
is_64bit(){
if [ `getconf WORD_BIT` = '32' ] && [ `getconf LONG_BIT` = '64' ] ; then
return 0
else
return 1
fi
}
download_file(){
if [ -s ${1} ]; then
echo "$1 [found]"
else
echo "$1 not found!!!download now..."
if ! wget -c -t3 -T60 ${download_root_url}/${1}; then
echo "Failed to download $1, please download it to ${cur_dir} directory manually and try again."
exit 1
fi
fi
}
versionget(){
if [[ -s /etc/redhat-release ]];then
grep -oE "[0-9.]+" /etc/redhat-release
else
grep -oE "[0-9.]+" /etc/issue
fi
}
centosversion(){
if check_sys sysRelease centos;then
local code=${1}
local version="`versionget`"
local main_ver=${version%%.*}
if [ "${main_ver}" == "${code}" ];then
return 0
else
return 1
fi
else
return 1
fi
}
debianversion(){
if check_sys sysRelease debian;then
local version=$( get_opsy )
local code=${1}
local main_ver=$( echo ${version} | sed 's/[^0-9]//g')
if [ "${main_ver}" == "${code}" ];then
return 0
else
return 1
fi
else
return 1
fi
}
version_check(){
if check_sys packageManager yum; then
if centosversion 5; then
echo "Error: CentOS 5 is not supported, Please re-install OS and try again."
exit 1
fi
fi
}
get_char(){
SAVEDSTTY=`stty -g`
stty -echo
stty cbreak
dd if=/dev/tty bs=1 count=1 2> /dev/null
stty -raw
stty echo
stty $SAVEDSTTY
}
preinstall_l2tp(){
echo
if [ -d "/proc/vz" ]; then
echo -e "\033[41;37m WARNING: \033[0m Your VPS is based on OpenVZ, and IPSec might not be supported by the kernel."
echo "Continue installation? (y/n)"
read -p "(Default: n)" agree
[ -z ${agree} ] && agree="n"
if [ "${agree}" == "n" ]; then
echo
echo "L2TP installation cancelled."
echo
exit 0
fi
fi
echo
echo "Please enter IP-Range:"
# read -p "(Default Range: 192.168.18):" iprange
# [ -z ${iprange} ] && iprange="192.168.18"
iprange="192.168.18"
echo ${iprange}
echo "Please enter PSK:"
# read -p "(Default PSK: teddysun.com):" mypsk
# [ -z ${mypsk} ] && mypsk="teddysun.com"
mypsk="midoks"
echo ${mypsk}
echo "Please enter Username:"
# read -p "(Default Username: teddysun):" username
# [ -z ${username} ] && username="teddysun"
username="midoks"
echo ${username}
# password=`rand`
echo "Please enter ${username}'s password:"
# read -p "(Default Password: ${password}):" tmppassword
# [ ! -z ${tmppassword} ] && password=${tmppassword}
password=midoks
echo ${password}
echo
echo "ServerIP:${IP}"
echo "Server Local IP:${iprange}.1"
echo "Client Remote IP Range:${iprange}.2-${iprange}.254"
echo "PSK:${mypsk}"
echo
echo "Press any key to start... or press Ctrl + C to cancel."
char=`get_char`
}
install_l2tp(){
mknod /dev/random c 1 9
if check_sys packageManager apt; then
apt-get -y update
if debianversion 7; then
if is_64bit; then
local libnspr4_filename1="libnspr4_4.10.7-1_amd64.deb"
local libnspr4_filename2="libnspr4-0d_4.10.7-1_amd64.deb"
local libnspr4_filename3="libnspr4-dev_4.10.7-1_amd64.deb"
local libnspr4_filename4="libnspr4-dbg_4.10.7-1_amd64.deb"
local libnss3_filename1="libnss3_3.17.2-1.1_amd64.deb"
local libnss3_filename2="libnss3-1d_3.17.2-1.1_amd64.deb"
local libnss3_filename3="libnss3-tools_3.17.2-1.1_amd64.deb"
local libnss3_filename4="libnss3-dev_3.17.2-1.1_amd64.deb"
local libnss3_filename5="libnss3-dbg_3.17.2-1.1_amd64.deb"
else
local libnspr4_filename1="libnspr4_4.10.7-1_i386.deb"
local libnspr4_filename2="libnspr4-0d_4.10.7-1_i386.deb"
local libnspr4_filename3="libnspr4-dev_4.10.7-1_i386.deb"
local libnspr4_filename4="libnspr4-dbg_4.10.7-1_i386.deb"
local libnss3_filename1="libnss3_3.17.2-1.1_i386.deb"
local libnss3_filename2="libnss3-1d_3.17.2-1.1_i386.deb"
local libnss3_filename3="libnss3-tools_3.17.2-1.1_i386.deb"
local libnss3_filename4="libnss3-dev_3.17.2-1.1_i386.deb"
local libnss3_filename5="libnss3-dbg_3.17.2-1.1_i386.deb"
fi
rm -rf ${cur_dir}/l2tp
mkdir -p ${cur_dir}/l2tp
cd ${cur_dir}/l2tp
download_file "${libnspr4_filename1}"
download_file "${libnspr4_filename2}"
download_file "${libnspr4_filename3}"
download_file "${libnspr4_filename4}"
download_file "${libnss3_filename1}"
download_file "${libnss3_filename2}"
download_file "${libnss3_filename3}"
download_file "${libnss3_filename4}"
download_file "${libnss3_filename5}"
dpkg -i ${libnspr4_filename1} ${libnspr4_filename2} ${libnspr4_filename3} ${libnspr4_filename4}
dpkg -i ${libnss3_filename1} ${libnss3_filename2} ${libnss3_filename3} ${libnss3_filename4} ${libnss3_filename5}
apt-get -y install wget gcc ppp flex bison make pkg-config libpam0g-dev libcap-ng-dev iptables \
libcap-ng-utils libunbound-dev libevent-dev libcurl4-nss-dev libsystemd-daemon-dev
else
apt-get -y install wget gcc ppp flex bison make python libnss3-dev libnss3-tools libselinux-dev iptables \
libnspr4-dev pkg-config libpam0g-dev libcap-ng-dev libcap-ng-utils libunbound-dev \
libevent-dev libcurl4-nss-dev libsystemd-dev
fi
apt-get -y --no-install-recommends install xmlto
apt-get -y install xl2tpd
compile_install
elif check_sys packageManager yum; then
echo "Adding the EPEL repository..."
yum -y install epel-release yum-utils
[ ! -f /etc/yum.repos.d/epel.repo ] && echo "Install EPEL repository failed, please check it." && exit 1
yum-config-manager --enable epel
echo "Adding the EPEL repository complete..."
if centosversion 7; then
yum -y install ppp libreswan xl2tpd firewalld
yum_install
elif centosversion 6; then
yum -y remove libevent-devel
yum -y install libevent2-devel
yum -y install nss-devel nspr-devel pkgconfig pam-devel \
libcap-ng-devel libselinux-devel lsof \
curl-devel flex bison gcc ppp make iptables gmp-devel \
fipscheck-devel unbound-devel xmlto libpcap-devel xl2tpd
compile_install
fi
fi
}
config_install(){
cat > /etc/ipsec.conf<<EOF
version 2.0
config setup
protostack=netkey
nhelpers=0
uniqueids=no
interfaces=%defaultroute
virtual_private=%v4:10.0.0.0/8,%v4:192.168.0.0/16,%v4:172.16.0.0/12,%v4:!${iprange}.0/24
conn l2tp-psk
rightsubnet=vhost:%priv
also=l2tp-psk-nonat
conn l2tp-psk-nonat
authby=secret
pfs=no
auto=add
keyingtries=3
rekey=no
ikelifetime=8h
keylife=1h
type=transport
left=%defaultroute
leftid=${IP}
leftprotoport=17/1701
right=%any
rightprotoport=17/%any
dpddelay=40
dpdtimeout=130
dpdaction=clear
sha2-truncbug=yes
EOF
cat > /etc/ipsec.secrets<<EOF
%any %any : PSK "${mypsk}"
EOF
cat > /etc/xl2tpd/xl2tpd.conf<<EOF
[global]
port = 1701
[lns default]
ip range = ${iprange}.2-${iprange}.254
local ip = ${iprange}.1
require chap = yes
refuse pap = yes
require authentication = yes
name = l2tpd
ppp debug = yes
pppoptfile = /etc/ppp/options.xl2tpd
length bit = yes
EOF
cat > /etc/ppp/options.xl2tpd<<EOF
ipcp-accept-local
ipcp-accept-remote
require-mschap-v2
ms-dns 8.8.8.8
ms-dns 8.8.4.4
noccp
auth
hide-password
idle 1800
mtu 1410
mru 1410
nodefaultroute
debug
proxyarp
connect-delay 5000
EOF
rm -f /etc/ppp/chap-secrets
cat > /etc/ppp/chap-secrets<<EOF
# Secrets for authentication using CHAP
# client server secret IP addresses
${username} l2tpd ${password} *
EOF
}
compile_install(){
rm -rf ${cur_dir}/l2tp
mkdir -p ${cur_dir}/l2tp
cd ${cur_dir}/l2tp
download_file "${libreswan_filename}.tar.gz"
tar -zxf ${libreswan_filename}.tar.gz
cd ${cur_dir}/l2tp/${libreswan_filename}
cat > Makefile.inc.local <<'EOF'
WERROR_CFLAGS =
USE_DNSSEC = false
USE_DH31 = false
USE_GLIBC_KERN_FLIP_HEADERS = true
EOF
make programs && make install
/usr/local/sbin/ipsec --version >/dev/null 2>&1
if [ $? -ne 0 ]; then
echo "${libreswan_filename} install failed."
exit 1
fi
config_install
cp -pf /etc/sysctl.conf /etc/sysctl.conf.bak
sed -i 's/net.ipv4.ip_forward = 0/net.ipv4.ip_forward = 1/g' /etc/sysctl.conf
for each in `ls /proc/sys/net/ipv4/conf/`; do
echo "net.ipv4.conf.${each}.accept_source_route=0" >> /etc/sysctl.conf
echo "net.ipv4.conf.${each}.accept_redirects=0" >> /etc/sysctl.conf
echo "net.ipv4.conf.${each}.send_redirects=0" >> /etc/sysctl.conf
echo "net.ipv4.conf.${each}.rp_filter=0" >> /etc/sysctl.conf
done
sysctl -p
if centosversion 6; then
[ -f /etc/sysconfig/iptables ] && cp -pf /etc/sysconfig/iptables /etc/sysconfig/iptables.old.`date +%Y%m%d`
if [ "`iptables -L -n | grep -c '\-\-'`" == "0" ]; then
cat > /etc/sysconfig/iptables <<EOF
# Added by L2TP VPN script
*filter
:INPUT ACCEPT [0:0]
:FORWARD ACCEPT [0:0]
:OUTPUT ACCEPT [0:0]
-A INPUT -m state --state RELATED,ESTABLISHED -j ACCEPT
-A INPUT -p icmp -j ACCEPT
-A INPUT -i lo -j ACCEPT
-A INPUT -p tcp --dport 22 -j ACCEPT
-A INPUT -p udp -m multiport --dports 500,4500,1701 -j ACCEPT
-A FORWARD -m state --state RELATED,ESTABLISHED -j ACCEPT
-A FORWARD -s ${iprange}.0/24 -j ACCEPT
COMMIT
*nat
:PREROUTING ACCEPT [0:0]
:OUTPUT ACCEPT [0:0]
:POSTROUTING ACCEPT [0:0]
-A POSTROUTING -s ${iprange}.0/24 -j SNAT --to-source ${IP}
COMMIT
EOF
else
iptables -I INPUT -p udp -m multiport --dports 500,4500,1701 -j ACCEPT
iptables -I FORWARD -m state --state RELATED,ESTABLISHED -j ACCEPT
iptables -I FORWARD -s ${iprange}.0/24 -j ACCEPT
iptables -t nat -A POSTROUTING -s ${iprange}.0/24 -j SNAT --to-source ${IP}
/etc/init.d/iptables save
fi
if [ ! -f /etc/ipsec.d/cert9.db ]; then
echo > /var/tmp/libreswan-nss-pwd
certutil -N -f /var/tmp/libreswan-nss-pwd -d /etc/ipsec.d
rm -f /var/tmp/libreswan-nss-pwd
fi
chkconfig --add iptables
chkconfig iptables on
chkconfig --add ipsec
chkconfig ipsec on
chkconfig --add xl2tpd
chkconfig xl2tpd on
/etc/init.d/iptables restart
/etc/init.d/ipsec start
/etc/init.d/xl2tpd start
else
[ -f /etc/iptables.rules ] && cp -pf /etc/iptables.rules /etc/iptables.rules.old.`date +%Y%m%d`
if [ "`iptables -L -n | grep -c '\-\-'`" == "0" ]; then
cat > /etc/iptables.rules <<EOF
# Added by L2TP VPN script
*filter
:INPUT ACCEPT [0:0]
:FORWARD ACCEPT [0:0]
:OUTPUT ACCEPT [0:0]
-A INPUT -m state --state RELATED,ESTABLISHED -j ACCEPT
-A INPUT -p icmp -j ACCEPT
-A INPUT -i lo -j ACCEPT
-A INPUT -p tcp --dport 22 -j ACCEPT
-A INPUT -p udp -m multiport --dports 500,4500,1701 -j ACCEPT
-A FORWARD -m state --state RELATED,ESTABLISHED -j ACCEPT
-A FORWARD -s ${iprange}.0/24 -j ACCEPT
COMMIT
*nat
:PREROUTING ACCEPT [0:0]
:OUTPUT ACCEPT [0:0]
:POSTROUTING ACCEPT [0:0]
-A POSTROUTING -s ${iprange}.0/24 -j SNAT --to-source ${IP}
COMMIT
EOF
else
iptables -I INPUT -p udp -m multiport --dports 500,4500,1701 -j ACCEPT
iptables -I FORWARD -m state --state RELATED,ESTABLISHED -j ACCEPT
iptables -I FORWARD -s ${iprange}.0/24 -j ACCEPT
iptables -t nat -A POSTROUTING -s ${iprange}.0/24 -j SNAT --to-source ${IP}
/sbin/iptables-save > /etc/iptables.rules
fi
cat > /etc/network/if-up.d/iptables <<EOF
#!/bin/sh
/sbin/iptables-restore < /etc/iptables.rules
EOF
chmod +x /etc/network/if-up.d/iptables
if [ ! -f /etc/ipsec.d/cert9.db ]; then
echo > /var/tmp/libreswan-nss-pwd
certutil -N -f /var/tmp/libreswan-nss-pwd -d /etc/ipsec.d
rm -f /var/tmp/libreswan-nss-pwd
fi
update-rc.d -f xl2tpd defaults
cp -f /etc/rc.local /etc/rc.local.old.`date +%Y%m%d`
sed --follow-symlinks -i -e '/^exit 0/d' /etc/rc.local
cat >> /etc/rc.local <<EOF
# Added by L2TP VPN script
echo 1 > /proc/sys/net/ipv4/ip_forward
/usr/sbin/service ipsec start
exit 0
EOF
chmod +x /etc/rc.local
echo 1 > /proc/sys/net/ipv4/ip_forward
/sbin/iptables-restore < /etc/iptables.rules
/usr/sbin/service ipsec start
/usr/sbin/service xl2tpd restart
fi
}
yum_install(){
config_install
cp -pf /etc/sysctl.conf /etc/sysctl.conf.bak
echo "# Added by L2TP VPN" >> /etc/sysctl.conf
echo "net.ipv4.ip_forward=1" >> /etc/sysctl.conf
echo "net.ipv4.tcp_syncookies=1" >> /etc/sysctl.conf
echo "net.ipv4.icmp_echo_ignore_broadcasts=1" >> /etc/sysctl.conf
echo "net.ipv4.icmp_ignore_bogus_error_responses=1" >> /etc/sysctl.conf
for each in `ls /proc/sys/net/ipv4/conf/`; do
echo "net.ipv4.conf.${each}.accept_source_route=0" >> /etc/sysctl.conf
echo "net.ipv4.conf.${each}.accept_redirects=0" >> /etc/sysctl.conf
echo "net.ipv4.conf.${each}.send_redirects=0" >> /etc/sysctl.conf
echo "net.ipv4.conf.${each}.rp_filter=0" >> /etc/sysctl.conf
done
sysctl -p
cat > /etc/firewalld/services/xl2tpd.xml<<EOF
<?xml version="1.0" encoding="utf-8"?>
<service>
<short>xl2tpd</short>
<description>L2TP IPSec</description>
<port protocol="udp" port="4500"/>
<port protocol="udp" port="1701"/>
</service>
EOF
chmod 640 /etc/firewalld/services/xl2tpd.xml
systemctl enable ipsec
systemctl enable xl2tpd
systemctl enable firewalld
systemctl status firewalld > /dev/null 2>&1
if [ $? -eq 0 ]; then
firewall-cmd --reload
echo "Checking firewalld status..."
firewall-cmd --list-all
echo "add firewalld rules..."
firewall-cmd --permanent --add-service=ipsec
firewall-cmd --permanent --add-service=xl2tpd
firewall-cmd --permanent --add-masquerade
firewall-cmd --reload
else
echo "Firewalld looks like not running, trying to start..."
systemctl start firewalld
if [ $? -eq 0 ]; then
echo "Firewalld start successfully..."
firewall-cmd --reload
echo "Checking firewalld status..."
firewall-cmd --list-all
echo "adding firewalld rules..."
firewall-cmd --permanent --add-service=ipsec
firewall-cmd --permanent --add-service=xl2tpd
firewall-cmd --permanent --add-masquerade
firewall-cmd --reload
else
echo "Failed to start firewalld. please enable udp port 500 4500 1701 manually if necessary."
fi
fi
systemctl restart ipsec
systemctl restart xl2tpd
echo "Checking ipsec status..."
systemctl -a | grep ipsec
echo "Checking xl2tpd status..."
systemctl -a | grep xl2tpd
echo "Checking firewalld status..."
firewall-cmd --list-all
}
finally(){
cd ${cur_dir}
rm -fr ${cur_dir}/l2tp
# create l2tp command
cp -f ${cur_dir}/`basename $0` /usr/bin/l2tp
echo "Please wait a moment..."
sleep 5
ipsec verify
echo
echo "###############################################################"
echo "# L2TP VPN Auto Installer #"
echo "# System Supported: CentOS 6+ / Debian 7+ / Ubuntu 12+ #"
echo "# Intro: https://teddysun.com/448.html #"
echo "# Author: Teddysun <i@teddysun.com> #"
echo "###############################################################"
echo "If there is no [FAILED] above, you can connect to your L2TP "
echo "VPN Server with the default Username/Password is below:"
echo
echo "Server IP: ${IP}"
echo "PSK : ${mypsk}"
echo "Username : ${username}"
echo "Password : ${password}"
echo
echo "If you want to modify user settings, please use below command(s):"
echo "l2tp -a (Add a user)"
echo "l2tp -d (Delete a user)"
echo "l2tp -l (List all users)"
echo "l2tp -m (Modify a user password)"
echo
echo "Welcome to visit our website: https://teddysun.com/448.html"
echo "Enjoy it!"
echo
}
l2tp(){
clear
echo
echo "###############################################################"
echo "# L2TP VPN Auto Installer #"
echo "# System Supported: CentOS 6+ / Debian 7+ / Ubuntu 12+ #"
echo "# Intro: https://teddysun.com/448.html #"
echo "# Author: Teddysun <i@teddysun.com> #"
echo "###############################################################"
echo
rootness
tunavailable
disable_selinux
version_check
get_os_info
preinstall_l2tp
install_l2tp
finally
}
list_users(){
if [ ! -f /etc/ppp/chap-secrets ];then
echo "Error: /etc/ppp/chap-secrets file not found."
exit 1
fi
local line="+-------------------------------------------+\n"
local string=%20s
printf "${line}|${string} |${string} |\n${line}" Username Password
grep -v "^#" /etc/ppp/chap-secrets | awk '{printf "|'${string}' |'${string}' |\n", $1,$3}'
printf ${line}
}
add_user(){
while :
do
read -p "Please input your Username:" user
if [ -z ${user} ]; then
echo "Username can not be empty"
else
grep -w "${user}" /etc/ppp/chap-secrets > /dev/null 2>&1
if [ $? -eq 0 ];then
echo "Username (${user}) already exists. Please re-enter your username."
else
break
fi
fi
done
pass=`rand`
echo "Please input ${user}'s password:"
read -p "(Default Password: ${pass}):" tmppass
[ ! -z ${tmppass} ] && pass=${tmppass}
echo "${user} l2tpd ${pass} *" >> /etc/ppp/chap-secrets
echo "Username (${user}) add completed."
}
del_user(){
while :
do
read -p "Please input Username you want to delete it:" user
if [ -z ${user} ]; then
echo "Username can not be empty"
else
grep -w "${user}" /etc/ppp/chap-secrets >/dev/null 2>&1
if [ $? -eq 0 ];then
break
else
echo "Username (${user}) is not exists. Please re-enter your username."
fi
fi
done
sed -i "/^\<${user}\>/d" /etc/ppp/chap-secrets
echo "Username (${user}) delete completed."
}
mod_user(){
while :
do
read -p "Please input Username you want to change password:" user
if [ -z ${user} ]; then
echo "Username can not be empty"
else
grep -w "${user}" /etc/ppp/chap-secrets >/dev/null 2>&1
if [ $? -eq 0 ];then
break
else
echo "Username (${user}) is not exists. Please re-enter your username."
fi
fi
done
pass=`rand`
echo "Please input ${user}'s new password:"
read -p "(Default Password: ${pass}):" tmppass
[ ! -z ${tmppass} ] && pass=${tmppass}
sed -i "/^\<${user}\>/d" /etc/ppp/chap-secrets
echo "${user} l2tpd ${pass} *" >> /etc/ppp/chap-secrets
echo "Username ${user}'s password has been changed."
}
# Main process
action=$1
if [ -z ${action} ] && [ "`basename $0`" != "l2tp" ]; then
action=install
fi
case ${action} in
install)
l2tp 2>&1 | tee ${cur_dir}/l2tp.log
;;
-l|--list)
list_users
;;
-a|--add)
add_user
;;
-d|--del)
del_user
;;
-m|--mod)
mod_user
;;
-h|--help)
echo "Usage: `basename $0` -l,--list List all users"
echo " `basename $0` -a,--add Add a user"
echo " `basename $0` -d,--del Delete a user"
echo " `basename $0` -m,--mod Modify a user password"
echo " `basename $0` -h,--help Print this help information"
;;
*)
echo "Usage: `basename $0` [-l,--list|-a,--add|-d,--del|-m,--mod|-h,--help]" && exit
;;
esac
+3
View File
@@ -0,0 +1,3 @@
# Secrets for authentication using CHAP
# client server secret IP addresses
demo demo demo *
+1
View File
@@ -0,0 +1 @@
%any %any : PSK "midoks"
+23 -20
View File
@@ -7,10 +7,10 @@ import time
import re import re
sys.path.append(os.getcwd() + "/class/core") sys.path.append(os.getcwd() + "/class/core")
import public import mw
app_debug = False app_debug = False
if public.isAppleSystem(): if mw.isAppleSystem():
app_debug = True app_debug = True
@@ -19,11 +19,11 @@ def getPluginName():
def getPluginDir(): def getPluginDir():
return public.getPluginDir() + '/' + getPluginName() return mw.getPluginDir() + '/' + getPluginName()
def getServerDir(): def getServerDir():
return public.getServerDir() + '/' + getPluginName() return mw.getServerDir() + '/' + getPluginName()
def getInitDFile(): def getInitDFile():
@@ -44,7 +44,7 @@ def getConfTpl():
def getMemPort(): def getMemPort():
path = getConf() path = getConf()
content = public.readFile(path) content = mw.readFile(path)
rep = 'PORT\s*=\s*(\d*)' rep = 'PORT\s*=\s*(\d*)'
tmp = re.search(rep, content) tmp = re.search(rep, content)
return tmp.groups()[0] return tmp.groups()[0]
@@ -68,7 +68,7 @@ def getArgs():
def status(): def status():
data = public.execShell( data = mw.execShell(
"ps -ef|grep " + getPluginName() + " |grep -v grep | grep -v python | awk '{print $2}'") "ps -ef|grep " + getPluginName() + " |grep -v grep | grep -v python | awk '{print $2}'")
if data[0] == '': if data[0] == '':
return 'stop' return 'stop'
@@ -78,7 +78,7 @@ def status():
def initDreplace(): def initDreplace():
file_tpl = getConfTpl() file_tpl = getConfTpl()
service_path = public.getServerDir() service_path = mw.getServerDir()
initD_path = getServerDir() + '/init.d' initD_path = getServerDir() + '/init.d'
if not os.path.exists(initD_path): if not os.path.exists(initD_path):
@@ -86,17 +86,17 @@ def initDreplace():
file_bin = initD_path + '/memcached' file_bin = initD_path + '/memcached'
if not os.path.exists(file_bin): if not os.path.exists(file_bin):
content = public.readFile(file_tpl) content = mw.readFile(file_tpl)
content = content.replace('{$SERVER_PATH}', service_path) content = content.replace('{$SERVER_PATH}', service_path)
public.writeFile(file_bin, content) mw.writeFile(file_bin, content)
public.execShell('chmod +x ' + file_bin) mw.execShell('chmod +x ' + file_bin)
return file_bin return file_bin
def memOp(method): def memOp(method):
file = initDreplace() file = initDreplace()
data = public.execShell(file + ' ' + method) data = mw.execShell(file + ' ' + method)
if data[1] == '': if data[1] == '':
return 'ok' return 'ok'
return data[1] return data[1]
@@ -146,15 +146,15 @@ def runInfo():
result['hit'] = float(result['get_hits']) / \ result['hit'] = float(result['get_hits']) / \
float(result['cmd_get']) * 100 float(result['cmd_get']) * 100
conf = public.readFile(getConf()) conf = mw.readFile(getConf())
result['bind'] = re.search('IP=(.+)', conf).groups()[0] result['bind'] = re.search('IP=(.+)', conf).groups()[0]
result['port'] = int(re.search('PORT=(\d+)', conf).groups()[0]) result['port'] = int(re.search('PORT=(\d+)', conf).groups()[0])
result['maxconn'] = int(re.search('MAXCONN=(\d+)', conf).groups()[0]) result['maxconn'] = int(re.search('MAXCONN=(\d+)', conf).groups()[0])
result['cachesize'] = int( result['cachesize'] = int(
re.search('CACHESIZE=(\d+)', conf).groups()[0]) re.search('CACHESIZE=(\d+)', conf).groups()[0])
return public.getJson(result) return mw.getJson(result)
except Exception, e: except Exception, e:
return public.getJson({}) return mw.getJson({})
def saveConf(): def saveConf():
@@ -164,13 +164,13 @@ def saveConf():
print confFile print confFile
try: try:
args = getArgs() args = getArgs()
content = public.readFile(confFile) content = mw.readFile(confFile)
content = re.sub('IP=.+', 'IP=' + args['ip'], content) content = re.sub('IP=.+', 'IP=' + args['ip'], content)
content = re.sub('PORT=\d+', 'PORT=' + args['port'], content) content = re.sub('PORT=\d+', 'PORT=' + args['port'], content)
content = re.sub('MAXCONN=\d+', 'MAXCONN=' + args['maxconn'], content) content = re.sub('MAXCONN=\d+', 'MAXCONN=' + args['maxconn'], content)
content = re.sub('CACHESIZE=\d+', 'CACHESIZE=' + content = re.sub('CACHESIZE=\d+', 'CACHESIZE=' +
args['cachesize'], content) args['cachesize'], content)
public.writeFile(confFile, content) mw.writeFile(confFile, content)
restart() restart()
return 'save ok' return 'save ok'
except Exception as e: except Exception as e:
@@ -180,7 +180,7 @@ def saveConf():
def initdStatus(): def initdStatus():
if not app_debug: if not app_debug:
if public.isAppleSystem(): if mw.isAppleSystem():
return "Apple Computer does not support" return "Apple Computer does not support"
initd_bin = getInitDFile() initd_bin = getInitDFile()
if os.path.exists(initd_bin): if os.path.exists(initd_bin):
@@ -191,20 +191,23 @@ def initdStatus():
def initdInstall(): def initdInstall():
import shutil import shutil
if not app_debug: if not app_debug:
if public.isAppleSystem(): if mw.isAppleSystem():
return "Apple Computer does not support" return "Apple Computer does not support"
mem_bin = initDreplace() mem_bin = initDreplace()
initd_bin = getInitDFile() initd_bin = getInitDFile()
shutil.copyfile(mem_bin, initd_bin) shutil.copyfile(mem_bin, initd_bin)
public.execShell('chmod +x ' + initd_bin) mw.execShell('chmod +x ' + initd_bin)
mw.execShell('chkconfig --add ' + getPluginName())
return 'ok' return 'ok'
def initdUinstall(): def initdUinstall():
if not app_debug: if not app_debug:
if public.isAppleSystem(): if mw.isAppleSystem():
return "Apple Computer does not support" return "Apple Computer does not support"
mw.execShell('chkconfig --del ' + getPluginName())
initd_bin = getInitDFile() initd_bin = getInitDFile()
os.remove(initd_bin) os.remove(initd_bin)
return 'ok' return 'ok'
+4 -3
View File
@@ -1,13 +1,14 @@
{ {
"sort": 7, "sort": 7,
"ps": "Memcached 是一个高性能的分布式内存对象缓存系统", "ps": "是一个高性能的分布式内存对象缓存系统",
"name": "memcached", "name": "memcached",
"title": "Memcached", "title": "Memcached",
"shell": "install.sh", "shell": "install.sh",
"versions":["1.5"], "versions":["1.6"],
"updates":["1.5.12"], "updates":["1.6.9"],
"tip": "soft", "tip": "soft",
"checks": "server/memcached", "checks": "server/memcached",
"path":"server/memcached",
"display": 1, "display": 1,
"author": "Zend", "author": "Zend",
"date": "2017-04-01", "date": "2017-04-01",
+10 -13
View File
@@ -1,4 +1,5 @@
#!/bin/bash #!/bin/bash
PATH=/bin:/sbin:/usr/bin:/usr/sbin:/usr/local/bin:/usr/local/sbin:~/bin PATH=/bin:/sbin:/usr/bin:/usr/sbin:/usr/local/bin:/usr/local/sbin:~/bin
export PATH export PATH
@@ -7,35 +8,31 @@ rootPath=$(dirname "$curPath")
rootPath=$(dirname "$rootPath") rootPath=$(dirname "$rootPath")
serverPath=$(dirname "$rootPath") serverPath=$(dirname "$rootPath")
install_tmp=${rootPath}/tmp/mw_install.pl install_tmp=${rootPath}/tmp/mw_install.pl
Install_mem() Install_mem(){
{
mkdir -p $serverPath/source mkdir -p $serverPath/source
echo '正在安装脚本文件...' > $install_tmp echo '正在安装脚本文件...' > $install_tmp
if [ ! -f $serverPath/source/memcached.tar.gz ];then if [ ! -f $serverPath/source/memcached.tar.gz ];then
wget -O $serverPath/source/memcached.tar.gz http://www.memcached.org/files/memcached-1.5.12.tar.gz wget -O $serverPath/source/memcached.tar.gz http://www.memcached.org/files/memcached-1.6.9.tar.gz
if fi
cd $serverPath/source && tar -zxvf memcached.tar.gz cd $serverPath/source && tar -zxvf memcached.tar.gz
mkdir -p $serverPath/memcached mkdir -p $serverPath/memcached
cd memcached* && ./configure --prefix=$serverPath/memcached && make && make install cd $serverPath/source/memcached*
./configure --prefix=$serverPath/memcached && make && make install
echo '1.5' > $serverPath/memcached/version.pl
echo '安装完成' > $install_tmp
echo '1.6' > $serverPath/memcached/version.pl
echo 'install ok' > $install_tmp
} }
Uninstall_mem() Uninstall_mem()
{ {
$serverPath/memcached/init.d/memcached stop ${serverPath}/memcached/init.d/memcached stop
rm -rf mkdir -p $serverPath/memcached rm -rf $serverPath/memcached
} }
@@ -7,7 +7,7 @@ import sys
sys.path.append("/usr/local/lib/python2.7/site-packages") sys.path.append("/usr/local/lib/python2.7/site-packages")
class mysql: class mysqlDb:
__DB_PASS = None __DB_PASS = None
__DB_USER = 'root' __DB_USER = 'root'
__DB_PORT = 3306 __DB_PORT = 3306
@@ -20,7 +20,7 @@ class mysql:
def __Conn(self): def __Conn(self):
'''连接MYSQL数据库''' '''连接MYSQL数据库'''
try: try:
import public import mw
socket = '/tmp/mysql.sock' socket = '/tmp/mysql.sock'
try: try:
import MySQLdb import MySQLdb
@@ -28,13 +28,13 @@ class mysql:
self.__DB_ERR = ex self.__DB_ERR = ex
return False return False
try: try:
myconf = public.readFile(self.__DB_CNF) myconf = mw.readFile(self.__DB_CNF)
rep = "port\s*=\s*([0-9]+)" rep = "port\s*=\s*([0-9]+)"
self.__DB_PORT = int(re.search(rep, myconf).groups()[0]) self.__DB_PORT = int(re.search(rep, myconf).groups()[0])
except: except:
self.__DB_PORT = 3306 self.__DB_PORT = 3306
# print self.__DB_PASS # print self.__DB_PASS
#self.__DB_PASS = public.M('config').where('id=?', (1,)).getField('mysql_root') #self.__DB_PASS = mw.M('config').where('id=?', (1,)).getField('mysql_root')
try: try:
self.__DB_CONN = MySQLdb.connect(host=self.__DB_HOST, user=self.__DB_USER, passwd=self.__DB_PASS, self.__DB_CONN = MySQLdb.connect(host=self.__DB_HOST, user=self.__DB_USER, passwd=self.__DB_PASS,
port=self.__DB_PORT, charset="utf8", connect_timeout=1, unix_socket=socket) port=self.__DB_PORT, charset="utf8", connect_timeout=1, unix_socket=socket)
@@ -48,6 +48,9 @@ class mysql:
self.__DB_ERR = e self.__DB_ERR = e
return False return False
def setDbConf(self, conf):
self.__DB_CNF = conf
def setPwd(self, pwd): def setPwd(self, pwd):
self.__DB_PASS = pwd self.__DB_PASS = pwd
+32 -7
View File
@@ -1,18 +1,19 @@
[client] [client]
user = root
#password = your_password #password = your_password
port = 3306 port = 3306
socket = /tmp/mysql.sock socket = {$SERVER_APP_PATH}/mysql.sock
[mysqld] [mysqld]
# 5.6
#default-authentication-plugin=sha256_password
port = 3306 port = 3306
socket = /tmp/mysql.sock socket = {$SERVER_APP_PATH}/mysql.sock
datadir = {$SERVER_APP_PATH}/data datadir = {$SERVER_APP_PATH}/data
log-error = {$SERVER_APP_PATH}/data/error.log log-error = {$SERVER_APP_PATH}/data/error.log
default_storage_engine = MyISAM default_storage_engine = MyISAM
#skip-external-locking
#loose-skip-innodb
key_buffer_size = 8M key_buffer_size = 8M
max_allowed_packet = 100G max_allowed_packet = 100M
table_open_cache = 32 table_open_cache = 32
sort_buffer_size = 256K sort_buffer_size = 256K
net_buffer_length = 4K net_buffer_length = 4K
@@ -20,15 +21,21 @@ read_buffer_size = 128K
read_rnd_buffer_size = 256K read_rnd_buffer_size = 256K
myisam_sort_buffer_size = 4M myisam_sort_buffer_size = 4M
thread_cache_size = 4 thread_cache_size = 4
lower_case_table_names=2
query_cache_size = 4M query_cache_size = 4M
tmp_table_size = 8M tmp_table_size = 8M
#skip-networking
#skip-name-resolve
max_connections = 500 max_connections = 500
max_connect_errors = 100 max_connect_errors = 100
open_files_limit = 65535 open_files_limit = 65535
#skip-networking
#skip-name-resolve
#skip-external-locking
#loose-skip-innodb
#skip-grant-tables
log-bin=mysql-bin log-bin=mysql-bin
binlog_format=mixed binlog_format=mixed
server-id = 1 server-id = 1
@@ -38,6 +45,24 @@ slow-query-log-file={$SERVER_APP_PATH}/data/mysql-slow.log
long_query_time=3 long_query_time=3
#log_queries_not_using_indexes=on #log_queries_not_using_indexes=on
relay-log=mdserver
relay-log-index=mdserver
#master
#binlog-do-db
binlog-ignore-db = test
binlog-ignore-db = mysql
binlog-ignore-db = information_schema
binlog-ignore-db = performance_schema
#slave
log-slave-updates
#replicate-do-db
replicate-ignore-db = information_schema
replicate-ignore-db = performance_schema
replicate-ignore-db = mysql
replicate-ignore-db = test
default_storage_engine = InnoDB default_storage_engine = InnoDB
innodb_data_home_dir = {$SERVER_APP_PATH}/data innodb_data_home_dir = {$SERVER_APP_PATH}/data
innodb_data_file_path = ibdata1:10M:autoextend innodb_data_file_path = ibdata1:10M:autoextend
+92
View File
@@ -0,0 +1,92 @@
[client]
user = root
#password = your_password
port = 3306
socket = {$SERVER_APP_PATH}/mysql.sock
default-character-set = UTF8MB4
[mysqld]
port = 3306
socket = {$SERVER_APP_PATH}/mysql.sock
datadir = {$SERVER_APP_PATH}/data
log-error = {$SERVER_APP_PATH}/data/error.log
default_storage_engine = MyISAM
key_buffer_size = 8M
table_open_cache = 32
sort_buffer_size = 256K
net_buffer_length = 4K
read_buffer_size = 128K
read_rnd_buffer_size = 256K
myisam_sort_buffer_size = 4M
thread_cache_size = 4
lower_case_table_names=2
tmp_table_size = 8M
character-set-server = UTF8MB4
max_connections = 500
max_connect_errors = 100
open_files_limit = 2560
max_allowed_packet = 128M
#skip-external-locking
#skip-grant-tables
#loose-skip-innodb
#skip-networking
#skip-name-resolve
log-bin=mysql-bin
binlog_format=mixed
server-id = 1
slow_query_log=1
slow-query-log-file={$SERVER_APP_PATH}/data/mysql-slow.log
long_query_time=3
#log_queries_not_using_indexes=on
relay-log=mdserver
relay-log-index=mdserver
#master
#binlog-do-db
binlog-ignore-db = test
binlog-ignore-db = mysql
binlog-ignore-db = information_schema
binlog-ignore-db = performance_schema
#slave
log-slave-updates
#replicate-do-db
replicate-ignore-db = information_schema
replicate-ignore-db = performance_schema
replicate-ignore-db = mysql
replicate-ignore-db = test
default_storage_engine = InnoDB
innodb_data_home_dir = {$SERVER_APP_PATH}/data
innodb_data_file_path = ibdata1:10M:autoextend
innodb_log_group_home_dir = {$SERVER_APP_PATH}/data
innodb_buffer_pool_size = 16M
innodb_log_file_size = 5M
innodb_log_buffer_size = 8M
innodb_flush_log_at_trx_commit = 1
innodb_lock_wait_timeout = 120
innodb_max_dirty_pages_pct = 90
innodb_read_io_threads = 1
innodb_write_io_threads = 1
innodb_file_per_table=1
binlog_expire_logs_seconds=2592000
[mysqldump]
quick
[mysql]
no-auto-rehash
[myisamchk]
key_buffer_size = 20M
sort_buffer_size = 20M
read_buffer = 2M
write_buffer = 2M
[mysqlhotcopy]
interactive-timeout
+11
View File
@@ -15,3 +15,14 @@ CREATE TABLE IF NOT EXISTS `databases` (
`ps` TEXT, `ps` TEXT,
`addtime` TEXT `addtime` TEXT
); );
CREATE TABLE IF NOT EXISTS `master_replication_user` (
`id` INTEGER PRIMARY KEY AUTOINCREMENT,
`username` TEXT,
`password` TEXT,
`accept` TEXT,
`ps` TEXT,
`addtime` TEXT
);
Binary file not shown.

Before

Width:  |  Height:  |  Size: 515 B

After

Width:  |  Height:  |  Size: 388 B

+28 -23
View File
@@ -1,3 +1,28 @@
<div class="bt-form">
<div class='plugin_version'></div>
<div class="bt-w-main">
<div class="bt-w-menu">
<script type="text/javascript">console.log($('.plugin_version').attr('version'));</script>
<p class="bgw" onclick="pluginService('mysql', $('.plugin_version').attr('version'));">服务</p>
<p onclick="pluginInitD('mysql', $('.plugin_version').attr('version'));">自启动</p>
<p onclick="pluginConfig('mysql', $('.plugin_version').attr('version'));">配置文件</p>
<p onclick="myDbPos();">存储位置</p>
<p onclick="myPort();">端口</p>
<p onclick="runInfo();">当前状态</p>
<p onclick="myPerfOpt();">性能优化</p>
<p onclick="myLogs();">日志</p>
<p onclick="pluginLogs('mysql',$('.plugin_version').attr('version'),'show_log');">慢日志</p>
<p onclick="dbList()">管理列表</p>
<p onclick="masterOrSlaveConf($('.plugin_version').attr('version'))">主从配置</p>
</div>
<div class="bt-w-con pd15">
<div class="soft-man-con"></div>
</div>
</div>
</div>
<style type="text/css"> <style type="text/css">
.db_list{ .db_list{
padding: 0px 0 10px 0; padding: 0px 0 10px 0;
@@ -25,29 +50,9 @@
margin-right: 0; margin-right: 0;
} }
</style> </style>
<div class="bt-form">
<div class="bt-w-main">
<div class="bt-w-menu">
<p class="bgw" onclick="pluginService('mysql');">服务</p>
<p onclick="pluginInitD('mysql');">自启动</p>
<p onclick="pluginConfig('mysql');">配置文件</p>
<p onclick="myDbPos();">存储位置</p>
<p onclick="myPort();">端口</p>
<p onclick="runInfo();">当前状态</p>
<p onclick="myPerfOpt();">性能优化</p>
<p onclick="myLogs();">日志</p>
<p onclick="pluginLogs('mysql','','show_log');">慢日志</p>
<p onclick="dbList()">管理列表</p>
</div>
<div class="bt-w-con pd15">
<div class="soft-man-con"></div>
</div>
</div>
</div>
<script type="text/javascript"> <script type="text/javascript">
resetPluginWinWidth(800); resetPluginWinWidth(800);
pluginService('mysql'); $.getScript( "/plugins/file?name=mysql&f=js/mysql.js", function(){
$.getScript( "/plugins/file?name=mysql&f=js/mysql.js"); pluginService('mysql',$('.plugin_version').attr('version'));
});
</script> </script>
+999 -178
View File
File diff suppressed because it is too large Load Diff
+8 -3
View File
@@ -3,11 +3,16 @@
"tip":"soft", "tip":"soft",
"name":"mysql", "name":"mysql",
"type":"运行环境", "type":"运行环境",
"ps":"MySQL是一种关系数据库管理系统!", "ps":"一种关系数据库管理系统!",
"versions":["5.5","5.6","5.7","8.0"], "coexist": false,
"updates":["5.5.62"], "checks": "server/mysql/VERSION/bin/mysql",
"path": "server/mysql/VERSION",
"todo_versions":["5.6","5.7","8.0"],
"versions":["5.5", "5.6", "5.7","8.0"],
"updates":["5.5.62","5.6.50", "5.7.32","8.0.22"],
"shell":"install.sh", "shell":"install.sh",
"checks":"server/mysql", "checks":"server/mysql",
"path":"server/mysql",
"author":"mysql", "author":"mysql",
"home":"https://dev.mysql.com/downloads/mysql", "home":"https://dev.mysql.com/downloads/mysql",
"date":"2017-11-24", "date":"2017-11-24",
+4
View File
@@ -1,4 +1,8 @@
#!/bin/sh #!/bin/sh
# chkconfig: 2345 55 25
# Description: mysql service
# distro. For CentOS/Redhat run: 'chkconfig --add mysql'
# Copyright Abandoned 1996 TCX DataKonsult AB & Monty Program KB & Detron HB # Copyright Abandoned 1996 TCX DataKonsult AB & Monty Program KB & Detron HB
# This file is public domain and comes with NO WARRANTY of any kind # This file is public domain and comes with NO WARRANTY of any kind
+376
View File
@@ -0,0 +1,376 @@
#!/bin/sh
# Copyright Abandoned 1996 TCX DataKonsult AB & Monty Program KB & Detron HB
# This file is public domain and comes with NO WARRANTY of any kind
# MySQL daemon start/stop script.
# Usually this is put in /etc/init.d (at least on machines SYSV R4 based
# systems) and linked to /etc/rc3.d/S99mysql and /etc/rc0.d/K01mysql.
# When this is done the mysql server will be started when the machine is
# started and shut down when the systems goes down.
# Comments to support chkconfig on RedHat Linux
# chkconfig: 2345 64 36
# description: A very fast and reliable SQL database engine.
# Comments to support LSB init script conventions
### BEGIN INIT INFO
# Provides: mysql
# Required-Start: $local_fs $network $remote_fs
# Should-Start: ypbind nscd ldap ntpd xntpd
# Required-Stop: $local_fs $network $remote_fs
# Default-Start: 2 3 4 5
# Default-Stop: 0 1 6
# Short-Description: start and stop MySQL
# Description: MySQL is a very fast and reliable SQL database engine.
### END INIT INFO
# If you install MySQL on some other places than /Users/midoks/Desktop/fwww/server/mysql, then you
# have to do one of the following things for this script to work:
#
# - Run this script from within the MySQL installation directory
# - Create a /etc/my.cnf file with the following information:
# [mysqld]
# basedir=<path-to-mysql-installation-directory>
# - Add the above to any other configuration file (for example ~/.my.ini)
# and copy my_print_defaults to /usr/bin
# - Add the path to the mysql-installation-directory to the basedir variable
# below.
#
# If you want to affect other MySQL variables, you should make your changes
# in the /etc/my.cnf, ~/.my.cnf or other MySQL configuration files.
# If you change base dir, you must also change datadir. These may get
# overwritten by settings in the MySQL configuration files.
basedir=
datadir=
# Default value, in seconds, afterwhich the script should timeout waiting
# for server start.
# Value here is overriden by value in my.cnf.
# 0 means don't wait at all
# Negative numbers mean to wait indefinitely
service_startup_timeout=900
# Lock directory for RedHat / SuSE.
lockdir='/var/lock/subsys'
lock_file_path="$lockdir/mysql"
# The following variables are only set for letting mysql.server find things.
# Set some defaults
mysqld_pid_file_path=
if test -z "$basedir"
then
basedir=/Users/midoks/Desktop/fwww/server/mysql
bindir=/Users/midoks/Desktop/fwww/server/mysql/bin
if test -z "$datadir"
then
datadir=/Users/midoks/Desktop/fwww/server/mysql/data
fi
sbindir=/Users/midoks/Desktop/fwww/server/mysql/bin
libexecdir=/Users/midoks/Desktop/fwww/server/mysql/bin
else
bindir="$basedir/bin"
if test -z "$datadir"
then
datadir="$basedir/data"
fi
sbindir="$basedir/sbin"
libexecdir="$basedir/libexec"
fi
# datadir_set is used to determine if datadir was set (and so should be
# *not* set inside of the --basedir= handler.)
datadir_set=
#
# Use LSB init script functions for printing messages, if possible
#
lsb_functions="/lib/lsb/init-functions"
if test -f $lsb_functions ; then
. $lsb_functions
else
log_success_msg()
{
echo " SUCCESS! $@"
}
log_failure_msg()
{
echo " ERROR! $@"
}
fi
PATH="/sbin:/usr/sbin:/bin:/usr/bin:$basedir/bin"
export PATH
mode=$1 # start or stop
[ $# -ge 1 ] && shift
other_args="$*" # uncommon, but needed when called from an RPM upgrade action
# Expected: "--skip-networking --skip-grant-tables"
# They are not checked here, intentionally, as it is the resposibility
# of the "spec" file author to give correct arguments only.
case `echo "testing\c"`,`echo -n testing` in
*c*,-n*) echo_n= echo_c= ;;
*c*,*) echo_n=-n echo_c= ;;
*) echo_n= echo_c='\c' ;;
esac
parse_server_arguments() {
for arg do
case "$arg" in
--basedir=*) basedir=`echo "$arg" | sed -e 's/^[^=]*=//'`
bindir="$basedir/bin"
if test -z "$datadir_set"; then
datadir="$basedir/data"
fi
sbindir="$basedir/sbin"
libexecdir="$basedir/libexec"
;;
--datadir=*) datadir=`echo "$arg" | sed -e 's/^[^=]*=//'`
datadir_set=1
;;
--pid-file=*) mysqld_pid_file_path=`echo "$arg" | sed -e 's/^[^=]*=//'` ;;
--service-startup-timeout=*) service_startup_timeout=`echo "$arg" | sed -e 's/^[^=]*=//'` ;;
esac
done
}
wait_for_pid () {
verb="$1" # created | removed
pid="$2" # process ID of the program operating on the pid-file
pid_file_path="$3" # path to the PID file.
i=0
avoid_race_condition="by checking again"
while test $i -ne $service_startup_timeout ; do
case "$verb" in
'created')
# wait for a PID-file to pop into existence.
test -s "$pid_file_path" && i='' && break
;;
'removed')
# wait for this PID-file to disappear
test ! -s "$pid_file_path" && i='' && break
;;
*)
echo "wait_for_pid () usage: wait_for_pid created|removed pid pid_file_path"
exit 1
;;
esac
# if server isn't running, then pid-file will never be updated
if test -n "$pid"; then
if kill -0 "$pid" 2>/dev/null; then
: # the server still runs
else
# The server may have exited between the last pid-file check and now.
if test -n "$avoid_race_condition"; then
avoid_race_condition=""
continue # Check again.
fi
# there's nothing that will affect the file.
log_failure_msg "The server quit without updating PID file ($pid_file_path)."
return 1 # not waiting any more.
fi
fi
echo $echo_n ".$echo_c"
i=`expr $i + 1`
sleep 1
done
if test -z "$i" ; then
log_success_msg
return 0
else
log_failure_msg
return 1
fi
}
# Get arguments from the my.cnf file,
# the only group, which is read from now on is [mysqld]
if test -x "$bindir/my_print_defaults"; then
print_defaults="$bindir/my_print_defaults"
else
# Try to find basedir in /etc/my.cnf
conf=/etc/my.cnf
print_defaults=
if test -r $conf
then
subpat='^[^=]*basedir[^=]*=\(.*\)$'
dirs=`sed -e "/$subpat/!d" -e 's//\1/' $conf`
for d in $dirs
do
d=`echo $d | sed -e 's/[ ]//g'`
if test -x "$d/bin/my_print_defaults"
then
print_defaults="$d/bin/my_print_defaults"
break
fi
done
fi
# Hope it's in the PATH ... but I doubt it
test -z "$print_defaults" && print_defaults="my_print_defaults"
fi
#
# Read defaults file from 'basedir'. If there is no defaults file there
# check if it's in the old (depricated) place (datadir) and read it from there
#
extra_args=""
if test -r "$basedir/my.cnf"
then
extra_args="-e $basedir/my.cnf"
fi
parse_server_arguments `$print_defaults $extra_args mysqld server mysql_server mysql.server`
#
# Set pid file if not given
#
if test -z "$mysqld_pid_file_path"
then
mysqld_pid_file_path=$datadir/`hostname`.pid
else
case "$mysqld_pid_file_path" in
/* ) ;;
* ) mysqld_pid_file_path="$datadir/$mysqld_pid_file_path" ;;
esac
fi
case "$mode" in
'start')
# Start daemon
# Safeguard (relative paths, core dumps..)
cd $basedir
echo $echo_n "Starting MySQL"
if test -x $bindir/mysqld_safe
then
# Give extra arguments to mysqld with the my.cnf file. This script
# may be overwritten at next upgrade.
$bindir/mysqld_safe --datadir="$datadir" --pid-file="$mysqld_pid_file_path" $other_args >/dev/null &
wait_for_pid created "$!" "$mysqld_pid_file_path"; return_value=$?
# Make lock for RedHat / SuSE
if test -w "$lockdir"
then
touch "$lock_file_path"
fi
exit $return_value
else
log_failure_msg "Couldn't find MySQL server ($bindir/mysqld_safe)"
fi
;;
'stop')
# Stop daemon. We use a signal here to avoid having to know the
# root password.
if test -s "$mysqld_pid_file_path"
then
# signal mysqld_safe that it needs to stop
touch "$mysqld_pid_file_path.shutdown"
mysqld_pid=`cat "$mysqld_pid_file_path"`
if (kill -0 $mysqld_pid 2>/dev/null)
then
echo $echo_n "Shutting down MySQL"
kill $mysqld_pid
# mysqld should remove the pid file when it exits, so wait for it.
wait_for_pid removed "$mysqld_pid" "$mysqld_pid_file_path"; return_value=$?
else
log_failure_msg "MySQL server process #$mysqld_pid is not running!"
rm "$mysqld_pid_file_path"
fi
# Delete lock for RedHat / SuSE
if test -f "$lock_file_path"
then
rm -f "$lock_file_path"
fi
exit $return_value
else
log_failure_msg "MySQL server PID file could not be found!"
fi
;;
'restart')
# Stop the service and regardless of whether it was
# running or not, start it again.
if $0 stop $other_args; then
$0 start $other_args
else
log_failure_msg "Failed to stop running server, so refusing to try to start."
exit 1
fi
;;
'reload'|'force-reload')
if test -s "$mysqld_pid_file_path" ; then
read mysqld_pid < "$mysqld_pid_file_path"
kill -HUP $mysqld_pid && log_success_msg "Reloading service MySQL"
touch "$mysqld_pid_file_path"
else
log_failure_msg "MySQL PID file could not be found!"
exit 1
fi
;;
'status')
# First, check to see if pid file exists
if test -s "$mysqld_pid_file_path" ; then
read mysqld_pid < "$mysqld_pid_file_path"
if kill -0 $mysqld_pid 2>/dev/null ; then
log_success_msg "MySQL running ($mysqld_pid)"
exit 0
else
log_failure_msg "MySQL is not running, but PID file exists"
exit 1
fi
else
# Try to find appropriate mysqld process
mysqld_pid=`pgrep -d' ' -f $libexecdir/mysqld`
# test if multiple pids exist
pid_count=`echo $mysqld_pid | wc -w`
if test $pid_count -gt 1 ; then
log_failure_msg "Multiple MySQL running but PID file could not be found ($mysqld_pid)"
exit 5
elif test -z $mysqld_pid ; then
if test -f "$lock_file_path" ; then
log_failure_msg "MySQL is not running, but lock file ($lock_file_path) exists"
exit 2
fi
log_failure_msg "MySQL is not running"
exit 3
else
log_failure_msg "MySQL is running but PID file could not be found"
exit 4
fi
fi
;;
*)
# usage
basename=`basename "$0"`
echo "Usage: $basename {start|stop|restart|reload|force-reload|status} [ MySQL server options ]"
exit 1
;;
esac
exit 0
+624 -14
View File
@@ -36,6 +36,26 @@ function myPost(method,args,callback, title){
},'json'); },'json');
} }
function myPostN(method,args,callback, title){
var _args = null;
if (typeof(args) == 'string'){
_args = JSON.stringify(str2Obj(args));
} else {
_args = JSON.stringify(args);
}
var _title = '正在获取...';
if (typeof(title) != 'undefined'){
_title = title;
}
$.post('/plugins/run', {name:'mysql', func:method, args:_args}, function(data) {
if(typeof(callback) == 'function'){
callback(data);
}
},'json');
}
function myAsyncPost(method,args){ function myAsyncPost(method,args){
var _args = null; var _args = null;
if (typeof(args) == 'string'){ if (typeof(args) == 'string'){
@@ -822,6 +842,86 @@ function openPhpmyadmin(name,username,password){
},200); },200);
} }
function delBackup(filename,name){
myPost('delete_db_backup',{filename:filename},function(){
layer.msg('执行成功!');
setTimeout(function(){
$('.layui-layer-close2').click();
setBackup(name);
},2000);
});
}
function downloadBackup(file){
window.open('/files/download?filename='+encodeURIComponent(file));
}
function importBackup(file,name){
myPost('import_db_backup',{file:file,name:name}, function(data){
// console.log(data);
layer.msg('执行成功!');
});
}
function setBackup(db_name,obj){
myPost('get_db_backup_list', {name:db_name}, function(data){
var rdata = $.parseJSON(data.data);
var tbody = '';
for (var i = 0; i < rdata.data.length; i++) {
tbody += '<tr>\
<td><span> ' + rdata.data[i]['name'] + '</span></td>\
<td><span> ' + rdata.data[i]['size'] + '</span></td>\
<td><span> ' + rdata.data[i]['time'] + '</span></td>\
<td style="text-align: right;">\
<a class="btlink" onclick="importBackup(\'' + rdata.data[i]['name'] + '\',\'' +db_name+ '\')">导入</a> | \
<a class="btlink" onclick="downloadBackup(\'' + rdata.data[i]['file'] + '\')">下载</a> | \
<a class="btlink" onclick="delBackup(\'' + rdata.data[i]['name'] + '\',\'' +db_name+ '\')">删除</a>\
</td>\
</tr> ';
}
var s = layer.open({
type: 1,
title: "数据库备份详情",
area: ['600px', '280px'],
closeBtn: 2,
shadeClose: false,
content: '<div class="pd15">\
<div class="db_list">\
<button id="btn_backup" class="btn btn-success btn-sm" type="button">备份</button>\
</div >\
<div class="divtable">\
<div id="database_fix" style="height:150px;overflow:auto;border:#ddd 1px solid">\
<table class="table table-hover "style="border:none">\
<thead>\
<tr>\
<th>文件名称</th>\
<th>文件大小</th>\
<th>备份时间</th>\
<th style="text-align: right;">操作</th>\
</tr>\
</thead>\
<tbody class="gztr">' + tbody + '</tbody>\
</table>\
</div>\
</div>\
</div>'
});
$('#btn_backup').click(function(){
myPost('set_db_backup',{name:db_name}, function(data){
layer.msg('执行成功!');
setTimeout(function(){
layer.close(s);
setBackup(db_name,obj);
},2000);
});
});
});
}
function dbList(page, search){ function dbList(page, search){
var _data = {}; var _data = {};
@@ -847,10 +947,14 @@ function dbList(page, search){
'<span onclick="showHidePass(this)" class="glyphicon glyphicon-eye-open cursor pw-ico" style="margin-left:10px"></span>'+ '<span onclick="showHidePass(this)" class="glyphicon glyphicon-eye-open cursor pw-ico" style="margin-left:10px"></span>'+
'<span class="ico-copy cursor btcopy" style="margin-left:10px" title="复制密码" onclick="copyPass(\''+rdata.data[i]['password']+'\')"></span>'+ '<span class="ico-copy cursor btcopy" style="margin-left:10px" title="复制密码" onclick="copyPass(\''+rdata.data[i]['password']+'\')"></span>'+
'</td>'; '</td>';
// list += '<td>备份</td>';
list += '<td><span class="c9 input-edit" onclick="setDbPs(\''+rdata.data[i]['id']+'\',\''+rdata.data[i]['name']+'\',this)" style="display: inline-block;">'+rdata.data[i]['ps']+'</span></td>'; list += '<td><span class="c9 input-edit" onclick="setDbPs(\''+rdata.data[i]['id']+'\',\''+rdata.data[i]['name']+'\',this)" style="display: inline-block;">'+rdata.data[i]['ps']+'</span></td>';
list += '<td style="text-align:right">' + list += '<td style="text-align:right">';
'<a href="javascript:;" class="btlink" onclick="openPhpmyadmin(\''+rdata.data[i]['name']+'\',\''+rdata.data[i]['username']+'\',\''+rdata.data[i]['password']+'\')" title="数据库管理">管理</a> | ' +
list += '<a href="javascript:;" class="btlink" class="btlink" onclick="setBackup(\''+rdata.data[i]['name']+'\',this)" title="数据库备份">'+(rdata.data[i]['is_backup']?'备份':'未备份') +'</a> | ';
list += '<a href="javascript:;" class="btlink" onclick="openPhpmyadmin(\''+rdata.data[i]['name']+'\',\''+rdata.data[i]['username']+'\',\''+rdata.data[i]['password']+'\')" title="数据库管理">管理</a> | ' +
'<a href="javascript:;" class="btlink" onclick="repTools(\''+rdata.data[i]['name']+'\')" title="MySQL优化修复工具">工具</a> | ' + '<a href="javascript:;" class="btlink" onclick="repTools(\''+rdata.data[i]['name']+'\')" title="MySQL优化修复工具">工具</a> | ' +
'<a href="javascript:;" class="btlink" onclick="setDbAccess(\''+rdata.data[i]['username']+'\')" title="设置数据库权限">权限</a> | ' + '<a href="javascript:;" class="btlink" onclick="setDbAccess(\''+rdata.data[i]['username']+'\')" title="设置数据库权限">权限</a> | ' +
'<a href="javascript:;" class="btlink" onclick="setDbPass('+rdata.data[i]['id']+',\''+ rdata.data[i]['username'] +'\',\'' + rdata.data[i]['password'] + '\')">改密</a> | ' + '<a href="javascript:;" class="btlink" onclick="setDbPass('+rdata.data[i]['id']+',\''+ rdata.data[i]['username'] +'\',\'' + rdata.data[i]['password'] + '\')">改密</a> | ' +
@@ -864,6 +968,7 @@ function dbList(page, search){
<button onclick="addDatabase()" title="添加数据库" class="btn btn-success btn-sm" type="button" style="margin-right: 5px;">添加数据库</button>\ <button onclick="addDatabase()" title="添加数据库" class="btn btn-success btn-sm" type="button" style="margin-right: 5px;">添加数据库</button>\
<button onclick="setRootPwd(0,\''+rdata.info['root_pwd']+'\')" title="设置MySQL管理员密码" class="btn btn-default btn-sm" type="button" style="margin-right: 5px;">root密码</button>\ <button onclick="setRootPwd(0,\''+rdata.info['root_pwd']+'\')" title="设置MySQL管理员密码" class="btn btn-default btn-sm" type="button" style="margin-right: 5px;">root密码</button>\
<button onclick="openPhpmyadmin(\'\',\'root\',\''+rdata.info['root_pwd']+'\')" title="打开phpMyadmin" class="btn btn-default btn-sm" type="button" style="margin-right: 5px;">phpMyAdmin</button>\ <button onclick="openPhpmyadmin(\'\',\'root\',\''+rdata.info['root_pwd']+'\')" title="打开phpMyadmin" class="btn btn-default btn-sm" type="button" style="margin-right: 5px;">phpMyAdmin</button>\
<button onclick="setDbAccess(\'root\')" title="ROOT权限" class="btn btn-default btn-sm" type="button" style="margin-right: 5px;">ROOT权限</button>\
<span style="float:right"> \ <span style="float:right"> \
<button batch="true" style="float: right;display: none;margin-left:10px;" onclick="delDbBatch();" title="删除选中项" class="btn btn-default btn-sm">删除选中</button>\ <button batch="true" style="float: right;display: none;margin-left:10px;" onclick="delDbBatch();" title="删除选中项" class="btn btn-default btn-sm">删除选中</button>\
</span>\ </span>\
@@ -1097,16 +1202,521 @@ function repTools(db_name, res){
</ul></div>' </ul></div>'
}); });
tableFixed('database_fix'); tableFixed('database_fix');
//表格头固定
function tableFixed(name) {
var tableName = document.querySelector('#' + name);
tableName.addEventListener('scroll', scrollHandle);
}
function scrollHandle(e) {
var scrollTop = this.scrollTop;
//this.querySelector('thead').style.transform = 'translateY(' + scrollTop + 'px)';
$(this).find("thead").css({ "transform": "translateY(" + scrollTop + "px)", "position": "relative", "z-index": "1" });
}
}); });
} }
function setDbMaster(name){
myPost('set_db_master', {name:name}, function(data){
var rdata = $.parseJSON(data.data);
layer.msg(rdata.msg, { icon: rdata.status ? 1 : 5 });
setTimeout(function(){
masterOrSlaveConf();
}, 2000);
});
}
function setDbSlave(name){
myPost('set_db_slave', {name:name}, function(data){
var rdata = $.parseJSON(data.data);
layer.msg(rdata.msg, { icon: rdata.status ? 1 : 5 });
setTimeout(function(){
masterOrSlaveConf();
}, 2000);
});
}
function addMasterRepSlaveUser(){
var index = layer.open({
type: 1,
skin: 'demo-class',
area: '500px',
title: '添加同步账户',
closeBtn: 1,
shift: 5,
shadeClose: true,
content: "<form class='bt-form pd20 pb70' id='add_master'>\
<div class='line'><span class='tname'>用户名</span><div class='info-r'><input name='username' class='bt-input-text mr5' placeholder='用户名' type='text' style='width:330px;' value='"+(randomStrPwd(6))+"'></div></div>\
<div class='line'>\
<span class='tname'>密码</span>\
<div class='info-r'><input class='bt-input-text mr5' type='text' name='password' id='MyPassword' style='width:330px' value='"+(randomStrPwd(16))+"' /><span title='随机密码' class='glyphicon glyphicon-repeat cursor' onclick='repeatPwd(16)'></span></div>\
</div>\
<input type='hidden' name='ps' value='' />\
<div class='bt-form-submit-btn'>\
<button id='my_mod_close' type='button' class='btn btn-danger btn-sm btn-title'>关闭</button>\
<button type='button' class='btn btn-success btn-sm btn-title' id='submit_add_master' >提交</button>\
</div>\
</form>",
});
// <div class='line'>\
// <span class='tname'>访问权限</span>\
// <div class='info-r '>\
// <select class='bt-input-text mr5' name='dataAccess' style='width:100px'>\
// <option value='127.0.0.1'>本地服务器</option>\
// <option value=\"%\">所有人</option>\
// <option value='ip'>指定IP</option>\
// </select>\
// </div>\
// </div>\
$("input[name='name']").keyup(function(){
var v = $(this).val();
$("input[name='db_user']").val(v);
$("input[name='ps']").val(v);
});
$('#my_mod_close').click(function(){
$('.layui-layer-close1').click();
});
$('select[name="dataAccess"]').change(function(){
var v = $(this).val();
if (v == 'ip'){
$(this).after("<input id='dataAccess_subid' class='bt-input-text mr5' type='text' name='address' placeholder='多个IP使用逗号(,)分隔' style='width: 230px; display: inline-block;'>");
} else {
$('#dataAccess_subid').remove();
}
});
$('#submit_add_master').click(function(){
var data = $("#add_master").serialize();
data = decodeURIComponent(data);
var dataObj = str2Obj(data);
if(!dataObj['address']){
dataObj['address'] = dataObj['dataAccess'];
}
// console.log(dataObj);
myPost('add_master_rep_slave_user', dataObj, function(data){
var rdata = $.parseJSON(data.data);
showMsg(rdata.msg,function(){
if (rdata.status){
getMasterRepSlaveList();
}
$('.layui-layer-close1').click();
},{icon: rdata.status ? 1 : 2},600);
});
});
}
function updateMasterRepSlaveUser(username){
var index = layer.open({
type: 1,
skin: 'demo-class',
area: '500px',
title: '更新账户',
closeBtn: 1,
shift: 5,
shadeClose: true,
content: "<form class='bt-form pd20 pb70' id='update_master'>\
<div class='line'><span class='tname'>用户名</span><div class='info-r'><input name='username' readonly='readonly' class='bt-input-text mr5' placeholder='用户名' type='text' style='width:330px;' value='"+username+"'></div></div>\
<div class='line'>\
<span class='tname'>密码</span>\
<div class='info-r'><input class='bt-input-text mr5' type='text' name='password' id='MyPassword' style='width:330px' value='"+(randomStrPwd(16))+"' /><span title='随机密码' class='glyphicon glyphicon-repeat cursor' onclick='repeatPwd(16)'></span></div>\
</div>\
<input type='hidden' name='ps' value='' />\
<div class='bt-form-submit-btn'>\
<button type='button' class='btn btn-success btn-sm btn-title' id='submit_update_master' >提交</button>\
</div>\
</form>",
});
$('#submit_update_master').click(function(){
var data = $("#update_master").serialize();
data = decodeURIComponent(data);
var dataObj = str2Obj(data);
// console.log(dataObj);
myPost('update_master_rep_slave_user', data, function(data){
var rdata = $.parseJSON(data.data);
showMsg(rdata.msg,function(){
if (rdata.status){
getMasterRepSlaveList();
}
$('.layui-layer-close1').click();
},{icon: rdata.status ? 1 : 2},600);
});
});
}
function getMasterRepSlaveUserCmd(username, db=''){
myPost('get_master_rep_slave_user_cmd', {username:username,db:db}, function(data){
var rdata = $.parseJSON(data.data);
if (!rdata['status']){
layer.msg(rdata['msg']);
return;
}
var loadOpen = layer.open({
type: 1,
title: '同步命令',
area: '500px',
content:"<form class='bt-form pd20 pb70' id='add_master'>\
<div class='line'>"+rdata.data+"</div>\
<div class='bt-form-submit-btn'>\
<button type='button' class='btn btn-success btn-sm btn-title class-copy-cmd'>复制</button>\
</div>\
</form>",
});
copyPass(rdata.data);
$('.class-copy-cmd').click(function(){
copyPass(rdata.data);
});
});
}
function delMasterRepSlaveUser(username){
myPost('del_master_rep_slave_user', {username:username}, function(data){
var rdata = $.parseJSON(data.data);
layer.msg(rdata.msg);
$('.layui-layer-close1').click();
setTimeout(function(){
getMasterRepSlaveList();
},1000);
});
}
function getMasterRepSlaveList(){
var _data = {};
if (typeof(page) =='undefined'){
var page = 1;
}
_data['page'] = page;
_data['page_size'] = 10;
myPost('get_master_rep_slave_list', _data, function(data){
// console.log(data);
var rdata = [];
try {
rdata = $.parseJSON(data.data);
} catch(e){
console.log(e);
}
var list = '';
// console.log(rdata['data']);
var user_list = rdata['data'];
for (i in user_list) {
// console.log(i);
var name = user_list[i]['username'];
list += '<tr><td>'+name+'</td>\
<td>'+user_list[i]['password']+'</td>\
<td>\
<a class="btlink" onclick="updateMasterRepSlaveUser(\''+name+'\');">修改</a> | \
<a class="btlink" onclick="delMasterRepSlaveUser(\''+name+'\');">删除</a> | \
<a class="btlink" onclick="getMasterRepSlaveUserCmd(\''+name+'\');">从库同步命令</a>\
</td>\
</tr>';
}
var page = '<div class="dataTables_paginate_4 dataTables_paginate paging_bootstrap page" style="margin-top:0px;"></div>';
page += '<div class="table_toolbar"><span class="sync btn btn-default btn-sm" onclick="addMasterRepSlaveUser()" title="">添加同步账户</span></div>';
var loadOpen = layer.open({
type: 1,
title: '同步账户列表',
area: '500px',
content:"<div class='bt-form pd20 c6'>\
<div class='divtable mtb10'>\
<div><table class='table table-hover'>\
<thead><tr><th>用户民</th><th>密码</th><th>操作</th></tr></thead>\
<tbody>" + list + "</tbody>\
</table></div>\
"+page +"\
</div>\
</div>"
});
$('.dataTables_paginate_4').html(rdata['page']);
});
}
function deleteSlave(){
myPost('delete_slave', {}, function(data){
var rdata = $.parseJSON(data.data);
layer.msg(rdata['msg']);
setTimeout(function(){
masterOrSlaveConf();
}, 3000);
});
}
function getFullSyncStatus(db){
var btn = '<div class="table_toolbar"><span class="sync btn btn-default btn-sm" id="begin_full_sync" title="">开始</span></div>';
var loadOpen = layer.open({
type: 1,
title: '全量同步['+db+']',
area: '500px',
content:"<div class='bt-form pd20 c6'>\
<div class='divtable mtb10'>\
<span id='full_msg'></span>\
<div class='progress'>\
<div class='progress-bar' role='progressbar' aria-valuenow='0' aria-valuemin='0' aria-valuemax='100' style='min-width: 2em;'>0%</div>\
</div>\
</div>\
"+btn+"\
</div>"
});
var timeId = setInterval(function(){
fullSync(db,0);
}, 1000);
function fullSync(db,begin){
myPostN('full_sync', {db:db,begin:begin}, function(data){
var rdata = $.parseJSON(data.data);
$('#full_msg').text(rdata['msg']);
$('.progress-bar').css('width',rdata['progress']+'%');
$('.progress-bar').text(rdata['progress']+'%');
if (rdata['code']==6 ||rdata['code']<0){
layer.msg(rdata['msg']);
clearInterval(timeId);
}
});
}
fullSync(db,0);
$('#begin_full_sync').click(function(){
fullSync(db,1);
timeId= setTimeout(function(){
fullSync(db,0);
}, 1000);
});
$('.layui-layer-close1').click(function(){
clearInterval(timeId);
});
}
function handlerRun(){
cmd = 'cd /www/server/mdserver-web && python /www/server/mdserver-web/plugins/mysql/index.py do_full_sync {"db":"all"}';
var loadOpen = layer.open({
type: 1,
title: '手动执行',
area: '500px',
content:"<form class='bt-form pd20 pb70' id='add_master'>\
<div class='line'>"+cmd+"</div>\
<div class='bt-form-submit-btn'>\
<button type='button' class='btn btn-success btn-sm btn-title class-copy-cmd'>复制</button>\
</div>\
</form>",
});
copyPass(cmd);
$('.class-copy-cmd').click(function(){
copyPass(cmd);
});
}
function masterOrSlaveConf(version=''){
function getMasterDbList(){
var _data = {};
if (typeof(page) =='undefined'){
var page = 1;
}
_data['page'] = page;
_data['page_size'] = 10;
myPost('get_masterdb_list', _data, function(data){
var rdata = $.parseJSON(data.data);
var list = '';
for(i in rdata.data){
list += '<tr>';
list += '<td>' + rdata.data[i]['name'] +'</td>';
list += '<td>' + (rdata.data[i]['master']?'是':'否') +'</td>';
list += '<td style="text-align:right">' +
'<a href="javascript:;" class="btlink" onclick="setDbMaster(\''+rdata.data[i]['name']+'\')" title="加入或退出">'+(rdata.data[i]['master']?'退出':'加入')+'</a> | ' +
'<a href="javascript:;" class="btlink" onclick="getMasterRepSlaveUserCmd(\'\',\''+rdata.data[i]['name']+'\')" title="同步命令">同步命令</a>' +
'</td>';
list += '</tr>';
}
var con = '<div class="divtable mtb10">\
<div class="tablescroll">\
<table id="DataBody" class="table table-hover" width="100%" cellspacing="0" cellpadding="0" border="0" style="border: 0 none;">\
<thead><tr>\
<th>数据库名</th>\
<th>同步</th>\
<th style="text-align:right;">操作</th></tr></thead>\
<tbody>\
'+ list +'\
</tbody></table>\
</div>\
<div id="databasePage" class="dataTables_paginate paging_bootstrap page"></div>\
<div class="table_toolbar">\
<span class="sync btn btn-default btn-sm" onclick="getMasterRepSlaveList()" title="">同步账户列表</span>\
</div>\
</div>';
$(".table_master_list").html(con);
$('#databasePage').html(rdata.page);
});
}
function getAsyncMasterDbList(){
var _data = {};
if (typeof(page) =='undefined'){
var page = 1;
}
_data['page'] = page;
_data['page_size'] = 10;
myPost('get_slave_list', _data, function(data){
var rdata = $.parseJSON(data.data);
var list = '';
for(i in rdata.data){
list += '<tr>';
list += '<td>' + rdata.data[i]['Master_Host'] +'</td>';
list += '<td>' + rdata.data[i]['Master_Port'] +'</td>';
list += '<td>' + rdata.data[i]['Master_User'] +'</td>';
list += '<td>' + rdata.data[i]['Master_Log_File'] +'</td>';
list += '<td>' + rdata.data[i]['Slave_IO_Running'] +'</td>';
list += '<td>' + rdata.data[i]['Slave_SQL_Running'] +'</td>';
list += '<td style="text-align:right">' +
'<a href="javascript:;" class="btlink" onclick="deleteSlave()" title="删除">删除</a>' +
'</td>';
list += '</tr>';
}
var con = '<div class="divtable mtb10">\
<div class="tablescroll">\
<table id="DataBody" class="table table-hover" width="100%" cellspacing="0" cellpadding="0" border="0" style="border: 0 none;">\
<thead><tr>\
<th>主[服务]</th>\
<th>端口</th>\
<th>用户</th>\
<th>日志</th>\
<th>IO</th>\
<th>SQL</th>\
<th style="text-align:right;">操作</th></tr></thead>\
<tbody>\
'+ list +'\
</tbody></table>\
</div>\
</div>';
// <div id="databasePage_slave" class="dataTables_paginate paging_bootstrap page"></div>\
// <div class="table_toolbar">\
// <span class="sync btn btn-default btn-sm" onclick="getMasterRepSlaveList()" title="">添加</span>\
// </div>
$(".table_slave_status_list").html(con);
});
}
function getAsyncDataList(){
var _data = {};
if (typeof(page) =='undefined'){
var page = 1;
}
_data['page'] = page;
_data['page_size'] = 10;
myPost('get_masterdb_list', _data, function(data){
var rdata = $.parseJSON(data.data);
var list = '';
for(i in rdata.data){
list += '<tr>';
list += '<td>' + rdata.data[i]['name'] +'</td>';
list += '<td style="text-align:right">' +
'<a href="javascript:;" class="btlink" onclick="setDbSlave(\''+rdata.data[i]['name']+'\')" title="加入|退出">'+(rdata.data[i]['slave']?'退出':'加入')+'</a> | ' +
'<a href="javascript:;" class="btlink" onclick="getFullSyncStatus(\''+rdata.data[i]['name']+'\')" title="修复">修复</a>' +
'</td>';
list += '</tr>';
}
var con = '<div class="divtable mtb10">\
<div class="tablescroll">\
<table id="DataBody" class="table table-hover" width="100%" cellspacing="0" cellpadding="0" border="0" style="border: 0 none;">\
<thead><tr>\
<th>本地库名</th>\
<th style="text-align:right;">操作</th></tr></thead>\
<tbody>\
'+ list +'\
</tbody></table>\
</div>\
<div id="databasePage" class="dataTables_paginate paging_bootstrap page"></div>\
<div class="table_toolbar">\
<span class="sync btn btn-default btn-sm" onclick="handlerRun()" title="免登录设置后,需要手动执行一下!">手动命令</span>\
<span class="sync btn btn-default btn-sm" onclick="getFullSyncStatus(\'ALL\')" title="全量同步">全量同步</span>\
</div>\
</div>';
$(".table_slave_list").html(con);
$('#databasePage').html(rdata.page);
});
}
function getMasterStatus(){
myPost('get_master_status', '', function(data){
var rdata = $.parseJSON(data.data);
var limitCon = '<p class="conf_p">\
<span class="f14 c6 mr20">Master[主]配置</span><span class="f14 c6 mr20"></span>\
<button class="btn '+(!rdata.status ? 'btn-danger' : 'btn-success')+' btn-xs btn-master va0">'+(!rdata.status ? '未开启' : '已开启') +'</button><hr/>\
</p>\
<!-- master list -->\
<div class="safe bgw table_master_list"></div>\
<hr/>\
<p class="conf_p">\
<span class="f14 c6 mr20">Slave[从]配置</span><span class="f14 c6 mr20"></span>\
<button class="btn '+(!rdata.data.slave_status ? 'btn-danger' : 'btn-success')+' btn-xs btn-slave va0">'+(!rdata.data.slave_status ? '未启动' : '已启动') +'</button><hr/>\
</p>\
<!-- slave status list -->\
<div class="safe bgw table_slave_status_list"></div>\
<!-- slave list -->\
<div class="safe bgw table_slave_list"></div>\
';
$(".soft-man-con").html(limitCon);
//设置主服务器配置
$(".btn-master").click(function () {
myPost('set_master_status', 'close=change', function(data){
var rdata = $.parseJSON(data.data);
layer.msg(rdata.msg, { icon: rdata.status ? 1 : 5 });
setTimeout(function(){
getMasterStatus();
}, 3000);
});
});
$(".btn-slave").click(function () {
myPost('set_slave_status', 'close=change', function(data){
var rdata = $.parseJSON(data.data);
layer.msg(rdata.msg, { icon: rdata.status ? 1 : 5 });
setTimeout(function(){
getMasterStatus();
}, 3000);
});
});
if (rdata.status){
getMasterDbList();
}
if (rdata.data.slave_status){
getAsyncMasterDbList();
getAsyncDataList()
}
});
}
getMasterStatus();
}
+26 -23
View File
@@ -9,7 +9,7 @@ curPath=`pwd`
rootPath=$(dirname "$curPath") rootPath=$(dirname "$curPath")
rootPath=$(dirname "$rootPath") rootPath=$(dirname "$rootPath")
serverPath=$(dirname "$rootPath") serverPath=$(dirname "$rootPath")
sysName=`uname`
install_tmp=${rootPath}/tmp/mw_install.pl install_tmp=${rootPath}/tmp/mw_install.pl
mysqlDir=${serverPath}/source/mysql mysqlDir=${serverPath}/source/mysql
@@ -19,37 +19,40 @@ Install_mysql()
mkdir -p ${mysqlDir} mkdir -p ${mysqlDir}
echo '正在安装脚本文件...' > $install_tmp echo '正在安装脚本文件...' > $install_tmp
mkdir -p /var/log/mariadb if [ "$sysName" != "Darwin" ];then
touch /var/log/mariadb/mariadb.log mkdir -p /var/log/mariadb
touch /var/log/mariadb/mariadb.log
groupadd mysql groupadd mysql
useradd -g mysql mysql useradd -g mysql mysql
fi
if [ ! -f ${mysqlDir}/mysql-5.5.62.tar.gz ];then if [ ! -f ${mysqlDir}/mysql-5.5.62.tar.gz ];then
wget -O ${mysqlDir}/mysql-5.5.62.tar.gz https://dev.mysql.com/get/Downloads/MySQL-5.5/mysql-5.5.62.tar.gz wget -O ${mysqlDir}/mysql-5.5.62.tar.gz https://dev.mysql.com/get/Downloads/MySQL-5.5/mysql-5.5.62.tar.gz
fi fi
if [ ! -f ${mysqlDir}/mysql-5.5.62 ];then if [ ! -d ${mysqlDir}/mysql-5.5.62 ];then
cd ${mysqlDir} && tar -zxvf ${mysqlDir}/mysql-5.5.62.tar.gz cd ${mysqlDir} && tar -zxvf ${mysqlDir}/mysql-5.5.62.tar.gz
fi fi
cd ${mysqlDir}/mysql-5.5.62 && cmake \ if [ ! -d $serverPath/mysql ];then
-DCMAKE_INSTALL_PREFIX=$serverPath/mysql \ cd ${mysqlDir}/mysql-5.5.62 && cmake \
-DMYSQL_USER=mysql \ -DCMAKE_INSTALL_PREFIX=$serverPath/mysql \
-DMYSQL_TCP_PORT=3306 \ -DMYSQL_USER=mysql \
-DMYSQL_UNIX_ADDR=/var/tmp/mysql.sock \ -DMYSQL_TCP_PORT=3306 \
-DWITH_MYISAM_STORAGE_ENGINE=1 \ -DMYSQL_UNIX_ADDR=/var/tmp/mysql.sock \
-DWITH_INNOBASE_STORAGE_ENGINE=1 \ -DWITH_MYISAM_STORAGE_ENGINE=1 \
-DWITH_MEMORY_STORAGE_ENGINE=1 \ -DWITH_INNOBASE_STORAGE_ENGINE=1 \
-DENABLED_LOCAL_INFILE=1 \ -DWITH_MEMORY_STORAGE_ENGINE=1 \
-DWITH_PARTITION_STORAGE_ENGINE=1 \ -DENABLED_LOCAL_INFILE=1 \
-DEXTRA_CHARSETS=all \ -DWITH_PARTITION_STORAGE_ENGINE=1 \
-DDEFAULT_CHARSET=utf8 \ -DEXTRA_CHARSETS=all \
-DDEFAULT_COLLATION=utf8_general_ci \ -DDEFAULT_CHARSET=utf8 \
&& make && make install && make clean \ -DDEFAULT_COLLATION=utf8_general_ci \
&& echo '5.5' > $serverPath/mysql/version.pl && make && make install && make clean \
echo '安装完成' > $install_tmp && echo '5.5' > $serverPath/mysql/version.pl
echo '安装完成' > $install_tmp
fi
} }
Uninstall_mysql() Uninstall_mysql()
+73
View File
@@ -0,0 +1,73 @@
# -*- coding: utf-8 -*-
#!/bin/bash
PATH=/bin:/sbin:/usr/bin:/usr/sbin:/usr/local/bin:/usr/local/sbin:~/bin
export PATH
#https://dev.mysql.com/downloads/mysql/5.6.html
#https://dev.mysql.com/downloads/file/?id=489600
curPath=`pwd`
rootPath=$(dirname "$curPath")
rootPath=$(dirname "$rootPath")
serverPath=$(dirname "$rootPath")
sysName=`uname`
install_tmp=${rootPath}/tmp/mw_install.pl
mysqlDir=${serverPath}/source/mysql
Install_mysql()
{
mkdir -p ${mysqlDir}
echo '正在安装脚本文件...' > $install_tmp
if [ "$sysName" != "Darwin" ];then
mkdir -p /var/log/mariadb
touch /var/log/mariadb/mariadb.log
groupadd mysql
useradd -g mysql mysql
fi
if [ ! -f ${mysqlDir}/mysql-5.6.50.tar.gz ];then
wget -O ${mysqlDir}/mysql-5.6.50.tar.gz https://cdn.mysql.com/Downloads/MySQL-5.6/mysql-5.6.50.tar.gz
fi
if [ ! -d ${mysqlDir}/mysql-5.6.50 ];then
cd ${mysqlDir} && tar -zxvf ${mysqlDir}/mysql-5.6.50.tar.gz
fi
if [ ! -d $serverPath/mysql ];then
cd ${mysqlDir}/mysql-5.6.50 && cmake \
-DCMAKE_INSTALL_PREFIX=$serverPath/mysql \
-DMYSQL_USER=mysql \
-DMYSQL_TCP_PORT=3306 \
-DMYSQL_UNIX_ADDR=/var/tmp/mysql.sock \
-DWITH_MYISAM_STORAGE_ENGINE=1 \
-DWITH_INNOBASE_STORAGE_ENGINE=1 \
-DWITH_MEMORY_STORAGE_ENGINE=1 \
-DENABLED_LOCAL_INFILE=1 \
-DWITH_PARTITION_STORAGE_ENGINE=1 \
-DEXTRA_CHARSETS=all \
-DDEFAULT_CHARSET=utf8 \
-DDEFAULT_COLLATION=utf8_general_ci \
&& make && make install && make clean
echo '5.6' > $serverPath/mysql/version.pl
echo '安装完成' > $install_tmp
fi
}
Uninstall_mysql()
{
rm -rf $serverPath/mysql
echo '卸载完成' > $install_tmp
}
action=$1
if [ "${1}" == 'install' ];then
Install_mysql
else
Uninstall_mysql
fi
+73
View File
@@ -0,0 +1,73 @@
# -*- coding: utf-8 -*-
#!/bin/bash
PATH=/bin:/sbin:/usr/bin:/usr/sbin:/usr/local/bin:/usr/local/sbin:~/bin
export PATH
#https://dev.mysql.com/downloads/mysql/5.7.html
#https://dev.mysql.com/downloads/file/?id=489855
curPath=`pwd`
rootPath=$(dirname "$curPath")
rootPath=$(dirname "$rootPath")
serverPath=$(dirname "$rootPath")
sysName=`uname`
install_tmp=${rootPath}/tmp/mw_install.pl
mysqlDir=${serverPath}/source/mysql
Install_mysql()
{
mkdir -p ${mysqlDir}
echo '正在安装脚本文件...' > $install_tmp
if [ "$sysName" != "Darwin" ];then
mkdir -p /var/log/mariadb
touch /var/log/mariadb/mariadb.log
groupadd mysql
useradd -g mysql mysql
fi
if [ ! -f ${mysqlDir}/mysql-boost-5.7.32.tar.gz ];then
wget -O ${mysqlDir}/mysql-boost-5.7.32.tar.gz https://cdn.mysql.com/Downloads/MySQL-5.7/mysql-boost-5.7.32.tar.gz
fi
if [ ! -d ${mysqlDir}/mysql-5.7.32 ];then
cd ${mysqlDir} && tar -zxvf ${mysqlDir}/mysql-boost-5.7.32.tar.gz
fi
if [ ! -d $serverPath/mysql ];then
cd ${mysqlDir}/mysql-5.7.32 && cmake \
-DCMAKE_INSTALL_PREFIX=$serverPath/mysql \
-DMYSQL_USER=mysql \
-DMYSQL_TCP_PORT=3306 \
-DMYSQL_UNIX_ADDR=/var/tmp/mysql.sock \
-DWITH_MYISAM_STORAGE_ENGINE=1 \
-DWITH_INNOBASE_STORAGE_ENGINE=1 \
-DWITH_MEMORY_STORAGE_ENGINE=1 \
-DENABLED_LOCAL_INFILE=1 \
-DWITH_PARTITION_STORAGE_ENGINE=1 \
-DEXTRA_CHARSETS=all \
-DDEFAULT_CHARSET=utf8 \
-DDEFAULT_COLLATION=utf8_general_ci \
-DDOWNLOAD_BOOST=1 \
-DWITH_BOOST=${mysqlDir}/mysql-5.7.28/boost/
make && make install && make clean
echo '5.7' > $serverPath/mysql/version.pl
echo '安装完成' > $install_tmp
fi
}
Uninstall_mysql()
{
rm -rf $serverPath/mysql
echo '卸载完成' > $install_tmp
}
action=$1
if [ "${1}" == 'install' ];then
Install_mysql
else
Uninstall_mysql
fi
+78
View File
@@ -0,0 +1,78 @@
# -*- coding: utf-8 -*-
#!/bin/bash
PATH=/bin:/sbin:/usr/bin:/usr/sbin:/usr/local/bin:/usr/local/sbin:~/bin
export PATH
#https://dev.mysql.com/downloads/mysql/5.7.html
#https://dev.mysql.com/downloads/file/?id=489855
curPath=`pwd`
rootPath=$(dirname "$curPath")
rootPath=$(dirname "$rootPath")
serverPath=$(dirname "$rootPath")
sysName=`uname`
install_tmp=${rootPath}/tmp/mw_install.pl
mysqlDir=${serverPath}/source/mysql
Install_mysql()
{
mkdir -p ${mysqlDir}
echo '正在安装脚本文件...' > $install_tmp
INSTALL_CMD=cmake
if [ "$sysName" != "Darwin" ];then
mkdir -p /var/log/mariadb
touch /var/log/mariadb/mariadb.log
groupadd mysql
useradd -g mysql mysql
yum install -y cmake3
INSTALL_CMD=cmake3
fi
if [ ! -f ${mysqlDir}/mysql-boost-8.0.22.tar.gz ];then
wget -O ${mysqlDir}/mysql-boost-8.0.22.tar.gz https://cdn.mysql.com/archives/mysql-8.0/mysql-boost-8.0.22.tar.gz
fi
if [ ! -d ${mysqlDir}/mysql-8.0.22 ];then
cd ${mysqlDir} && tar -zxvf ${mysqlDir}/mysql-boost-8.0.22.tar.gz
fi
if [ ! -d $serverPath/mysql ];then
cd ${mysqlDir}/mysql-8.0.22 && ${INSTALL_CMD} \
-DCMAKE_INSTALL_PREFIX=$serverPath/mysql \
-DMYSQL_USER=mysql \
-DMYSQL_TCP_PORT=3306 \
-DMYSQL_UNIX_ADDR=/var/tmp/mysql.sock \
-DWITH_MYISAM_STORAGE_ENGINE=1 \
-DWITH_INNOBASE_STORAGE_ENGINE=1 \
-DWITH_MEMORY_STORAGE_ENGINE=1 \
-DENABLED_LOCAL_INFILE=1 \
-DWITH_PARTITION_STORAGE_ENGINE=1 \
-DEXTRA_CHARSETS=all \
-DDEFAULT_CHARSET=utf8 \
-DDEFAULT_COLLATION=utf8_general_ci \
-DDOWNLOAD_BOOST=1 \
-DFORCE_INSOURCE_BUILD=1 \
-DWITH_BOOST=${mysqlDir}/mysql-8.0.22/boost/
make && make install && make clean
echo '8.0' > $serverPath/mysql/version.pl
echo '安装完成' > $install_tmp
fi
}
Uninstall_mysql()
{
rm -rf $serverPath/mysql
echo '卸载完成' > $install_tmp
}
action=$1
if [ "${1}" == 'install' ];then
Install_mysql
else
Uninstall_mysql
fi
+8
View File
@@ -0,0 +1,8 @@
lua_shared_dict limit 30m;
lua_shared_dict drop_ip 30m;
lua_shared_dict drop_sum 30m;
lua_package_path "{$WAF_PATH}/lua/?.lua;{$ROOT_PATH}/openresty/lualib/?.lua;;";
access_by_lua_file {$WAF_PATH}/lua/init.lua;
#init_by_lua_file {$WAF_PATH}/lua/init.lua;
#access_by_lua_file {$WAF_PATH}/lua/waf.lua;
Binary file not shown.

After

Width:  |  Height:  |  Size: 2.4 KiB

+249
View File
@@ -0,0 +1,249 @@
<style>
/*waf*/
.lib-con-title {
height: 26px;
border-bottom: #ccc 1px solid;
margin-bottom: 10px;
width: 100%;
}
.lib-con-title span {
font-weight: bold;
float: left;
}
.lib-con-title .ssh-item {
margin-top: 0;
padding: 0;
}
.lib-con {
margin-bottom: 10px;
width: 100%;
}
.waftable .ssh-item {
display: inline-block;
padding-top: 0;
}
.waftable .ssh-item .btswitch + .btswitch-btn, .lib-con-title .ssh-item .btswitch + .btswitch-btn {
width: 2.0em;
height: 1.2em;
margin-bottom: 0
}
.rule_btn button {
margin: 10px;
}
.table .gztr td, #LogDayCon td {
word-break: break-all;
}
.wavbox {
width: 314px;
float: left;
height: 60px;
line-height: 52px;
text-align: center;
margin-bottom: 10px;
margin-top: 5px;
padding: 0;
}
.wavbox span {
font-size: 18px;
margin: 0 6px;
font-weight: bold;
}
.screen .line {
width: 33.333%;
text-align: center;
height: 70px;
float: left;
margin: 6px 0;
}
.screen .line:nth-of-type(3n-1) {
margin-right: 0;
}
.screen .line .name {
width: auto;
display: block;
text-align: center;
margin: 5px 0 8px;
color: #666;
}
.screen .line .val {
font-size: 18px;
display: block;
text-align: center;
font-weight: bold
}
.wafview-head {
height: 30px;
border-bottom: #ccc 1px solid;
margin-bottom: 10px;
}
.waf-switch {
margin-left: 20px;
margin-top: -3px;
}
.wafinfo {
line-height: 18px;
margin-right: 10px;
}
.wafinfo .safetotal {
margin: 0 6px;
font-size: 16px;
}
.screen {
background-color: #fafafa;
border: #ddd 1px solid;
padding: 0;
float: left;
border-radius: 4px;
margin-top: 5px;
margin-bottom: 10px;
width: 645px;
}
.table .sitename, .filtertext {
width: 100px;
display: block;
overflow: hidden;
text-overflow: ellipsis;
white-space: nowrap;
}
.td3txt {
max-width: 200px;
display: block;
overflow: hidden;
text-overflow: ellipsis;
white-space: nowrap;
}
.tdhide {
display: none
}
.divpre {
padding: 9.5px;
margin: 0 0 10px;
font-size: 13px;
line-height: 1.42857143;
color: #333;
word-break: break-all;
word-wrap: break-word;
background-color: #f6f6f6;
border: 1px solid #ddd;
border-radius: 4px;
max-height: 100px;
overflow: auto
}
.lib-con .table > tbody > tr.active td {
background-color: #E4EEE0;
}
.table_head_fix {
position: relative;
}
.tipsval {
margin-left: 2px;
color: #fc6d26;
padding: 0 2px;
height: 14px;
line-height: 14px;
border-radius: 3px;
font-family: arial;
vertical-align: 2px;
font-weight: 700
}
.tipsvalnull {
color: #ccc;
font-weight: normal
}
.dot {
position: relative;
}
.dot:after {
content: "";
height: 4px;
width: 4px;
border-radius: 2px;
background: #fc6d26;
position: absolute;
left: -7px;
top: 5px;
}
.soft-man-con .CodeMirror {
height: 250px;
}
.tab_list{
width: 100%;
}
.tab_list .tab_block{
width: 50%;
height: 45px;
line-height: 45px;
display: inline-block;
text-align: center;
border:1px solid #cfcfcfcf;
border-top:0;
background: #ececec;
cursor: pointer;
}
.tab_list .tab_block.active{
background: #fff;
border: 0;
}
.table_fix{
display: inline-block;
overflow: hidden;
text-overflow: ellipsis;
white-space: nowrap;
}
.help-info-text {
margin-top: 0px;
}
</style>
<div class="bt-form">
<div class="bt-w-main">
<div class="bt-w-menu">
<p class="bgw" onclick="pluginService('op_waf');">服务</p>
<p onclick="wafScreen();">首页</p>
<p onclick="wafGloabl();">全局配置</p>
<p onclick="wafSite();">站点配置</p>
<p onclick="wafHistory();">封锁历史</p>
<!-- <p onclick="wafLogs();">操作日志</p> -->
</div>
<!-- lib-con -->
<div class="bt-w-con pd15">
<div class="soft-man-con"></div>
</div>
</div>
</div>
<script type="text/javascript">
resetPluginWinWidth(800);
$.getScript( "/plugins/file?name=op_waf&f=js/op_waf.js", function(){
pluginService('op_waf');
});
</script>
+989
View File
@@ -0,0 +1,989 @@
# coding:utf-8
import sys
import io
import os
import time
import subprocess
import json
sys.path.append(os.getcwd() + "/class/core")
import mw
app_debug = False
if mw.isAppleSystem():
app_debug = True
def getPluginName():
return 'op_waf'
def getPluginDir():
return mw.getPluginDir() + '/' + getPluginName()
def getServerDir():
return mw.getServerDir() + '/' + getPluginName()
def getArgs():
args = sys.argv[2:]
tmp = {}
args_len = len(args)
if args_len == 1:
t = args[0].strip('{').strip('}')
t = t.split(':')
tmp[t[0]] = t[1]
elif args_len > 1:
for i in range(len(args)):
t = args[i].split(':')
tmp[t[0]] = t[1]
return tmp
def checkArgs(data, ck=[]):
for i in range(len(ck)):
if not ck[i] in data:
return (False, mw.returnJson(False, '参数:(' + ck[i] + ')没有!'))
return (True, mw.returnJson(True, 'ok'))
def getConf():
path = mw.getServerDir() + "/openresty/nginx/conf/nginx.conf"
return path
def initDomainInfo():
data = []
path_domains = getJsonPath('domains')
_list = mw.M('sites').field('id,name,path').where(
'status=?', ('1',)).order('id desc').select()
for i in range(len(_list)):
tmp = {}
tmp['name'] = _list[i]['name']
tmp['path'] = _list[i]['path']
_list_domain = mw.M('domain').field('name').where(
'pid=?', (_list[i]['id'],)).order('id desc').select()
tmp_j = []
for j in range(len(_list_domain)):
tmp_j.append(_list_domain[j]['name'])
tmp['domains'] = tmp_j
data.append(tmp)
cjson = mw.getJson(data)
mw.writeFile(path_domains, cjson)
def initSiteInfo():
data = []
path_domains = getJsonPath('domains')
path_config = getJsonPath('config')
path_site = getJsonPath('site')
config_contents = mw.readFile(path_config)
config_contents = json.loads(config_contents)
domain_contents = mw.readFile(path_domains)
domain_contents = json.loads(domain_contents)
try:
site_contents = mw.readFile(path_site)
except Exception as e:
site_contents = "{}"
site_contents = json.loads(site_contents)
site_contents_new = {}
for x in range(len(domain_contents)):
name = domain_contents[x]['name']
if name in site_contents:
site_contents_new[name] = site_contents[name]
else:
tmp = {}
tmp['cdn'] = False
tmp['log'] = True
tmp['get'] = True
tmp['post'] = True
tmp['open'] = False
tmp['cc'] = config_contents['cc']
tmp['retry'] = config_contents['retry']
tmp['get'] = config_contents['get']
tmp['post'] = config_contents['post']
tmp['user-agent'] = config_contents['user-agent']
tmp['cookie'] = config_contents['cookie']
tmp['scan'] = config_contents['scan']
cdn_header = ['x-forwarded-for',
'x-real-ip', 'HTTP_CF_CONNECTING_IP']
tmp['cdn_header'] = cdn_header
disable_upload_ext = ["php", "jsp"]
tmp['disable_upload_ext'] = disable_upload_ext
disable_path = ['sql']
tmp['disable_ext'] = disable_path
site_contents_new[name] = tmp
cjson = mw.getJson(site_contents_new)
mw.writeFile(path_site, cjson)
def initTotalInfo():
data = []
path_domains = getJsonPath('domains')
path_total = getJsonPath('total')
domain_contents = mw.readFile(path_domains)
domain_contents = json.loads(domain_contents)
try:
total_contents = mw.readFile(path_total)
except Exception as e:
total_contents = "{}"
total_contents = json.loads(total_contents)
total_contents_new = {}
for x in range(len(domain_contents)):
name = domain_contents[x]['name']
if 'sites' in total_contents and name in total_contents['sites']:
pass
else:
tmp = {}
tmp['cdn'] = 0
tmp['log'] = 0
tmp['get'] = 0
tmp['post'] = 0
tmp['total'] = 0
_name = {}
_name[name] = tmp
total_contents['sites'] = _name
cjson = mw.getJson(total_contents)
mw.writeFile(path_total, cjson)
def status():
path = getConf()
if not os.path.exists(path):
return 'stop'
conf = mw.readFile(path)
if conf.find("#include luawaf.conf;") != -1:
return 'stop'
if conf.find("luawaf.conf;") == -1:
return 'stop'
return 'start'
def contentReplace(content):
service_path = mw.getServerDir()
waf_path = mw.getServerDir() + "/openresty/nginx/conf/waf"
content = content.replace('{$ROOT_PATH}', mw.getRootDir())
content = content.replace('{$SERVER_PATH}', service_path)
content = content.replace('{$WAF_PATH}', waf_path)
return content
def initDreplace():
path = mw.getServerDir() + "/openresty/nginx/conf"
if not os.path.exists(path + '/waf'):
sdir = getPluginDir() + '/waf'
cmd = 'cp -rf ' + sdir + ' ' + path
mw.execShell(cmd)
config = mw.getServerDir() + '/openresty/nginx/conf/waf/config.json'
content = mw.readFile(config)
content = json.loads(content)
content['reqfile_path'] = mw.getServerDir(
) + "/openresty/nginx/conf/waf/html"
mw.writeFile(config, mw.getJson(content))
config = mw.getServerDir() + "/openresty/nginx/conf/waf/lua/init.lua"
content = mw.readFile(config)
content = contentReplace(content)
mw.writeFile(config, content)
waf_conf = mw.getServerDir() + "/openresty/nginx/conf/luawaf.conf"
waf_tpl = getPluginDir() + "/conf/luawaf.conf"
content = mw.readFile(waf_tpl)
content = contentReplace(content)
mw.writeFile(waf_conf, content)
initDomainInfo()
initSiteInfo()
initTotalInfo()
def start():
initDreplace()
path = getConf()
conf = mw.readFile(path)
conf = conf.replace('#include luawaf.conf;', "include luawaf.conf;")
mw.writeFile(path, conf)
mw.restartWeb()
return 'ok'
def stop():
path = mw.getServerDir() + "/openresty/nginx/conf/waf"
if os.path.exists(path):
cmd = 'rm -rf ' + path
mw.execShell(cmd)
path = getConf()
conf = mw.readFile(path)
conf = conf.replace('include luawaf.conf;', "#include luawaf.conf;")
mw.writeFile(path, conf)
mw.restartWeb()
return 'ok'
def restart():
mw.restartWeb()
return 'ok'
def reload():
stop()
mw.execShell('rm -rf ' + mw.getServerDir() +
"/openresty/nginx/logs/error.log")
start()
return 'ok'
def getJsonPath(name):
path = mw.getServerDir() + "/openresty/nginx/conf/waf/" + name + ".json"
return path
def getRuleJsonPath(name):
path = mw.getServerDir() + "/openresty/nginx/conf/waf/rule/" + name + ".json"
return path
def getRule():
args = getArgs()
data = checkArgs(args, ['rule_name'])
if not data[0]:
return data[1]
rule_name = args['rule_name']
fpath = getRuleJsonPath(rule_name)
content = mw.readFile(fpath)
return mw.returnJson(True, 'ok', content)
def addRule():
args = getArgs()
data = checkArgs(args, ['ruleName', 'ruleValue', 'ps'])
if not data[0]:
return data[1]
ruleValue = args['ruleValue']
ruleName = args['ruleName']
ps = args['ps']
fpath = getRuleJsonPath(ruleName)
content = mw.readFile(fpath)
content = json.loads(content)
tmp_k = []
tmp_k.append(1)
tmp_k.append(ruleValue)
tmp_k.append(ps)
tmp_k.append(1)
content.append(tmp_k)
cjson = mw.getJson(content)
mw.writeFile(fpath, cjson)
return mw.returnJson(True, '设置成功!', content)
def removeRule():
args = getArgs()
data = checkArgs(args, ['ruleName', 'index'])
if not data[0]:
return data[1]
index = int(args['index'])
ruleName = args['ruleName']
fpath = getRuleJsonPath(ruleName)
content = mw.readFile(fpath)
content = json.loads(content)
k = content[index]
content.remove(k)
cjson = mw.getJson(content)
mw.writeFile(fpath, cjson)
return mw.returnJson(True, '设置成功!', content)
def setRuleState():
args = getArgs()
data = checkArgs(args, ['ruleName', 'index'])
if not data[0]:
return data[1]
index = int(args['index'])
ruleName = args['ruleName']
fpath = getRuleJsonPath(ruleName)
content = mw.readFile(fpath)
content = json.loads(content)
b = content[index][0]
if b == 1:
content[index][0] = 0
else:
content[index][0] = 1
cjson = mw.getJson(content)
mw.writeFile(fpath, cjson)
return mw.returnJson(True, '设置成功!', content)
def modifyRule():
args = getArgs()
data = checkArgs(args, ['index', 'ruleName', 'ruleBody', 'rulePs'])
if not data[0]:
return data[1]
index = int(args['index'])
ruleName = args['ruleName']
ruleBody = args['ruleBody']
rulePs = args['rulePs']
fpath = getRuleJsonPath(ruleName)
content = mw.readFile(fpath)
content = json.loads(content)
tmp = content[index]
tmp_k = []
tmp_k.append(tmp[0])
tmp_k.append(ruleBody)
tmp_k.append(rulePs)
tmp_k.append(tmp[3])
content[index] = tmp_k
cjson = mw.getJson(content)
mw.writeFile(fpath, cjson)
return mw.returnJson(True, '设置成功!', content)
def getSiteRule():
args = getArgs()
data = checkArgs(args, ['siteName', 'ruleName'])
if not data[0]:
return data[1]
siteName = args['siteName']
siteRule = args['ruleName']
path = getJsonPath('site')
content = mw.readFile(path)
content = json.loads(content)
r = content[siteName][siteRule]
cjson = mw.getJson(r)
return mw.returnJson(True, 'ok!', cjson)
def addSiteRule():
args = getArgs()
data = checkArgs(args, ['siteName', 'ruleName', 'ruleValue'])
if not data[0]:
return data[1]
siteName = args['siteName']
siteRule = args['ruleName']
ruleValue = args['ruleValue']
path = getJsonPath('site')
content = mw.readFile(path)
content = json.loads(content)
content[siteName][siteRule].append(ruleValue)
cjson = mw.getJson(content)
mw.writeFile(path, cjson)
return mw.returnJson(True, '设置成功!')
def addIpWhite():
args = getArgs()
data = checkArgs(args, ['start_ip', 'end_ip'])
if not data[0]:
return data[1]
start_ip = args['start_ip']
end_ip = args['end_ip']
path = getRuleJsonPath('ip_white')
content = mw.readFile(path)
content = json.loads(content)
data = []
start_ip_list = start_ip.split('.')
tmp = []
for x in range(len(start_ip_list)):
tmp.append(int(start_ip_list[x]))
end_ip_list = end_ip.split('.')
tmp2 = []
for x in range(len(end_ip_list)):
tmp2.append(int(end_ip_list[x]))
data.append(tmp)
data.append(tmp2)
content.append(data)
cjson = mw.getJson(content)
mw.writeFile(path, cjson)
return mw.returnJson(True, '设置成功!')
def removeIpWhite():
args = getArgs()
data = checkArgs(args, ['index'])
if not data[0]:
return data[1]
index = args['index']
path = getRuleJsonPath('ip_white')
content = mw.readFile(path)
content = json.loads(content)
k = content[int(index)]
content.remove(k)
cjson = mw.getJson(content)
mw.writeFile(path, cjson)
return mw.returnJson(True, '设置成功!')
def addIpBlack():
args = getArgs()
data = checkArgs(args, ['start_ip', 'end_ip'])
if not data[0]:
return data[1]
start_ip = args['start_ip']
end_ip = args['end_ip']
path = getRuleJsonPath('ip_black')
content = mw.readFile(path)
content = json.loads(content)
data = []
start_ip_list = start_ip.split('.')
tmp = []
for x in range(len(start_ip_list)):
tmp.append(int(start_ip_list[x]))
end_ip_list = end_ip.split('.')
tmp2 = []
for x in range(len(end_ip_list)):
tmp2.append(int(end_ip_list[x]))
data.append(tmp)
data.append(tmp2)
content.append(data)
cjson = mw.getJson(content)
mw.writeFile(path, cjson)
return mw.returnJson(True, '设置成功!')
def removeIpBlack():
args = getArgs()
data = checkArgs(args, ['index'])
if not data[0]:
return data[1]
index = args['index']
path = getRuleJsonPath('ip_black')
content = mw.readFile(path)
content = json.loads(content)
k = content[int(index)]
content.remove(k)
cjson = mw.getJson(content)
mw.writeFile(path, cjson)
return mw.returnJson(True, '设置成功!')
def setIpv6Black():
args = getArgs()
data = checkArgs(args, ['addr'])
if not data[0]:
return data[1]
addr = args['addr'].replace('_', ':')
path = getRuleJsonPath('ipv6_black')
content = mw.readFile(path)
content = json.loads(content)
content.append(addr)
cjson = mw.getJson(content)
mw.writeFile(path, cjson)
return mw.returnJson(True, '设置成功!')
def delIpv6Black():
args = getArgs()
data = checkArgs(args, ['addr'])
if not data[0]:
return data[1]
addr = args['addr'].replace('_', ':')
path = getRuleJsonPath('ipv6_black')
content = mw.readFile(path)
content = json.loads(content)
content.remove(addr)
cjson = mw.getJson(content)
mw.writeFile(path, cjson)
return mw.returnJson(True, '设置成功!')
def removeSiteRule():
args = getArgs()
data = checkArgs(args, ['siteName', 'ruleName', 'index'])
if not data[0]:
return data[1]
siteName = args['siteName']
siteRule = args['ruleName']
index = args['index']
path = getJsonPath('site')
content = mw.readFile(path)
content = json.loads(content)
ruleValue = content[siteName][siteRule][int(index)]
content[siteName][siteRule].remove(ruleValue)
cjson = mw.getJson(content)
mw.writeFile(path, cjson)
return mw.returnJson(True, '设置成功!')
def setObjStatus():
args = getArgs()
data = checkArgs(args, ['obj', 'statusCode'])
if not data[0]:
return data[1]
conf = getJsonPath('config')
content = mw.readFile(conf)
cobj = json.loads(content)
o = args['obj']
status = args['statusCode']
cobj[o]['status'] = status
cjson = mw.getJson(cobj)
mw.writeFile(conf, cjson)
return mw.returnJson(True, '设置成功!')
def setRetry():
args = getArgs()
data = checkArgs(args, ['retry', 'retry_time',
'retry_cycle', 'is_open_global'])
if not data[0]:
return data[1]
conf = getJsonPath('config')
content = mw.readFile(conf)
cobj = json.loads(content)
cobj['retry'] = args
cjson = mw.getJson(cobj)
mw.writeFile(conf, cjson)
return mw.returnJson(True, '设置成功!', [])
def setSiteRetry():
return mw.returnJson(True, '设置成功-?!', [])
def setCcConf():
args = getArgs()
data = checkArgs(args, ['siteName', 'cycle', 'limit',
'endtime', 'is_open_global', 'increase'])
if not data[0]:
return data[1]
conf = getJsonPath('config')
content = mw.readFile(conf)
cobj = json.loads(content)
tmp = cobj['cc']
tmp['cycle'] = int(args['cycle'])
tmp['limit'] = int(args['limit'])
tmp['endtime'] = int(args['endtime'])
tmp['is_open_global'] = args['is_open_global']
tmp['increase'] = args['increase']
cobj['cc'] = tmp
cjson = mw.getJson(cobj)
mw.writeFile(conf, cjson)
return mw.returnJson(True, '设置成功!', [])
def setSiteCcConf():
return mw.returnJson(False, '暂未开发!', [])
def saveScanRule():
args = getArgs()
data = checkArgs(args, ['header', 'cookie', 'args'])
if not data[0]:
return data[1]
path = getRuleJsonPath('scan_black')
cjson = mw.getJson(args)
mw.writeFile(path, cjson)
return mw.returnJson(True, '设置成功!', [])
def getSiteConfig():
path = getJsonPath('site')
content = mw.readFile(path)
content = json.loads(content)
total = getJsonPath('total')
total_content = mw.readFile(total)
total_content = json.loads(total_content)
# print total_content
for x in content:
tmp = []
tmp_v = {}
if 'sites' in total_content and x in total_content['sites']:
tmp_v = total_content['sites'][x]
key_list = ['get', 'post', 'user-agent', 'cookie', 'cdn', 'cc']
for kx in range(len(key_list)):
ktmp = {}
if kx in tmp_v:
ktmp['value'] = tmp_v[key_list[kx]]
else:
ktmp['value'] = ''
ktmp['key'] = key_list[kx]
tmp.append(ktmp)
# print tmp
content[x]['total'] = tmp
content = mw.getJson(content)
return mw.returnJson(True, 'ok!', content)
def getSiteConfigByName():
args = getArgs()
data = checkArgs(args, ['siteName'])
if not data[0]:
return data[1]
path = getJsonPath('site')
content = mw.readFile(path)
content = json.loads(content)
siteName = args['siteName']
retData = {}
if siteName in content:
retData = content[siteName]
return mw.returnJson(True, 'ok!', retData)
def addSiteCdnHeader():
args = getArgs()
data = checkArgs(args, ['siteName', 'cdn_header'])
if not data[0]:
return data[1]
path = getJsonPath('site')
content = mw.readFile(path)
content = json.loads(content)
siteName = args['siteName']
retData = {}
if siteName in content:
content[siteName]['cdn_header'].append(args['cdn_header'])
cjson = mw.getJson(content)
mw.writeFile(path, cjson)
return mw.returnJson(True, '添加成功!')
def removeSiteCdnHeader():
args = getArgs()
data = checkArgs(args, ['siteName', 'cdn_header'])
if not data[0]:
return data[1]
path = getJsonPath('site')
content = mw.readFile(path)
content = json.loads(content)
siteName = args['siteName']
retData = {}
if siteName in content:
content[siteName]['cdn_header'].remove(args['cdn_header'])
cjson = mw.getJson(content)
mw.writeFile(path, cjson)
return mw.returnJson(True, '删除成功!')
def outputData():
args = getArgs()
data = checkArgs(args, ['s_Name'])
if not data[0]:
return data[1]
path = getRuleJsonPath(args['s_Name'])
content = mw.readFile(path)
return mw.returnJson(True, 'ok', content)
def importData():
args = getArgs()
data = checkArgs(args, ['s_Name', 'pdata'])
if not data[0]:
return data[1]
path = getRuleJsonPath(args['s_Name'])
mw.writeFile(path, args['pdata'])
return mw.returnJson(True, '设置成功!')
def getLogsList():
args = getArgs()
data = checkArgs(args, ['siteName'])
if not data[0]:
return data[1]
data = []
path = mw.getLogsDir() + '/waf'
files = os.listdir(path)
for f in files:
if f == '.DS_Store':
continue
f = f.split('_')
if f[0] == args['siteName']:
fl = f[1].split('.')
data.append(fl[0])
return mw.returnJson(True, 'ok!', data)
def getSafeLogs():
args = getArgs()
data = checkArgs(args, ['siteName', 'toDate', 'p'])
if not data[0]:
return data[1]
path = mw.getLogsDir() + '/waf'
file = path + '/' + args['siteName'] + '_' + args['toDate'] + '.log'
if not os.path.exists(file):
return mw.returnJson(False, "文件不存在!")
retData = []
file = open(file)
while 1:
lines = file.readlines(100000)
if not lines:
break
for line in lines:
retData.append(json.loads(line))
return mw.returnJson(True, '设置成功!', retData)
def setObjOpen():
args = getArgs()
data = checkArgs(args, ['obj'])
if not data[0]:
return data[1]
conf = getJsonPath('config')
content = mw.readFile(conf)
cobj = json.loads(content)
o = args['obj']
if cobj[o]["open"]:
cobj[o]["open"] = False
else:
cobj[o]["open"] = True
cjson = mw.getJson(cobj)
mw.writeFile(conf, cjson)
return mw.returnJson(True, '设置成功!')
def setSiteObjOpen():
args = getArgs()
data = checkArgs(args, ['siteName', 'obj'])
if not data[0]:
return data[1]
siteName = args['siteName']
obj = args['obj']
path = getJsonPath('site')
content = mw.readFile(path)
content = json.loads(content)
if type(content[siteName][obj]) == bool:
if content[siteName][obj]:
content[siteName][obj] = False
else:
content[siteName][obj] = True
else:
if content[siteName][obj]['open']:
content[siteName][obj]['open'] = False
else:
content[siteName][obj]['open'] = True
cjson = mw.getJson(content)
mw.writeFile(path, cjson)
return mw.returnJson(True, '设置成功!')
def getWafSrceen():
conf = getJsonPath('total')
return mw.readFile(conf)
def getWafConf():
conf = getJsonPath('config')
return mw.readFile(conf)
def getWafSite():
return ''
if __name__ == "__main__":
func = sys.argv[1]
if func == 'status':
print status()
elif func == 'start':
print start()
elif func == 'stop':
print stop()
elif func == 'restart':
print restart()
elif func == 'reload':
print reload()
elif func == 'conf':
print getConf()
elif func == 'get_rule':
print getRule()
elif func == 'add_rule':
print addRule()
elif func == 'remove_rule':
print removeRule()
elif func == 'set_rule_state':
print setRuleState()
elif func == 'modify_rule':
print modifyRule()
elif func == 'get_site_rule':
print getSiteRule()
elif func == 'add_site_rule':
print addSiteRule()
elif func == 'add_ip_white':
print addIpWhite()
elif func == 'remove_ip_white':
print removeIpWhite()
elif func == 'add_ip_black':
print addIpBlack()
elif func == 'remove_ip_black':
print removeIpBlack()
elif func == 'set_ipv6_black':
print setIpv6Black()
elif func == 'del_ipv6_black':
print delIpv6Black()
elif func == 'remove_site_rule':
print removeSiteRule()
elif func == 'set_obj_status':
print setObjStatus()
elif func == 'set_obj_open':
print setObjOpen()
elif func == 'set_site_obj_open':
print setSiteObjOpen()
elif func == 'set_cc_conf':
print setCcConf()
elif func == 'set_site_cc_conf':
print setSiteCcConf()
elif func == 'set_retry':
print setRetry()
elif func == 'set_site_retry':
print setSiteRetry()
elif func == 'save_scan_rule':
print saveScanRule()
elif func == 'get_site_config':
print getSiteConfig()
elif func == 'get_site_config_byname':
print getSiteConfigByName()
elif func == 'add_site_cdn_header':
print addSiteCdnHeader()
elif func == 'remove_site_cdn_header':
print removeSiteCdnHeader()
elif func == 'get_logs_list':
print getLogsList()
elif func == 'get_safe_logs':
print getSafeLogs()
elif func == 'output_data':
print outputData()
elif func == 'import_data':
print importData()
elif func == 'waf_srceen':
print getWafSrceen()
elif func == 'waf_conf':
print getWafConf()
elif func == 'waf_site':
print getWafSite()
else:
print('error')
+15
View File
@@ -0,0 +1,15 @@
{
"title":"OP防火墙",
"tip":"soft",
"name":"op_waf",
"type":"其他插件",
"ps":"有效防止sql注入/xss/一句话木马等常见渗透攻击",
"shell":"install.sh",
"checks":"server/op_waf",
"path":"server/op_waf",
"author":"loveshell",
"home":"https://github.com/loveshell/ngx_lua_waf",
"date":"2019-04-21",
"pid": "1",
"versions": ["0.1"]
}
+36
View File
@@ -0,0 +1,36 @@
#!/bin/bash
PATH=/bin:/sbin:/usr/bin:/usr/sbin:/usr/local/bin:/usr/local/sbin:~/bin
export PATH
curPath=`pwd`
rootPath=$(dirname "$curPath")
rootPath=$(dirname "$rootPath")
serverPath=$(dirname "$rootPath")
install_tmp=${rootPath}/tmp/mw_install.pl
Install_of(){
echo '正在安装脚本文件...' > $install_tmp
mkdir -p $serverPath/op_waf
echo '0.1' > $serverPath/op_waf/version.pl
echo 'install ok' > $install_tmp
}
Uninstall_of(){
rm -rf $serverPath/op_waf
}
action=$1
type=$2
action=$1
if [ "${1}" == 'install' ];then
Install_of
else
Uninstall_of
fi

Some files were not shown because too many files have changed in this diff Show More