Compare commits

...

219 commits

Author SHA1 Message Date
Jo-Philipp Wich
9feda4595b luci-0.9: merge r6443 2010-11-19 11:48:24 +00:00
Jo-Philipp Wich
5dff7ab140 luci-0.9: merge r6424 2010-11-13 20:51:15 +00:00
Jo-Philipp Wich
d31df673fa luci-0.9: backport r6422 2010-11-13 14:00:54 +00:00
Jo-Philipp Wich
0e2071753f luci-0.9: merge r6420 2010-11-13 13:52:34 +00:00
Jo-Philipp Wich
5dea416e83 luci-0.9: merge r6410 2010-11-09 19:44:01 +00:00
Jo-Philipp Wich
c790400671 luci-0.9: merge r6387 2010-11-03 00:21:46 +00:00
Jo-Philipp Wich
2f14ec03ae luci-0.9: merge r6346 2010-10-28 18:22:14 +00:00
Jo-Philipp Wich
b8e71be773 luci-0.9: merge r6343 2010-10-28 16:58:44 +00:00
Jo-Philipp Wich
395df47437 luci-0.9: merge r6313 2010-10-28 12:26:48 +00:00
Jo-Philipp Wich
7a8d9beb88 luci-0.9: merge r6188 2010-05-30 23:48:02 +00:00
Jo-Philipp Wich
48e35bf43a luci-0.9: merge r6165 2010-05-15 18:49:20 +00:00
Jo-Philipp Wich
57dc871f5a luci-0.9: merge r6081 2010-04-16 19:05:48 +00:00
Jo-Philipp Wich
9391668d82 luci-0.9: merge r6035 2010-04-07 21:59:19 +00:00
Jo-Philipp Wich
80be0c046d luci-0.9: commit pending merge information 2010-04-05 17:46:20 +00:00
Jo-Philipp Wich
40ddfa629f luci-0.9: update translation template for init manager 2010-04-05 17:45:18 +00:00
Jo-Philipp Wich
119aeff2c7 luci-0.9: fix various uvl issues 2010-04-05 17:44:57 +00:00
Jo-Philipp Wich
f77d92b2be luci-0.9: merge r6024, r6025 2010-04-05 17:39:35 +00:00
Jo-Philipp Wich
4efb7b28fa luci-0.9: merge r6019 2010-04-04 17:29:11 +00:00
Jo-Philipp Wich
119b6d898f luci-0.9: merge r6016 2010-04-03 19:31:40 +00:00
Jo-Philipp Wich
82ca74d1b3 luci-0.9: merge r6014 2010-04-03 19:02:18 +00:00
Jo-Philipp Wich
f6f39eda94 luci-0.9: merge r6012 2010-04-03 17:53:09 +00:00
Jo-Philipp Wich
6afee3fff7 luci-0.9: merge r6009 2010-04-03 13:55:23 +00:00
Jo-Philipp Wich
d638ce2adb luci-0.9: fix language detection in LuCI settings 2010-04-03 13:21:39 +00:00
Jo-Philipp Wich
243c3d497f luci-0.9: merge r5989 2010-03-29 21:35:29 +00:00
Jo-Philipp Wich
d55e6c794c luci-0.9: merge r5987 2010-03-29 18:41:32 +00:00
Jo-Philipp Wich
f0e9aaf293 luci-0.9: merge r5269 2010-03-29 01:13:37 +00:00
Jo-Philipp Wich
1b3f0e7bc3 luci-0.9: merge r5980 2010-03-28 20:56:13 +00:00
Jo-Philipp Wich
5ee7124e53 luci-0.9: merge r5978 2010-03-28 20:43:15 +00:00
Jo-Philipp Wich
d91e8e0d1f luci-0.9: merge r5975 2010-03-28 17:56:09 +00:00
Jo-Philipp Wich
f2eccfdcaf luci-0.9: merge r5973 2010-03-28 17:42:40 +00:00
Jo-Philipp Wich
50f73513a9 luci-0.9: merge r5967 2010-03-27 23:52:06 +00:00
Jo-Philipp Wich
de75afdeeb luci-0.9: fix regression introduced by r5963 2010-03-27 22:23:47 +00:00
Jo-Philipp Wich
a124d0353a luci-0.9: merge r5964 2010-03-27 22:20:14 +00:00
Jo-Philipp Wich
0f888230ed luci-0.9: merge r5962 2010-03-27 21:49:15 +00:00
Jo-Philipp Wich
6945497fff luci-0.9: merge r5960 2010-03-27 20:57:00 +00:00
Jo-Philipp Wich
9d9c18e29e luci-0.9: merge r5958 2010-03-27 19:28:59 +00:00
Jo-Philipp Wich
291206c9fa luci-0.9: merge r5956 2010-03-27 19:23:59 +00:00
Jo-Philipp Wich
7ff62d42c5 luci-0.9: merge r5954 2010-03-27 19:17:47 +00:00
Jo-Philipp Wich
3cdccaa76c luci-0.9: merge r5952 2010-03-27 17:42:00 +00:00
Jo-Philipp Wich
e8b29453c8 luci-0.9: merge r5950 2010-03-27 17:29:54 +00:00
Jo-Philipp Wich
db8dab8cdf luci-0.9: merge r5948 2010-03-27 14:56:35 +00:00
Jo-Philipp Wich
252a496c77 luci-0.9: merge r5946 2010-03-27 03:02:56 +00:00
Jo-Philipp Wich
8090100c76 luci-0.9: merge r5944 2010-03-27 02:56:03 +00:00
Jo-Philipp Wich
94a98c7004 luci-0.9: merge r5942 2010-03-27 02:45:36 +00:00
Jo-Philipp Wich
ce93183e25 luci-0.9: merge r5940 2010-03-27 02:41:29 +00:00
Jo-Philipp Wich
ff39f24b0a luci-0.9: change default source target to precompiled 2010-03-27 02:11:01 +00:00
Jo-Philipp Wich
a710515dac luci-0.9: flush stdout during sysupgrade 2010-03-27 02:02:51 +00:00
Jo-Philipp Wich
d9e011d7cb luci-0.9: merge r5919 2010-03-25 17:19:39 +00:00
Jo-Philipp Wich
87af5a13f1 luci-0.9: merge r5908-r5911 2010-03-25 17:16:20 +00:00
Jo-Philipp Wich
a99076696a luci-0.9: merge r5902, r5903 2010-03-25 17:14:57 +00:00
Jo-Philipp Wich
065403a514 luci-0.9: merge r5920-5922 2010-03-25 17:05:02 +00:00
Jo-Philipp Wich
1b2a207eea luci-0.9: merge r5913 2010-03-24 00:06:23 +00:00
Jo-Philipp Wich
e235c7cc60 luci-0.9: merge r5655 2010-03-23 16:23:03 +00:00
Jo-Philipp Wich
a32d60c3fb luci-0.9: merge r5871 2010-03-18 22:40:57 +00:00
Jo-Philipp Wich
fe356792c2 luci-0.9: merge r5869 2010-03-18 22:37:41 +00:00
Jo-Philipp Wich
a2696531d9 luci-0.9: merge r5865 2010-03-18 17:26:08 +00:00
Jo-Philipp Wich
95bc270f06 luci-0.9: merge r5861-r5863 2010-03-18 17:07:23 +00:00
Jo-Philipp Wich
14e06588ec luci-0.9: merge r5859 2010-03-18 15:19:48 +00:00
Jo-Philipp Wich
5223afaf66 luci-0.9: remove definitions for luanet from feed makefile 2010-03-17 16:31:04 +00:00
Jo-Philipp Wich
5d98d73229 luci-0.9: remove libs/lpk and libs/luanet - they're unused and frequently break builds (#113) 2010-03-15 15:21:06 +00:00
Jo-Philipp Wich
508488e961 luci-0.9: merge r5782 2010-03-09 21:23:11 +00:00
Jo-Philipp Wich
c146ab202d luci-0.9: merge r5777 2010-03-09 11:37:54 +00:00
Jo-Philipp Wich
b30715381e luci-0.9: merge r5775 2010-03-09 02:14:02 +00:00
Jo-Philipp Wich
168c05be7b luci-0.9: merge OpenWrt.org from trunk, adds tab support CSS 2010-03-09 02:09:20 +00:00
Jo-Philipp Wich
3441fe8c82 luci-0.9: backport CBI from trunk, adds tab support, auto-hiding of commit notifications and better layout control 2010-03-09 02:05:49 +00:00
Jo-Philipp Wich
2c59a118ed luci-0.9: add 11n options, add ap/sta wds mode 2010-03-09 01:18:15 +00:00
Jo-Philipp Wich
12a1c66478 luci-0.9: merge r5769 2010-03-08 23:47:39 +00:00
Jo-Philipp Wich
3fe0697748 luci-0.9: minor fixes and sanity checks in network config pages 2010-03-08 22:45:06 +00:00
Jo-Philipp Wich
3ef4fdce75 luci-0.9: merge r5766 2010-03-08 19:33:42 +00:00
Jo-Philipp Wich
583a8607f1 luci-0.9: merge r5764 2010-03-08 19:07:13 +00:00
Jo-Philipp Wich
a6295e8d83 luci-0.9: merge r5762 2010-03-08 18:57:00 +00:00
Jo-Philipp Wich
afe12c4b94 luci-0.9: merge r5760 2010-03-08 17:02:44 +00:00
Jo-Philipp Wich
a2338d9adf luci-0.9: merge r5758 2010-03-08 04:51:42 +00:00
Jo-Philipp Wich
4762f5a633 luci-0.9: merge r5756 2010-03-08 02:47:47 +00:00
Jo-Philipp Wich
a88531779f luci-0.9: merge r5597 2010-03-08 02:34:12 +00:00
Jo-Philipp Wich
42a09cdd1e luci-0.9: merge r5753 2010-03-08 02:17:39 +00:00
Jo-Philipp Wich
2c4ff11f58 luci-0.9: combine dhcp and lease page 2010-03-08 02:09:46 +00:00
Jo-Philipp Wich
9444aff816 luci-0.9: merge r5750 2010-03-08 01:50:27 +00:00
Jo-Philipp Wich
6ce49433c5 luci-0.9: merge r5748 2010-03-08 01:47:51 +00:00
Jo-Philipp Wich
5abc657c8e luci-0.9: merge r5746 2010-03-08 01:24:30 +00:00
Jo-Philipp Wich
d3083a9e7a luci-0.9: merge r5744 2010-03-08 01:19:46 +00:00
Jo-Philipp Wich
773e6b78c3 luci-0.9: drop luci_ethers, static lease mgmnt. is now covered by /etc/config/dhcp 2010-03-08 01:07:02 +00:00
Jo-Philipp Wich
7ae301e92c luci-0.9: merge r5741 2010-03-08 00:53:12 +00:00
Jo-Philipp Wich
9823bb991e luci-0.9: merge r5739 2010-03-08 00:50:19 +00:00
Jo-Philipp Wich
fe1f00bfe8 luci-0.9: various improvements in package management ui 2010-03-08 00:13:43 +00:00
Jo-Philipp Wich
81241de757 luci-0.9: merge r5736 2010-03-07 21:52:24 +00:00
Jo-Philipp Wich
3cdb067150 luci-0.9: merge r5733 2010-03-07 20:14:48 +00:00
Jo-Philipp Wich
fa5e477e56 luci-0.9: merge r5730 amd r5731 2010-03-07 19:06:44 +00:00
Jo-Philipp Wich
d536bdacfb luci-0.9: merge r5726 2010-03-07 17:53:13 +00:00
Jo-Philipp Wich
8644cf317b luci-0.9: only show wireless and switch config if hardware is present 2010-03-07 16:40:50 +00:00
Jo-Philipp Wich
bda9d81da7 luci-0.9: merge r5721 2010-03-07 15:24:52 +00:00
Jo-Philipp Wich
d28e31fe14 luci-0.9: merge r5716 2010-03-06 19:15:58 +00:00
Jo-Philipp Wich
f72e3e2ad3 luci-0.9: merge r5115 2010-03-06 19:15:16 +00:00
Jo-Philipp Wich
9e0713734e luci-0.9: merge r5712 2010-03-02 00:48:21 +00:00
Jo-Philipp Wich
45b90e8686 luci-0.9: merge r5693 and r5697 2010-02-28 23:46:32 +00:00
Jo-Philipp Wich
699c9b1e97 luci-0.9: merge r5698 2010-02-28 23:44:44 +00:00
Jo-Philipp Wich
fcc5d1e3c7 luci-0.9: rewrite package management to be less OOM prone 2010-02-28 23:43:17 +00:00
Jo-Philipp Wich
2a5d6299fd luci-0.9: merge r5641 (code 255 on opkg update) 2010-01-01 17:55:53 +00:00
Jo-Philipp Wich
8bc4c2646e luci-0.9: merge r5642 2009-12-24 00:54:40 +00:00
Jo-Philipp Wich
4e33af6103 luci-0.9: merge r5637 2009-12-20 18:35:46 +00:00
Jo-Philipp Wich
82cc8fddef luci-0.9: merge r5635 2009-12-20 18:19:18 +00:00
Jo-Philipp Wich
723c9a900b luci-0.9: merge r5615 2009-12-13 21:33:54 +00:00
Jo-Philipp Wich
2958ac689f luci-0.9: merge r5613 2009-12-13 21:19:02 +00:00
Jo-Philipp Wich
ed2a86b70f luci-0.9: fix last commit: swap back swapped values and swap the others instead 2009-12-11 15:57:15 +00:00
Jo-Philipp Wich
7b3830a279 luci-0.9: labels for black- and whitelist are swapped 2009-12-11 15:50:39 +00:00
Jo-Philipp Wich
e9fa8eba79 luci-0.9: merge r5596 2009-12-09 23:04:44 +00:00
Jo-Philipp Wich
e02b2c07b7 luci-0.9: merge r5605 2009-12-04 23:17:09 +00:00
Jo-Philipp Wich
061213f9cf luci-0.9: merge r5603 2009-12-02 12:36:40 +00:00
Jo-Philipp Wich
69b994469c luci-0.9: r5601 2009-11-29 16:11:43 +00:00
Jo-Philipp Wich
25c3869fc3 luci-0.9: merge r5599 2009-11-29 15:17:29 +00:00
Jo-Philipp Wich
f0e63629cb luci-0.9: merge r5590, r5591 and r5592 2009-11-25 02:24:16 +00:00
Jo-Philipp Wich
dff999ea08 luci-0.9: merge r5586 2009-11-23 20:47:34 +00:00
Jo-Philipp Wich
8fc605c3e8 luci-0.9: merge r5574 2009-11-22 23:55:48 +00:00
Jo-Philipp Wich
baf949c399 luci-0.9: merge r5572 2009-11-22 22:26:44 +00:00
Jo-Philipp Wich
835f7aa6df luci-0.9: merge r5570 2009-11-22 21:15:08 +00:00
Jo-Philipp Wich
d2b2092fe6 luci-0.9: merge 5565# 2009-11-22 19:59:13 +00:00
Jo-Philipp Wich
7d2189ddfa luci-0.9: merge r5560 2009-11-21 00:24:28 +00:00
Jo-Philipp Wich
17d2f0f6b4 luci-0.9: merge r5558 2009-11-19 23:59:50 +00:00
Jo-Philipp Wich
efe3fb5880 luci-0.9: merge r5534 2009-11-11 23:19:32 +00:00
Jo-Philipp Wich
88db0de82f luci-0.9: merge r5532 2009-11-11 22:55:44 +00:00
Jo-Philipp Wich
d6697579ef luci-0.9: merge r5530 2009-11-11 22:42:31 +00:00
Jo-Philipp Wich
4fa5b90a4d luci-0.9: merge r5528 2009-11-11 13:49:13 +00:00
Jo-Philipp Wich
7e68834bf4 luci-0.9: merge r5516 2009-11-08 02:53:19 +00:00
Jo-Philipp Wich
183ca17dd2 luci-0.9: merge r5414, r5415, r5450 and 5494 2009-11-06 19:45:58 +00:00
Jo-Philipp Wich
c789622e73 luci-0.9: merge r5504 2009-11-06 13:19:45 +00:00
Jo-Philipp Wich
cef08fb346 luci-0.9: merge r5498 2009-11-01 23:00:23 +00:00
Felix Fietkau
02cfebdf60 make luci depend on the newly fixed lua host build 2009-10-27 21:20:18 +00:00
Jo-Philipp Wich
bb6c9f146b luci-0.9: merge r5412 2009-10-19 21:13:53 +00:00
Jo-Philipp Wich
08145f2ad2 luci-0.9: merge r5410 2009-10-19 21:06:14 +00:00
Jo-Philipp Wich
6b019d3cbe contrib/package: remote-update: merge r5303 as well 2009-10-19 12:32:20 +00:00
Jo-Philipp Wich
05d6d004b9 luci-0.9: merge r5407# 2009-10-19 12:22:39 +00:00
Jo-Philipp Wich
a7e91b297c luci-0.9: merge r5382 2009-10-09 00:46:32 +00:00
Jo-Philipp Wich
8a4cfc4649 luci-0.9: merge r5363 2009-10-07 19:50:53 +00:00
Jo-Philipp Wich
12c498821f luci-0.9: merge r5361 2009-10-07 17:36:13 +00:00
Jo-Philipp Wich
3432a89362 luci-0.9: merge r5359 2009-10-04 18:12:36 +00:00
Jo-Philipp Wich
bd72aa8399 luci-0.9: drop sysupgrade-atheros, went upstream 2009-10-03 18:58:35 +00:00
Jo-Philipp Wich
edda488b29 luci-0.9: merge r5340 2009-09-24 16:52:27 +00:00
Jo-Philipp Wich
aa4f626aab luci-0.9: merge r5334 2009-09-17 11:12:45 +00:00
Jo-Philipp Wich
842c39dde3 luci-0.9: merge r5330 2009-09-11 16:42:16 +00:00
Jo-Philipp Wich
f9787b70cd luci-0.9: merge r5327 2009-09-11 01:56:05 +00:00
Jo-Philipp Wich
a5eca04263 luci-0.9: merge r5320 2009-09-08 12:23:11 +00:00
Jo-Philipp Wich
4eeddc486c luci-0.9: merge r5318 2009-09-06 10:30:42 +00:00
Jo-Philipp Wich
6c74d2d77b luci-0.9: merge r5314-r5315 2009-08-29 00:08:44 +00:00
Jo-Philipp Wich
9f782466ed luci-0.9: merge r5313 2009-08-27 17:54:51 +00:00
Jo-Philipp Wich
dd6dd2d8f5 luci-0.9: merge r5310 2009-08-27 00:06:30 +00:00
Jo-Philipp Wich
5a91868704 luci-0.9: merge r5266 2009-08-13 14:37:09 +00:00
Jo-Philipp Wich
36034591e2 luci-0.9: merge r5242 2009-08-08 00:43:25 +00:00
Jo-Philipp Wich
87f3212b67 luci-0.9: merge r5240 2009-08-07 15:16:52 +00:00
Jo-Philipp Wich
3c0a06e3a0 luci-0.9: merge r5238 2009-08-07 12:26:10 +00:00
Jo-Philipp Wich
a6f5cd2547 luci-0.9: merge r5198 2009-08-05 02:07:00 +00:00
Jo-Philipp Wich
9c07466806 luci-0.9: merge r5193-r5194 2009-08-05 01:38:44 +00:00
Jo-Philipp Wich
ce8c292271 luci-0.9: merge r5195 2009-08-05 00:53:43 +00:00
Jo-Philipp Wich
66e92f5fc0 luci-0.9: merge r5191 2009-08-01 20:41:52 +00:00
Jo-Philipp Wich
e180231545 luci-0.9: merge r5184-r5189 2009-07-31 23:36:15 +00:00
Jo-Philipp Wich
92ca7f33c2 luci-0.9: merge r5176-r5182 2009-07-31 00:18:13 +00:00
Jo-Philipp Wich
79fb9f138a luci-0.9: merge r5175 2009-07-30 12:11:41 +00:00
Jo-Philipp Wich
07cb5432b3 luci-0.9: merge r5173 2009-07-30 12:08:26 +00:00
Jo-Philipp Wich
83d4fb3adb luci-0.9: merge r5171 2009-07-30 11:07:29 +00:00
Jo-Philipp Wich
afc80c0bef luci-0.9: merge r5168 2009-07-30 03:31:19 +00:00
Jo-Philipp Wich
398e0aa0a8 luci-0.9: merge r5165 2009-07-29 04:36:07 +00:00
Jo-Philipp Wich
32577be4b9 luci-0.9: merge r5154-r5161 2009-07-29 03:53:16 +00:00
Jo-Philipp Wich
ad8c39598e luci-0.9: merge r5162 2009-07-29 03:30:07 +00:00
Jo-Philipp Wich
0764c67993 luci-0.9: merge r5145-r5153 2009-07-26 23:59:58 +00:00
Jo-Philipp Wich
a545e495ba luci-0.9: merge r5130-r5143 2009-07-26 21:28:44 +00:00
Jo-Philipp Wich
c2eb3ea4a5 luci-0.9: merge r5128 2009-07-23 22:59:15 +00:00
Jo-Philipp Wich
0bfe00bd4e luci-0.9: merge r5126 2009-07-23 12:39:47 +00:00
Jo-Philipp Wich
bed30927f8 luci-0.9: merge r5124 2009-07-23 12:12:41 +00:00
Jo-Philipp Wich
853d989579 luci-0.9: disable memory debugging in dispatcher 2009-07-23 03:43:20 +00:00
Jo-Philipp Wich
6ca178a10d luci-0.9: oops, luci-voice-core slipped through 2009-07-23 03:38:15 +00:00
Jo-Philipp Wich
98f37e437d luci-0.9: merge r5113 - r5118 2009-07-23 03:35:57 +00:00
Jo-Philipp Wich
8e48d1b46f luci-0.9: remove luci-diag-* and luci-voice-* from 8.09 for now 2009-07-23 03:34:19 +00:00
Jo-Philipp Wich
1937aad896 luci-0.9: merge r5027 - r5112 2009-07-23 03:32:30 +00:00
Jo-Philipp Wich
5070549096 luci-0.9: sync translations 2009-07-17 17:47:41 +00:00
Jo-Philipp Wich
f9663bc6b6 luci-0.9: merge r5027 2009-07-07 17:31:06 +00:00
Jo-Philipp Wich
81d7f37cb6 luci-0.9: merge r5025 2009-07-07 04:10:21 +00:00
Jo-Philipp Wich
4918c60ac2 luci-0.9: merge r5022 and r5023 2009-07-07 04:02:33 +00:00
Jo-Philipp Wich
83fe3be564 luci-0.9: merge r5019 and r5020 2009-07-07 03:02:28 +00:00
Jo-Philipp Wich
f2c4ece600 luci-0.9: merge r5017 2009-07-07 02:34:44 +00:00
Jo-Philipp Wich
db5529137f luci-0.9: merge r5015 2009-07-07 00:39:25 +00:00
Jo-Philipp Wich
307540f562 luci-0.9: merge r5007-r5013 2009-07-06 23:03:18 +00:00
Jo-Philipp Wich
6a4ecfeacc luci-0.9: merge r4962 2009-07-02 22:38:33 +00:00
Jo-Philipp Wich
a4a3734a1d luci-0.9: merge r4957-r4959 2009-07-01 02:09:47 +00:00
Jo-Philipp Wich
d6cc0cf925 luci-0.9: merge r4956 2009-07-01 00:42:22 +00:00
Jo-Philipp Wich
278fd02b6a luci-0.9: merge r4954 2009-06-30 18:05:46 +00:00
Jo-Philipp Wich
acfe8ea454 luci-0.9: merge r4952 2009-06-30 18:01:54 +00:00
Jo-Philipp Wich
78111f8c87 luci-0.9: merge r4950 2009-06-30 14:51:04 +00:00
Jo-Philipp Wich
a903a2c822 luci-0.9: merge r4948 2009-06-30 14:03:30 +00:00
Jo-Philipp Wich
d4cf4403f1 luci-0.9: merge r4946 2009-06-30 05:11:25 +00:00
Jo-Philipp Wich
836e65e00e luci-0.9: merge r4941-r4944 2009-06-30 04:50:24 +00:00
Jo-Philipp Wich
9a876ab453 luci-0.9: merge r4939 2009-06-30 01:43:52 +00:00
Jo-Philipp Wich
94785efc60 luci-0.9: merge r4937 2009-06-30 01:30:23 +00:00
Jo-Philipp Wich
7ed98bf01b luci-0.9: merge r4935 2009-06-27 15:59:59 +00:00
Jo-Philipp Wich
8b01581917 luci-0.9: merge r4932 and r4933 2009-06-27 15:32:58 +00:00
Jo-Philipp Wich
d9b28ec7a4 luci-0.9: merge r4930 2009-06-27 14:36:04 +00:00
Jo-Philipp Wich
a9830fad17 luci-0.9: merge r4928 2009-06-25 21:28:19 +00:00
Jo-Philipp Wich
3a06c9ee2f luci-0.9: merge r4896 2009-06-24 20:59:56 +00:00
Jo-Philipp Wich
022404df01 luci-0.9: merge r4894 2009-06-23 19:18:35 +00:00
Jo-Philipp Wich
579505b1d0 luci-0.9: merge r4892 2009-06-22 19:34:49 +00:00
Jo-Philipp Wich
2396520413 luci-0.9: merge r4886-r4890 2009-06-22 10:23:21 +00:00
Jo-Philipp Wich
2e70805812 luci-0.9: merge r4885 2009-06-21 11:47:08 +00:00
Jo-Philipp Wich
7d141e7a0b luci-0.9: merge r4882 2009-06-21 10:45:23 +00:00
Jo-Philipp Wich
3a631ce73b luci-0.9: merge r4880-r4881 2009-06-20 21:34:33 +00:00
Jo-Philipp Wich
cc0fd37129 luci-0.9: merge r4878 2009-06-20 16:30:55 +00:00
Jo-Philipp Wich
85e4cd7cdb luci-0.9: merge r4870-r4876 2009-06-20 13:03:01 +00:00
Jo-Philipp Wich
86306c4324 luci-0.9: merge r4868 2009-06-17 12:57:34 +00:00
Jo-Philipp Wich
cd1442893a luci-0.9: merge r4865 and r4866 2009-06-17 12:49:16 +00:00
Jo-Philipp Wich
75da8f7de3 luci-0.9: merge r4863 2009-06-16 23:12:49 +00:00
Jo-Philipp Wich
5e544d4927 luci-0.9: merge r4861 2009-06-16 23:05:44 +00:00
Jo-Philipp Wich
135261e7e4 luci-0.9: merge r4856-r4859 2009-06-16 22:45:06 +00:00
Jo-Philipp Wich
d47cf50446 luci-0.9: merge r4854 2009-06-16 21:43:06 +00:00
Jo-Philipp Wich
b5f48953ab luci-0.9: merge r4852 2009-06-16 19:40:52 +00:00
Jo-Philipp Wich
8276e4c6bb luci-0.9: merge r4848, r4849 and r4850 2009-06-16 14:44:01 +00:00
Jo-Philipp Wich
9aea9f8db8 luci-0.9: merge r4846 2009-06-15 20:08:44 +00:00
Jo-Philipp Wich
64c972454f luci-0.9: merge r4843, r4844 2009-06-15 19:21:36 +00:00
Jo-Philipp Wich
db4a419f9d luci-0.9: merge r4841 2009-06-15 16:13:45 +00:00
Jo-Philipp Wich
8d7586cffc luci-0.9: merge r4835 2009-06-11 11:10:35 +00:00
Jo-Philipp Wich
2120d46596 luci-0.9: remove incomplete asterisk stuff, remove bitrot 2009-06-11 00:04:39 +00:00
Jo-Philipp Wich
de56c8e3ce luci-0.9: prepare feed Makefile 2009-06-10 23:55:09 +00:00
Jo-Philipp Wich
ee63495c36 Start LuCI 0.9.x branch 2009-06-10 23:51:29 +00:00
443 changed files with 18431 additions and 21099 deletions

View file

@ -12,7 +12,13 @@ all: build
build: gccbuild luabuild build: gccbuild luabuild
gccbuild: gccbuild:
for i in $(MODULES); do make -C$$i compile; done make -C libs/lmo CC="cc" CFLAGS="" LDFLAGS="" host-install
for i in $(MODULES); do \
make -C$$i compile || { \
echo "*** Compilation of $$i failed!"; \
exit 1; \
}; \
done
luabuild: i18nbuild luabuild: i18nbuild
for i in $(MODULES); do HOST=$(realpath host) make -C$$i luabuild; done for i in $(MODULES); do HOST=$(realpath host) make -C$$i luabuild; done
@ -23,6 +29,7 @@ i18nbuild:
clean: clean:
rm -rf docs rm -rf docs
make -C libs/lmo host-clean
for i in $(MODULES); do make -C$$i clean; done for i in $(MODULES); do make -C$$i clean; done
@ -45,15 +52,8 @@ hostenv: host ucidefaults
ucidefaults: ucidefaults:
build/hostenv.sh $(realpath host) $(LUA_MODULEDIR) $(LUA_LIBRARYDIR) "$(realpath host)/bin/uci-defaults --exclude luci-freifunk-*" build/hostenv.sh $(realpath host) $(LUA_MODULEDIR) $(LUA_LIBRARYDIR) "$(realpath host)/bin/uci-defaults --exclude luci-freifunk-*"
runboa: hostenv
libs/sgi-webuci/host/buildconfig.sh $(realpath host) > host/etc/boa/boa.conf
build/hostenv.sh $(realpath host) $(LUA_MODULEDIR) $(LUA_LIBRARYDIR) "$(realpath host/usr/bin/boa) -c $(realpath host/etc/boa) -d"
runhttpd: hostenv runhttpd: hostenv
build/hostenv.sh $(realpath host) $(LUA_MODULEDIR) $(LUA_LIBRARYDIR) "$(realpath host/usr/bin/lucittpd) $(realpath host)/usr/lib/lucittpd/plugins" build/hostenv.sh $(realpath host) $(LUA_MODULEDIR) $(LUA_LIBRARYDIR) "lua build/lucid.lua"
runluci: luahost
build/hostenv.sh $(realpath host) $(LUA_MODULEDIR) $(LUA_LIBRARYDIR) "$(realpath libs/httpd/host/runluci) $(realpath host) $(HTDOCS)"
runlua: hostenv runlua: hostenv
build/hostenv.sh $(realpath host) $(LUA_MODULEDIR) $(LUA_LIBRARYDIR) "lua -i build/setup.lua" build/hostenv.sh $(realpath host) $(LUA_MODULEDIR) $(LUA_LIBRARYDIR) "lua -i build/setup.lua"

View file

@ -17,7 +17,7 @@ module("luci.controller.ddns", package.seeall)
function index() function index()
require("luci.i18n") require("luci.i18n")
luci.i18n.loadc("ddns") luci.i18n.loadc("ddns")
if not luci.fs.access("/etc/config/ddns") then if not nixio.fs.access("/etc/config/ddns") then
return return
end end
@ -26,7 +26,7 @@ function index()
page.dependent = true page.dependent = true
local page = entry({"mini", "network", "ddns"}, cbi("ddns/ddnsmini", {autoapply=true}), luci.i18n.translate("ddns"), 60) local page = entry({"mini", "network", "ddns"}, cbi("ddns/ddns", {autoapply=true}), luci.i18n.translate("ddns"), 60)
page.i18n = "ddns" page.i18n = "ddns"
page.dependent = true page.dependent = true
end end

View file

@ -12,22 +12,39 @@ You may obtain a copy of the License at
$Id$ $Id$
]]-- ]]--
require("luci.tools.webadmin")
local is_mini = (luci.dispatcher.context.path[1] == "mini")
m = Map("ddns", translate("ddns"), translate("ddns_desc")) m = Map("ddns", translate("ddns"), translate("ddns_desc"))
s = m:section(TypedSection, "service", "") s = m:section(TypedSection, "service", "")
s.addremove = true s.addremove = true
s.anonymous = false
s:option(Flag, "enabled", translate("enable")) s:option(Flag, "enabled", translate("enable"))
svc = s:option(ListValue, "service_name", translate("service")) svc = s:option(ListValue, "service_name", translate("service"))
svc.rmempty = true svc.rmempty = true
svc:value("")
svc:value("dyndns.org") local services = { }
svc:value("changeip.com") local fd = io.open("/usr/lib/ddns/services", "r")
svc:value("zoneedit.com") if fd then
svc:value("no-ip.com") local ln
svc:value("freedns.afraid.org") repeat
ln = fd:read("*l")
local s = ln and ln:match('^%s*"([^"]+)"')
if s then services[#services+1] = s end
until not ln
fd:close()
end
local v
for _, v in luci.util.vspairs(services) do
svc:value(v)
end
svc:value("", translate("cbi_manual"))
s:option(Value, "domain", translate("hostname")).rmempty = true s:option(Value, "domain", translate("hostname")).rmempty = true
s:option(Value, "username", translate("username")).rmempty = true s:option(Value, "username", translate("username")).rmempty = true
@ -35,28 +52,38 @@ pw = s:option(Value, "password", translate("password"))
pw.rmempty = true pw.rmempty = true
pw.password = true pw.password = true
src = s:option(ListValue, "ip_source")
src:value("network", translate("network"))
src:value("interface", translate("interface"))
src:value("web", "URL")
iface = s:option(ListValue, "ip_network", translate("network")) if is_mini then
iface:depends("ip_source", "network") s.defaults.ip_source = "network"
iface.rmempty = true s.defaults.ip_network = "wan"
luci.tools.webadmin.cbi_add_networks(iface) else
require("luci.tools.webadmin")
iface = s:option(ListValue, "ip_interface", translate("interface")) src = s:option(ListValue, "ip_source")
iface:depends("ip_source", "interface") src:value("network", translate("network"))
iface.rmempty = true src:value("interface", translate("interface"))
for k, v in pairs(luci.sys.net.devices()) do src:value("web", "URL")
iface = s:option(ListValue, "ip_network", translate("network"))
iface:depends("ip_source", "network")
iface.rmempty = true
luci.tools.webadmin.cbi_add_networks(iface)
iface = s:option(ListValue, "ip_interface", translate("interface"))
iface:depends("ip_source", "interface")
iface.rmempty = true
for k, v in pairs(luci.sys.net.devices()) do
iface:value(v) iface:value(v)
end
web = s:option(Value, "ip_url", "URL")
web:depends("ip_source", "web")
web.rmempty = true
end end
web = s:option(Value, "ip_url", "URL") url = s:option(Value, "update_url")
web:depends("ip_source", "web") url:depends("service_name", "")
web.rmempty = true url.rmempty = true
s:option(Value, "update_url").optional = true
s:option(Value, "check_interval").default = 10 s:option(Value, "check_interval").default = 10
unit = s:option(ListValue, "check_unit") unit = s:option(ListValue, "check_unit")

View file

@ -1,52 +0,0 @@
--[[
LuCI - Lua Configuration Interface
Copyright 2008 Steven Barth <steven@midlink.org>
Copyright 2008 Jo-Philipp Wich <xm@leipzig.freifunk.net>
Licensed under the Apache License, Version 2.0 (the "License");
you may not use this file except in compliance with the License.
You may obtain a copy of the License at
http://www.apache.org/licenses/LICENSE-2.0
$Id$
]]--
m = Map("ddns", translate("ddns"), translate("ddns_desc"))
s = m:section(TypedSection, "service", "")
s.addremove = true
s:option(Flag, "enabled", translate("enable"))
svc = s:option(ListValue, "service_name", translate("service"))
svc.rmempty = true
svc:value("dyndns.org")
svc:value("changeip.com")
svc:value("zoneedit.com")
svc:value("no-ip.com")
svc:value("freedns.afraid.org")
s:option(Value, "domain", translate("hostname")).rmempty = true
s:option(Value, "username", translate("username")).rmempty = true
pw = s:option(Value, "password", translate("password"))
pw.rmempty = true
pw.password = true
s.defaults.ip_source = "network"
s.defaults.ip_network = "wan"
s:option(Value, "check_interval").default = 10
unit = s:option(ListValue, "check_unit")
unit.default = "minutes"
unit:value("minutes", "min")
unit:value("hours", "h")
s:option(Value, "force_interval").default = 72
unit = s:option(ListValue, "force_unit")
unit.default = "hours"
unit:value("minutes", "min")
unit:value("hours", "h")
return m

View file

@ -19,6 +19,28 @@ local uci = require "luci.model.uci".cursor()
local tools = require "luci.tools.ffwizard" local tools = require "luci.tools.ffwizard"
local util = require "luci.util" local util = require "luci.util"
local sys = require "luci.sys" local sys = require "luci.sys"
local ip = require "luci.ip"
local function mksubnet(community, meship)
local subnet_prefix = tonumber(uci:get("freifunk", community, "splash_prefix")) or 27
local pool_network = uci:get("freifunk", community, "splash_network") or "10.104.0.0/16"
local pool = luci.ip.IPv4(pool_network)
if pool then
local hosts_per_subnet = 2^(32 - subnet_prefix)
local number_of_subnets = (2^pool:prefix())/hosts_per_subnet
local seed1, seed2 = meship:match("(%d+)%.(%d+)$")
math.randomseed(seed1 * seed2)
local subnet = pool:add(hosts_per_subnet * math.random(number_of_subnets))
local subnet_ipaddr = subnet:network(subnet_prefix):add(1):string()
local subnet_netmask = subnet:mask(subnet_prefix):string()
return subnet_ipaddr, subnet_netmask
end
end
-------------------- View -------------------- -------------------- View --------------------
@ -35,11 +57,11 @@ uci:foreach("wireless", "wifi-device",
main = f:field(Flag, "wifi", "Freifunkzugang einrichten") main = f:field(Flag, "wifi", "Freifunkzugang einrichten")
net = f:field(Value, "net", "Freifunknetz", "1. Teil der IP-Adresse") net = f:field(Value, "net", "Freifunk Community", "Mesh Netzbereich")
net.rmempty = true net.rmempty = true
net:depends("wifi", "1") net:depends("wifi", "1")
uci:foreach("freifunk", "community", function(s) uci:foreach("freifunk", "community", function(s)
net:value(s[".name"], "%s (%s)" % {s.name, s.prefix}) net:value(s[".name"], "%s (%s)" % {s.name, s.mesh_network or "?"})
end) end)
function net.cfgvalue(self, section) function net.cfgvalue(self, section)
@ -50,49 +72,64 @@ function net.write(self, section, value)
uci:save("freifunk") uci:save("freifunk")
end end
meship = f:field(Value, "meship", "Mesh IP Adresse", "Netzweit eindeutige Identifikation")
subnet = f:field(Value, "subnet", "Subnetz (Projekt)", "2. Teil der IP-Adresse") meship.rmempty = true
subnet.rmempty = true meship:depends("wifi", "1")
subnet:depends("wifi", "1") function meship.cfgvalue(self, section)
function subnet.cfgvalue(self, section) return uci:get("freifunk", "wizard", "meship")
return uci:get("freifunk", "wizard", "subnet")
end end
function subnet.write(self, section, value) function meship.write(self, section, value)
uci:set("freifunk", "wizard", "subnet", value) uci:set("freifunk", "wizard", "meship", value)
uci:save("freifunk") uci:save("freifunk")
end end
function meship.validate(self, value)
node = f:field(Value, "node", "Knoten", "3. Teil der IP-Adresse") local x = ip.IPv4(value)
node.rmempty = true return ( x and x:prefix() == 32 ) and x:string() or ""
node:depends("wifi", "1")
for i=1, 51 do
node:value(i)
end
function node.cfgvalue(self, section)
return uci:get("freifunk", "wizard", "node")
end
function node.write(self, section, value)
uci:set("freifunk", "wizard", "node", value)
uci:save("freifunk")
end end
client = f:field(Flag, "client", "WLAN-DHCP anbieten") client = f:field(Flag, "client", "WLAN-DHCP anbieten")
client:depends("wifi", "1") client:depends("wifi", "1")
client.rmempty = true client.rmempty = false
function client.cfgvalue(self, section)
return uci:get("freifunk", "wizard", "dhcp_splash") or "0"
end
olsr = f:field(Flag, "olsr", "OLSR einrichten") olsr = f:field(Flag, "olsr", "OLSR einrichten")
olsr.rmempty = true olsr.rmempty = true
lat = f:field(Value, "lat", "Latitude") lat = f:field(Value, "lat", "Latitude")
lat:depends("olsr", "1") lat:depends("olsr", "1")
function lat.cfgvalue(self, section)
return uci:get("freifunk", "wizard", "latitude")
end
function lat.write(self, section, value)
uci:set("freifunk", "wizard", "latitude", value)
uci:save("freifunk")
end
lon = f:field(Value, "lon", "Longitude") lon = f:field(Value, "lon", "Longitude")
lon:depends("olsr", "1") lon:depends("olsr", "1")
function lon.cfgvalue(self, section)
return uci:get("freifunk", "wizard", "longitude")
end
function lon.write(self, section, value)
uci:set("freifunk", "wizard", "longitude", value)
uci:save("freifunk")
end
share = f:field(Flag, "sharenet", "Eigenen Internetzugang freigeben") share = f:field(Flag, "sharenet", "Eigenen Internetzugang freigeben")
share.rmempty = true share.rmempty = true
wansec = f:field(Flag, "wansec", "WAN-Zugriff auf Gateway beschränken")
wansec.rmempty = false
wansec:depends("sharenet", "1")
function wansec.cfgvalue(self, section)
return uci:get("freifunk", "wizard", "wan_security")
end
function wansec.write(self, section, value)
uci:set("freifunk", "wizard", "wan_security", value)
uci:save("freifunk")
end
-------------------- Control -------------------- -------------------- Control --------------------
function f.handle(self, state, data) function f.handle(self, state, data)
@ -122,33 +159,26 @@ function main.write(self, section, value)
end end
local device = dev:formvalue(section) local device = dev:formvalue(section)
local community, external local node_ip, external
-- Collect IP-Address -- Collect IP-Address
local inet = net:formvalue(section) local community = net:formvalue(section)
local isubnet = subnet:formvalue(section)
local inode = node:formvalue(section)
-- Invalidate fields -- Invalidate fields
if not inet then if not community then
net.tag_missing[section] = true net.tag_missing[section] = true
else else
community = inet
external = uci:get("freifunk", community, "external") or "" external = uci:get("freifunk", community, "external") or ""
inet = uci:get("freifunk", community, "prefix") or inet network = ip.IPv4(uci:get("freifunk", community, "mesh_network") or "104.0.0.0/8")
node_ip = meship:formvalue(section) and ip.IPv4(meship:formvalue(section))
if not node_ip or not network or not network:contains(node_ip) then
meship.tag_missing[section] = true
node_ip = nil
end end
if not isubnet then
subnet.tag_missing[section] = true
end
if not inode then
node.tag_missing[section] = true
end end
if not inet or not isubnet or not inode then if not node_ip then return end
return
end
local ip = "%s.%s.%s" % {inet, isubnet, inode}
-- Cleanup -- Cleanup
@ -232,7 +262,7 @@ function main.write(self, section, value)
local netconfig = uci:get_all("freifunk", "interface") local netconfig = uci:get_all("freifunk", "interface")
util.update(netconfig, uci:get_all(external, "interface") or {}) util.update(netconfig, uci:get_all(external, "interface") or {})
netconfig.proto = "static" netconfig.proto = "static"
netconfig.ipaddr = ip netconfig.ipaddr = node_ip:string()
uci:section("network", "interface", device, netconfig) uci:section("network", "interface", device, netconfig)
uci:save("network") uci:save("network")
@ -240,7 +270,7 @@ function main.write(self, section, value)
tools.firewall_zone_add_interface("freifunk", device) tools.firewall_zone_add_interface("freifunk", device)
local new_hostname = ip:gsub("%.", "-") local new_hostname = node_ip:string():gsub("%.", "-")
local old_hostname = sys.hostname() local old_hostname = sys.hostname()
uci:foreach("system", "system", uci:foreach("system", "system",
@ -335,11 +365,29 @@ end
function share.write(self, section, value) function share.write(self, section, value)
uci:delete_all("firewall", "forwarding", {src="freifunk", dest="wan"}) uci:delete_all("firewall", "forwarding", {src="freifunk", dest="wan"})
uci:delete_all("olsrd", "LoadPlugin", {library="olsrd_dyn_gw_plain.so.0.4"}) uci:delete_all("olsrd", "LoadPlugin", {library="olsrd_dyn_gw_plain.so.0.4"})
uci:foreach("firewall", "zone",
function(s)
if s.name == "wan" then
uci:delete("firewall", s['.name'], "local_restrict")
return false
end
end)
if value == "1" then if value == "1" then
uci:section("firewall", "forwarding", nil, {src="freifunk", dest="wan"}) uci:section("firewall", "forwarding", nil, {src="freifunk", dest="wan"})
uci:section("olsrd", "LoadPlugin", nil, {library="olsrd_dyn_gw_plain.so.0.4"}) uci:section("olsrd", "LoadPlugin", nil, {library="olsrd_dyn_gw_plain.so.0.4"})
if wansec:formvalue(section) == "1" then
uci:foreach("firewall", "zone",
function(s)
if s.name == "wan" then
uci:set("firewall", s['.name'], "local_restrict", "1")
return false
end end
end)
end
end
uci:save("firewall") uci:save("firewall")
uci:save("olsrd") uci:save("olsrd")
uci:save("system") uci:save("system")
@ -348,26 +396,21 @@ end
function client.write(self, section, value) function client.write(self, section, value)
if value == "0" then if value == "0" then
uci:delete("freifunk", "wizard", "dhcp_splash")
uci:save("freifunk")
return return
end end
local device = dev:formvalue(section) local device = dev:formvalue(section)
-- Collect IP-Address -- Collect IP-Address
local inet = net:formvalue(section) local node_ip = meship:formvalue(section)
local isubnet = subnet:formvalue(section)
local inode = node:formvalue(section)
if not inet or not isubnet or not inode then if not node_ip then return end
return
end local community = net:formvalue(section)
local community = inet
local external = community and uci:get("freifunk", community, "external") or "" local external = community and uci:get("freifunk", community, "external") or ""
inet = uci:get("freifunk", community, "prefix") or inet local splash_ip, splash_mask = mksubnet(community, node_ip)
local dhcpbeg = 48 + tonumber(inode) * 4
local dclient = "%s.%s.%s" % {inet:gsub("^[0-9]+", "10"), isubnet, dhcpbeg}
local limit = dhcpbeg < 252 and 3 or 2
-- Delete old alias -- Delete old alias
uci:delete("network", device .. "dhcp") uci:delete("network", device .. "dhcp")
@ -376,7 +419,8 @@ function client.write(self, section, value)
local aliasbase = uci:get_all("freifunk", "alias") local aliasbase = uci:get_all("freifunk", "alias")
util.update(aliasbase, uci:get_all(external, "alias") or {}) util.update(aliasbase, uci:get_all(external, "alias") or {})
aliasbase.interface = device aliasbase.interface = device
aliasbase.ipaddr = dclient aliasbase.ipaddr = splash_ip
aliasbase.netmask = splash_mask
aliasbase.proto = "static" aliasbase.proto = "static"
uci:section("network", "alias", device .. "dhcp", aliasbase) uci:section("network", "alias", device .. "dhcp", aliasbase)
uci:save("network") uci:save("network")
@ -440,6 +484,10 @@ function client.write(self, section, value)
-- Make sure that luci_splash is enabled -- Make sure that luci_splash is enabled
sys.exec("/etc/init.d/luci_splash enable") sys.exec("/etc/init.d/luci_splash enable")
-- Remember state
uci:set("freifunk", "wizard", "dhcp_splash", "1")
uci:save("freifunk")
end end
return f return f

View file

@ -21,7 +21,6 @@ s.anonymous = true
iface = s:option(ListValue, "src", translate("fw_src")) iface = s:option(ListValue, "src", translate("fw_src"))
oface = s:option(ListValue, "dest", translate("fw_dest")) oface = s:option(ListValue, "dest", translate("fw_dest"))
s:option(Flag, "mtu_fix", translate("fw_mtufix"))
luci.model.uci.cursor():foreach("firewall", "zone", luci.model.uci.cursor():foreach("firewall", "zone",
function (section) function (section)

View file

@ -41,7 +41,7 @@ luci.model.uci.cursor():foreach("firewall", "zone",
proto = s:option(Value, "proto", translate("protocol")) proto = s:option(Value, "proto", translate("protocol"))
proto.optional = true proto.optional = true
proto:value("") proto:value("all", translate("firewall_rule_proto_all", "Any"))
proto:value("tcpudp", "TCP+UDP") proto:value("tcpudp", "TCP+UDP")
proto:value("tcp", "TCP") proto:value("tcp", "TCP")
proto:value("udp", "UDP") proto:value("udp", "UDP")

View file

@ -16,6 +16,7 @@ m = Map("firewall", translate("fw_fw"), translate("fw_fw1"))
s = m:section(TypedSection, "defaults") s = m:section(TypedSection, "defaults")
s.anonymous = true s.anonymous = true
s.addremove = false
s:option(Flag, "syn_flood") s:option(Flag, "syn_flood")
@ -57,6 +58,7 @@ for i, v in ipairs(p) do
end end
s:option(Flag, "masq") s:option(Flag, "masq")
s:option(Flag, "mtu_fix", translate("fw_mtufix"))
net = s:option(MultiValue, "network") net = s:option(MultiValue, "network")
net.widget = "select" net.widget = "select"

View file

@ -18,7 +18,7 @@ module("luci.controller.hd_idle", package.seeall)
function index() function index()
require("luci.i18n") require("luci.i18n")
luci.i18n.loadc("hd_idle") luci.i18n.loadc("hd_idle")
if not luci.fs.access("/etc/config/hd-idle") then if not nixio.fs.access("/etc/config/hd-idle") then
return return
end end

View file

@ -13,7 +13,7 @@ $Id$
]]-- ]]--
require("luci.fs") require("nixio.fs")
m = Map("hd-idle", translate("hd_idle"), translate("hd_idle_desc")) m = Map("hd-idle", translate("hd_idle"), translate("hd_idle_desc"))
@ -24,8 +24,8 @@ s:option(Flag, "enabled", translate("enable", "Enable"))
disk = s:option(Value, "disk", translate("disk")) disk = s:option(Value, "disk", translate("disk"))
disk.rmempty = true disk.rmempty = true
for _, dev in ipairs(luci.fs.glob("/dev/[sh]d[a-z]")) do for dev in nixio.fs.glob("/dev/[sh]d[a-z]") do
disk:value(luci.fs.basename(dev)) disk:value(nixio.fs.basename(dev))
end end
s:option(Value, "idle_time_interval", translate("idle_time_interval")).default = 10 s:option(Value, "idle_time_interval", translate("idle_time_interval")).default = 10

View file

@ -15,7 +15,7 @@ $Id$
module("luci.controller.init", package.seeall) module("luci.controller.init", package.seeall)
function index() function index()
if not luci.fs.access("/etc/rc.common") then if not nixio.fs.access("/etc/rc.common") then
return return
end end
@ -23,7 +23,7 @@ function index()
luci.i18n.loadc("initmgr") luci.i18n.loadc("initmgr")
entry( entry(
{"admin", "system", "init"}, form("init/init"), {"admin", "services", "init"}, form("init/init"),
luci.i18n.translate("initmgr", "Init Scripts") luci.i18n.translate("initmgr", "Init Scripts"), 0
).i18n = "initmgr" ).i18n = "initmgr"
end end

View file

@ -32,27 +32,54 @@ end
m = SimpleForm("initmgr", translate("initmgr"), translate("initmgr_desc")) m = SimpleForm("initmgr", translate("initmgr"), translate("initmgr_desc"))
m.reset = false m.reset = false
m.submit = false
s = m:section(Table, inits) s = m:section(Table, inits)
i = s:option(DummyValue, "index", translate("initmgr_index")) i = s:option(DummyValue, "index", translate("initmgr_index"))
n = s:option(DummyValue, "name", translate("initmgr_name")) n = s:option(DummyValue, "name", translate("initmgr_name"))
e = s:option(Flag, "enabled", translate("initmgr_enabled"))
e.cfgvalue = function(self, section) e = s:option(Button, "endisable", translate("initmgr_enabled"))
return inits[section].enabled and "1" or "0"
e.render = function(self, section, scope)
if inits[section].enabled then
self.title = translate("initmgr_enable", "Enabled")
self.inputstyle = "save"
else
self.title = translate("initmgr_disable", "Disabled")
self.inputstyle = "reset"
end
Button.render(self, section, scope)
end end
e.write = function(self, section, value) e.write = function(self, section)
if value == "1" and not inits[section].enabled then if inits[section].enabled then
inits[section].enabled = true
return luci.sys.init.enable(inits[section].name)
elseif value == "0" and inits[section].enabled then
inits[section].enabled = false inits[section].enabled = false
return luci.sys.init.disable(inits[section].name) return luci.sys.init.disable(inits[section].name)
else
inits[section].enabled = true
return luci.sys.init.enable(inits[section].name)
end end
return true
end end
start = s:option(Button, "start", translate("initmgr_start", "Start"))
start.inputstyle = "apply"
start.write = function(self, section)
luci.sys.call("/etc/init.d/%s %s" %{ inits[section].name, self.option })
end
restart = s:option(Button, "restart", translate("initmgr_restart", "Restart"))
restart.inputstyle = "reload"
restart.write = start.write
stop = s:option(Button, "stop", translate("initmgr_stop", "Stop"))
stop.inputstyle = "remove"
stop.write = start.write
return m return m

View file

@ -18,7 +18,7 @@
[ function(data) { [ function(data) {
return parseFloat(data["Signal level"]) return parseFloat(data["Signal level"])
- parseFloat(data["Noise level"]); - parseFloat(data["Noise level"]);
}, "S/N (dBm)"], }, "S/N (dB)"],
// Graph layout options // Graph layout options
{ drawBackground: false, yAxis: [ 0, 50 ], { drawBackground: false, yAxis: [ 0, 50 ],

View file

@ -18,7 +18,7 @@ module("luci.controller.mmc_over_gpio", package.seeall)
function index() function index()
require("luci.i18n") require("luci.i18n")
luci.i18n.loadc("mmc_over_gpio") luci.i18n.loadc("mmc_over_gpio")
if not luci.fs.access("/etc/config/mmc_over_gpio") then if not nixio.fs.access("/etc/config/mmc_over_gpio") then
return return
end end

View file

@ -17,7 +17,7 @@ module("luci.controller.ntpc", package.seeall)
function index() function index()
require("luci.i18n") require("luci.i18n")
luci.i18n.loadc("ntpc") luci.i18n.loadc("ntpc")
if not luci.fs.access("/etc/config/ntpclient") then if not nixio.fs.access("/etc/config/ntpclient") then
return return
end end

View file

@ -16,6 +16,7 @@ m = Map("ntpclient", translate("ntpc"), translate("ntpc_desc"))
s = m:section(TypedSection, "ntpclient", translate("general")) s = m:section(TypedSection, "ntpclient", translate("general"))
s.anonymous = true s.anonymous = true
s.addremove = false
s:option(DummyValue, "_time", translate("ntpc_current")).value = os.date("%c") s:option(DummyValue, "_time", translate("ntpc_current")).value = os.date("%c")
@ -25,6 +26,8 @@ s:option(Value, "count", translate("ntpc_count"), translate("ntpc_count_desc")).
s2 = m:section(TypedSection, "ntpdrift", translate("ntpc_drift")) s2 = m:section(TypedSection, "ntpdrift", translate("ntpc_drift"))
s2.anonymous = true s2.anonymous = true
s2.addremove = false
s2:option(Value, "freq", translate("ntpc_drift_freq")).rmempty = true s2:option(Value, "freq", translate("ntpc_drift_freq")).rmempty = true

View file

@ -17,6 +17,7 @@ m = Map("ntpclient", translate("ntpc"), translate("ntpc_desc"))
s = m:section(TypedSection, "ntpclient", translate("general")) s = m:section(TypedSection, "ntpclient", translate("general"))
s.anonymous = true s.anonymous = true
s.addremove = false
s:option(DummyValue, "_time", translate("ntpc_current")).value = os.date("%c") s:option(DummyValue, "_time", translate("ntpc_current")).value = os.date("%c")

View file

@ -1,7 +1,7 @@
module("luci.controller.olsr", package.seeall) module("luci.controller.olsr", package.seeall)
function index() function index()
if not luci.fs.access("/etc/config/olsrd") then if not nixio.fs.access("/etc/config/olsrd") then
return return
end end
@ -182,7 +182,7 @@ function fetch_txtinfo(otable)
local rawdata = luci.sys.httpget("http://127.0.0.1:2006/"..otable) local rawdata = luci.sys.httpget("http://127.0.0.1:2006/"..otable)
if #rawdata == 0 then if #rawdata == 0 then
if luci.fs.access("/proc/net/ipv6_route", "r") then if nixio.fs.access("/proc/net/ipv6_route", "r") then
rawdata = luci.sys.httpget("http://[::1]:2006/"..otable) rawdata = luci.sys.httpget("http://[::1]:2006/"..otable)
if #rawdata == 0 then if #rawdata == 0 then
return nil return nil

View file

@ -90,6 +90,8 @@ for i=0,7 do
end end
willingness.optional = true willingness.optional = true
natthr = s:option(Value, "NatThreshold")
natthr.optional = true
i = m:section(TypedSection, "Interface", translate("interfaces")) i = m:section(TypedSection, "Interface", translate("interfaces"))

View file

@ -13,9 +13,8 @@ You may obtain a copy of the License at
$Id$ $Id$
]]-- ]]--
require("luci.fs") local ip = require "luci.ip"
require("luci.ip") local fs = require "nixio.fs"
if arg[1] then if arg[1] then
mp = Map("olsrd", translate("olsrd_plugins", "OLSR - Plugins")) mp = Map("olsrd", translate("olsrd_plugins", "OLSR - Plugins"))
@ -44,7 +43,7 @@ if arg[1] then
local function Cidr2IpMask(val) local function Cidr2IpMask(val)
if val then if val then
for i = 1, #val do for i = 1, #val do
local cidr = luci.ip.IPv4(val[i]) or luci.ip.IPv6(val[i]) local cidr = ip.IPv4(val[i]) or ip.IPv6(val[i])
if cidr then if cidr then
val[i] = cidr:network():string() .. " " .. cidr:mask():string() val[i] = cidr:network():string() .. " " .. cidr:mask():string()
end end
@ -59,9 +58,9 @@ if arg[1] then
local ip, mask = val[i]:gmatch("([^%s]+)%s+([^%s]+)")() local ip, mask = val[i]:gmatch("([^%s]+)%s+([^%s]+)")()
local cidr local cidr
if ip and mask and ip:match(":") then if ip and mask and ip:match(":") then
cidr = luci.ip.IPv6(ip, mask) cidr = ip.IPv6(ip, mask)
elseif ip and mask then elseif ip and mask then
cidr = luci.ip.IPv4(ip, mask) cidr = ip.IPv4(ip, mask)
end end
if cidr then if cidr then
@ -220,7 +219,7 @@ else
) )
-- create a loadplugin section for each found plugin -- create a loadplugin section for each found plugin
for k, v in pairs(luci.fs.dir("/usr/lib")) do for v in fs.dir("/usr/lib") do
if v:sub(1, 6) == "olsrd_" then if v:sub(1, 6) == "olsrd_" then
if not plugins[v] then if not plugins[v] then
mpi.uci:section( mpi.uci:section(

View file

@ -39,7 +39,7 @@ $Id$
end end
%> %>
<tr> <tr>
<td><a href="http://<%=link["Remote IP"]%>"><%=link["Remote IP"]%></a></td> <td><a href="http://<%=link["Remote IP"]%>/cgi-bin-nodes.html"><%=link["Remote IP"]%></a></td>
<td><%=link["Local IP"]%></td> <td><%=link["Local IP"]%></td>
<td><%=link.LQ%></td> <td><%=link.LQ%></td>
<td><%=link.NLQ%></td> <td><%=link.NLQ%></td>

View file

@ -12,7 +12,6 @@ You may obtain a copy of the License at
$Id$ $Id$
]]-- ]]--
require("luci.fs")
require("luci.ip") require("luci.ip")

View file

@ -12,7 +12,6 @@ You may obtain a copy of the License at
$Id$ $Id$
]]-- ]]--
require("luci.fs")
require("luci.ip") require("luci.ip")
require("luci.model.uci") require("luci.model.uci")

View file

@ -12,13 +12,9 @@ You may obtain a copy of the License at
$Id$ $Id$
]]-- ]]--
require("luci.fs") local fs = require "nixio.fs"
require("luci.ip") local sys = require "luci.sys"
require("luci.sys") local uci = require "luci.model.uci".cursor()
require("luci.model.uci")
local uci = luci.model.uci.cursor()
local m = Map("openvpn", translate("openvpn")) local m = Map("openvpn", translate("openvpn"))
local s = m:section( TypedSection, "openvpn", translate("openvpn_overview"), translate("openvpn_overview_desc") ) local s = m:section( TypedSection, "openvpn", translate("openvpn_overview"), translate("openvpn_overview_desc") )
@ -74,14 +70,12 @@ s:option( Flag, "enable", translate("openvpn_enable") )
local active = s:option( DummyValue, "_active", translate("openvpn_active") ) local active = s:option( DummyValue, "_active", translate("openvpn_active") )
function active.cfgvalue(self, section) function active.cfgvalue(self, section)
if luci.fs.isfile("/var/run/openvpn_%s.pid" % section) then local pid = fs.readfile("/var/run/openvpn_%s.pid" % section)
local pid = io.lines("/var/run/openvpn_%s.pid" % section)()
if pid and #pid > 0 and tonumber(pid) ~= nil then if pid and #pid > 0 and tonumber(pid) ~= nil then
return (luci.sys.process.signal(pid, 0)) return (sys.process.signal(pid, 0))
and translatef("openvpn_active_yes", pid) and translatef("openvpn_active_yes", pid)
or translate("openvpn_active_no") or translate("openvpn_active_no")
end end
end
return translate("openvpn_active_no") return translate("openvpn_active_no")
end end

View file

@ -1,7 +1,9 @@
#!/bin/sh #!/bin/sh
uci batch <<-EOF uci batch <<-EOF 2>/dev/null
add ucitrack freifunk_p2pblock add ucitrack freifunk_p2pblock
set ucitrack.@freifunk_p2pblock[-1].init=freifunk-p2pblock set ucitrack.@freifunk_p2pblock[-1].init=freifunk-p2pblock
commit ucitrack commit ucitrack
EOF EOF
exit 0

View file

@ -18,7 +18,7 @@ module("luci.controller.p910nd", package.seeall)
function index() function index()
require("luci.i18n") require("luci.i18n")
luci.i18n.loadc("p910nd") luci.i18n.loadc("p910nd")
if not luci.fs.access("/etc/config/p910nd") then if not nixio.fs.access("/etc/config/p910nd") then
return return
end end

View file

@ -14,7 +14,7 @@ $Id$
module("luci.controller.polipo", package.seeall) module("luci.controller.polipo", package.seeall)
function index() function index()
if not luci.fs.access("/etc/config/polipo") then if not nixio.fs.access("/etc/config/polipo") then
return return
end end

View file

@ -14,7 +14,7 @@ $Id$
module("luci.controller.qos", package.seeall) module("luci.controller.qos", package.seeall)
function index() function index()
if not luci.fs.access("/etc/config/qos") then if not nixio.fs.access("/etc/config/qos") then
return return
end end

View file

@ -11,13 +11,18 @@ You may obtain a copy of the License at
$Id$ $Id$
]]-- ]]--
require("luci.tools.webadmin")
local wa = require "luci.tools.webadmin"
local fs = require "nixio.fs"
m = Map("qos") m = Map("qos")
s = m:section(TypedSection, "interface", translate("interfaces")) s = m:section(TypedSection, "interface", translate("interfaces"))
s.addremove = true s.addremove = true
s.anonymous = true
s:option(Flag, "enabled", translate("enable")) e = s:option(Flag, "enabled", translate("enable"))
e.rmempty = false
c = s:option(ListValue, "classgroup") c = s:option(ListValue, "classgroup")
c:value("Default", "standard") c:value("Default", "standard")
@ -46,19 +51,19 @@ t.default = "Normal"
srch = s:option(Value, "srchost") srch = s:option(Value, "srchost")
srch.rmempty = true srch.rmempty = true
srch:value("", translate("all")) srch:value("", translate("all"))
luci.tools.webadmin.cbi_add_knownips(srch) wa.cbi_add_knownips(srch)
dsth = s:option(Value, "dsthost") dsth = s:option(Value, "dsthost")
dsth.rmempty = true dsth.rmempty = true
dsth:value("", translate("all")) dsth:value("", translate("all"))
luci.tools.webadmin.cbi_add_knownips(dsth) wa.cbi_add_knownips(dsth)
l7 = s:option(ListValue, "layer7", translate("service")) l7 = s:option(ListValue, "layer7", translate("service"))
l7.rmempty = true l7.rmempty = true
l7:value("", translate("all")) l7:value("", translate("all"))
local pats = luci.fs.dir("/etc/l7-protocols") local pats = fs.dir("/etc/l7-protocols")
if pats then if pats then
for i,f in ipairs(pats) do for f in pats do
if f:sub(-4) == ".pat" then if f:sub(-4) == ".pat" then
l7:value(f:sub(1, #f-4)) l7:value(f:sub(1, #f-4))
end end

View file

@ -12,7 +12,10 @@ You may obtain a copy of the License at
$Id$ $Id$
]]-- ]]--
require("luci.tools.webadmin")
local wa = require "luci.tools.webadmin"
local fs = require "nixio.fs"
m = Map("qos") m = Map("qos")
s = m:section(NamedSection, "wan", "interface", translate("m_n_inet")) s = m:section(NamedSection, "wan", "interface", translate("m_n_inet"))
@ -37,19 +40,19 @@ t.default = "Normal"
srch = s:option(Value, "srchost") srch = s:option(Value, "srchost")
srch.rmempty = true srch.rmempty = true
srch:value("", translate("all")) srch:value("", translate("all"))
luci.tools.webadmin.cbi_add_knownips(srch) wa.cbi_add_knownips(srch)
dsth = s:option(Value, "dsthost") dsth = s:option(Value, "dsthost")
dsth.rmempty = true dsth.rmempty = true
dsth:value("", translate("all")) dsth:value("", translate("all"))
luci.tools.webadmin.cbi_add_knownips(dsth) wa.cbi_add_knownips(dsth)
l7 = s:option(ListValue, "layer7", translate("service")) l7 = s:option(ListValue, "layer7", translate("service"))
l7.rmempty = true l7.rmempty = true
l7:value("", translate("all")) l7:value("", translate("all"))
local pats = luci.fs.dir("/etc/l7-protocols") local pats = fs.dir("/etc/l7-protocols")
if pats then if pats then
for i,f in ipairs(pats) do for f in pats do
if f:sub(-4) == ".pat" then if f:sub(-4) == ".pat" then
l7:value(f:sub(1, #f-4)) l7:value(f:sub(1, #f-4))
end end

View file

@ -15,7 +15,7 @@ $Id$
module("luci.controller.samba", package.seeall) module("luci.controller.samba", package.seeall)
function index() function index()
if not luci.fs.access("/etc/config/samba") then if not nixio.fs.access("/etc/config/samba") then
return return
end end
require("luci.i18n") require("luci.i18n")

View file

@ -0,0 +1,3 @@
#!/bin/sh
echo -en "Status: 302 Moved\r\n"
echo -en "Location: http://$SERVER_ADDR/cgi-bin/luci/splash\r\n\r\n"

View file

@ -11,9 +11,18 @@ function index()
end end
function action_dispatch() function action_dispatch()
local uci = luci.model.uci.cursor_state()
local mac = luci.sys.net.ip4mac(luci.http.getenv("REMOTE_ADDR")) or "" local mac = luci.sys.net.ip4mac(luci.http.getenv("REMOTE_ADDR")) or ""
local status = luci.util.execl("luci-splash status "..mac)[1] local access = false
if #mac > 0 and ( status == "whitelisted" or status == "lease" ) then
uci:foreach("luci_splash", "lease", function(s)
if s.mac and s.mac:lower() == mac then access = true end
end)
uci:foreach("luci_splash", "whitelist", function(s)
if s.mac and s.mac:lower() == mac then access = true end
end)
if #mac > 0 and access then
luci.http.redirect(luci.dispatcher.build_url()) luci.http.redirect(luci.dispatcher.build_url())
else else
luci.http.redirect(luci.dispatcher.build_url("splash", "splash")) luci.http.redirect(luci.dispatcher.build_url("splash", "splash"))
@ -24,7 +33,7 @@ function action_activate()
local ip = luci.http.getenv("REMOTE_ADDR") or "127.0.0.1" local ip = luci.http.getenv("REMOTE_ADDR") or "127.0.0.1"
local mac = luci.sys.net.ip4mac(ip:match("^[\[::ffff:]*(%d+.%d+%.%d+%.%d+)\]*$")) local mac = luci.sys.net.ip4mac(ip:match("^[\[::ffff:]*(%d+.%d+%.%d+%.%d+)\]*$"))
if mac and luci.http.formvalue("accept") then if mac and luci.http.formvalue("accept") then
os.execute("luci-splash add "..mac.." >/dev/null 2>&1") os.execute("luci-splash lease "..mac.." >/dev/null 2>&1")
luci.http.redirect(luci.model.uci.cursor():get("freifunk", "community", "homepage")) luci.http.redirect(luci.model.uci.cursor():get("freifunk", "community", "homepage"))
else else
luci.http.redirect(luci.dispatcher.build_url()) luci.http.redirect(luci.dispatcher.build_url())
@ -35,63 +44,44 @@ function action_status_admin()
local uci = luci.model.uci.cursor_state() local uci = luci.model.uci.cursor_state()
local macs = luci.http.formvaluetable("save") local macs = luci.http.formvaluetable("save")
local function delete_mac(what, mac) local changes = {
uci:delete_all("luci_splash", what, whitelist = { },
function(s) blacklist = { },
return ( s.mac and s.mac:lower() == mac ) lease = { },
end) remove = { }
end
local function leases(mac)
local leases = { }
uci:foreach("luci_splash", "lease", function(s)
if s.start and s.mac and s.mac:lower() ~= mac then
leases[#leases+1] = {
start = s.start,
mac = s.mac
} }
end
end)
uci:revert("luci_splash")
return leases
end
local function commit(leases, no_commit)
if not no_commit then
uci:save("luci_splash")
uci:commit("luci_splash")
end
for _, l in ipairs(leases) do
uci:section("luci_splash", "lease", nil, l)
end
uci:save("luci_splash")
os.execute("/etc/init.d/luci_splash restart")
end
for key, _ in pairs(macs) do for key, _ in pairs(macs) do
local policy = luci.http.formvalue("policy.%s" % key) local policy = luci.http.formvalue("policy.%s" % key)
local mac = luci.http.protocol.urldecode(key) local mac = luci.http.protocol.urldecode(key)
local lslist = leases(policy ~= "kick" and mac)
delete_mac("blacklist", mac)
delete_mac("whitelist", mac)
if policy == "whitelist" or policy == "blacklist" then if policy == "whitelist" or policy == "blacklist" then
uci:section("luci_splash", policy, nil, { mac = mac }) changes[policy][#changes[policy]+1] = mac
elseif policy == "normal" then elseif policy == "normal" then
lslist[#lslist+1] = { mac = mac, start = os.time() } changes["lease"][#changes["lease"]+1] = mac
elseif policy == "kick" then elseif policy == "kicked" then
for _, l in ipairs(lslist) do changes["remove"][#changes["remove"]+1] = mac
if l.mac:lower() == mac then l.kicked="1" end
end end
end end
commit(lslist) if #changes.whitelist > 0 then
os.execute("luci-splash whitelist %s >/dev/null"
% table.concat(changes.whitelist))
end
if #changes.blacklist > 0 then
os.execute("luci-splash blacklist %s >/dev/null"
% table.concat(changes.blacklist))
end
if #changes.lease > 0 then
os.execute("luci-splash lease %s >/dev/null"
% table.concat(changes.lease))
end
if #changes.remove > 0 then
os.execute("luci-splash remove %s >/dev/null"
% table.concat(changes.remove))
end end
luci.template.render("admin_status/splash", { is_admin = true }) luci.template.render("admin_status/splash", { is_admin = true })

View file

@ -4,30 +4,39 @@ require("luci.model.uci")
m = Map("luci_splash", "Client-Splash", [[Client-Splash ist das Freifunk Hotspot-Authentifizierungs-System.]]) m = Map("luci_splash", "Client-Splash", [[Client-Splash ist das Freifunk Hotspot-Authentifizierungs-System.]])
s = m:section(NamedSection, "general", "core", "Allgemein") s = m:section(NamedSection, "general", "core", "Allgemein")
s.addremove = false
s:option(Value, "leasetime", "Freigabezeit", "h") s:option(Value, "leasetime", "Freigabezeit", "h")
s:option(Value, "limit_up", "Upload-Limitierung", "Kilobit/s - limitiert die Upload-Geschwindigkeit von Clients") s:option(Value, "limit_up", "Upload-Limitierung", "Kilobyte/s - limitiert die Upload-Geschwindigkeit von Clients")
s:option(Value, "limit_down", "Download-Limitierung", "Kilobit/s - limitiert die Download-Geschwindigkeit von Clients") s:option(Value, "limit_down", "Download-Limitierung", "Kilobyte/s - limitiert die Download-Geschwindigkeit von Clients")
s:option(DummyValue, "_tmp", "", s:option(DummyValue, "_tmp", "",
"Bandbreitenlimitierung für Clients wird aktiviert wenn sowohl Up- als auch " .. "Bandbreitenlimitierung für Clients wird aktiviert wenn sowohl Up- als auch " ..
"Download-Geschwindigkeit angegeben werden. Auf 0 setzen um die Limitierung zu deaktivieren. " .. "Download-Geschwindigkeit angegeben werden. Auf 0 setzen um die Limitierung zu deaktivieren. " ..
"Clients in der Whitelist werden nicht limitiert.") "Clients in der Whitelist werden nicht limitiert.")
s = m:section(TypedSection, "iface", "Schnittstellen") s = m:section(TypedSection, "iface", "Schnittstellen",
"Bestimmt die Schnittstellen auf denen Splashing aktiviert werden soll. " ..
"Diese Einstellungen müssen normalerweise nicht angepasst werden.")
s.template = "cbi/tblsection" s.template = "cbi/tblsection"
s.addremove = true s.addremove = true
s.anonymous = true s.anonymous = true
local uci = luci.model.uci.cursor() local uci = luci.model.uci.cursor()
zone = s:option(ListValue, "zone", "Firewallzone") zone = s:option(ListValue, "zone", "Firewallzone",
"Splash-Regeln in der angegebenen Zone eingliedern")
uci:foreach("firewall", "zone", uci:foreach("firewall", "zone",
function (section) function (section)
zone:value(section.name) zone:value(section.name)
end) end)
iface = s:option(ListValue, "network", "Netzwerk") iface = s:option(ListValue, "network", "Netzwerk",
"Client-Verkehr auf der angegebenen Schnittstelle abfangen")
uci:foreach("network", "interface", uci:foreach("network", "interface",
function (section) function (section)
if section[".name"] ~= "loopback" then if section[".name"] ~= "loopback" then
@ -40,16 +49,35 @@ uci:foreach("network", "alias",
iface:value(section[".name"]) iface:value(section[".name"])
end) end)
s = m:section(TypedSection, "whitelist", "Automatische Freigabe")
s = m:section(TypedSection, "whitelist", "Whitelist",
"MAC-Adressen in dieser Liste werden automatisch freigegeben und unterliegen " ..
"keiner Bandbreitenlimitierung.")
s.template = "cbi/tblsection" s.template = "cbi/tblsection"
s.addremove = true s.addremove = true
s.anonymous = true s.anonymous = true
s:option(Value, "mac", "MAC-Adresse") s:option(Value, "mac", "MAC-Adresse")
s = m:section(TypedSection, "blacklist", "Automatische Sperrung")
s = m:section(TypedSection, "blacklist", "Blacklist",
"MAC-Adressen in dieser Liste werden automatisch gesperrt. Verkehr von diesen " ..
"Adressen wird komplett verworfen und es wird kein Verbindungsaufbau via WLAN " ..
"zugelassen.")
s.template = "cbi/tblsection" s.template = "cbi/tblsection"
s.addremove = true s.addremove = true
s.anonymous = true s.anonymous = true
s:option(Value, "mac", "MAC-Adresse") s:option(Value, "mac", "MAC-Adresse")
s = m:section(TypedSection, "subnet", "Freigegebene Subnetze",
"Hier eingetragene Subnetze oder Host-Adressen sind vom Splash-Vorgang ausgenommen.")
s.template = "cbi/tblsection"
s.addremove = true
s.anonymous = true
s:option(Value, "ipaddr", "IP-Adresse")
s:option(Value, "netmask", "Netzmaske", "optional bei Host-Adressen").rmempty = true
return m return m

View file

@ -18,6 +18,8 @@ local utl = require "luci.util"
local ipt = require "luci.sys.iptparser".IptParser() local ipt = require "luci.sys.iptparser".IptParser()
local uci = require "luci.model.uci".cursor_state() local uci = require "luci.model.uci".cursor_state()
local wat = require "luci.tools.webadmin" local wat = require "luci.tools.webadmin"
local fs = require "nixio.fs"
local clients = { } local clients = { }
local leasetime = tonumber(uci:get("luci_splash", "general", "leasetime") or 1) * 60 * 60 local leasetime = tonumber(uci:get("luci_splash", "general", "leasetime") or 1) * 60 * 60
local leasefile = "/tmp/dhcp.leases" local leasefile = "/tmp/dhcp.leases"
@ -35,10 +37,10 @@ uci:foreach("luci_splash", "lease",
start = tonumber(s.start), start = tonumber(s.start),
limit = ( tonumber(s.start) + leasetime ), limit = ( tonumber(s.start) + leasetime ),
mac = s.mac:upper(), mac = s.mac:upper(),
ipaddr = s.ipaddr,
policy = "normal", policy = "normal",
packets = 0, packets = 0,
bytes = 0, bytes = 0,
kicked = s.kicked and true or false
} }
end end
end) end)
@ -58,12 +60,24 @@ for _, r in ipairs(ipt:find({table="nat", chain="luci_splash_leases"})) do
end end
end end
for _, r in ipairs(ipt:find({table="filter", chain="luci_splash_counter"})) do for mac, client in pairs(clients) do
if r.options and #r.options >= 2 and r.options[1] == "MAC" then client.bytes_in = 0
local c = clients[r.options[2]:lower()] client.bytes_out = 0
if c and c.packets == 0 then client.packets_in = 0
c.bytes = tonumber(r.bytes) client.packets_out = 0
c.packets = tonumber(r.packets)
if client.ipaddr then
local rin = ipt:find({table="mangle", chain="luci_splash_mark_in", destination=client.ipaddr})
local rout = ipt:find({table="mangle", chain="luci_splash_mark_out", options={"MAC", client.mac:upper()}})
if rin and #rin > 0 then
client.bytes_in = rin[1].bytes
client.packets_in = rin[1].packets
end
if rout and #rout > 0 then
client.bytes_out = rout[1].bytes
client.packets_out = rout[1].packets
end end
end end
end end
@ -82,7 +96,7 @@ uci:foreach("luci_splash", "blacklist",
end end
end) end)
if luci.fs.access(leasefile) then if fs.access(leasefile) then
for l in io.lines(leasefile) do for l in io.lines(leasefile) do
local time, mac, ip, name = l:match("^(%d+) (%S+) (%S+) (%S+)") local time, mac, ip, name = l:match("^(%d+) (%S+) (%S+) (%S+)")
if time and mac and ip then if time and mac and ip then
@ -125,7 +139,7 @@ end
<th class="cbi-section-table-cell"><%:ff_splash_ip IP Address%></th> <th class="cbi-section-table-cell"><%:ff_splash_ip IP Address%></th>
<th class="cbi-section-table-cell"><%:ff_splash_mac MAC Address%></th> <th class="cbi-section-table-cell"><%:ff_splash_mac MAC Address%></th>
<th class="cbi-section-table-cell"><%:ff_splash_timeleft Time remaining%></th> <th class="cbi-section-table-cell"><%:ff_splash_timeleft Time remaining%></th>
<th class="cbi-section-table-cell"><%:ff_splash_traffic Outgoing traffic%></th> <th class="cbi-section-table-cell"><%:ff_splash_traffic Traffic in/out%></th>
<th class="cbi-section-table-cell"><%:ff_splash_policy Policy%></th> <th class="cbi-section-table-cell"><%:ff_splash_policy Policy%></th>
</tr> </tr>
@ -151,7 +165,7 @@ end
(c.limit >= os.time()) and wat.date_format(c.limit-os.time()) or (c.limit >= os.time()) and wat.date_format(c.limit-os.time()) or
(c.policy ~= "normal") and "-" or "<em>" .. translate("ff_splash_expired", "expired") .. "</em>" (c.policy ~= "normal") and "-" or "<em>" .. translate("ff_splash_expired", "expired") .. "</em>"
%></td> %></td>
<td class="cbi-section-table-cell"><%=wat.byte_format(c.bytes)%></td> <td class="cbi-section-table-cell"><%=wat.byte_format(c.bytes_in)%> / <%=wat.byte_format(c.bytes_out)%></td>
<td class="cbi-section-table-cell"> <td class="cbi-section-table-cell">
<% if is_admin then %> <% if is_admin then %>
<select name="policy.<%=c.mac:lower()%>" style="width:200px"> <select name="policy.<%=c.mac:lower()%>" style="width:200px">
@ -159,7 +173,7 @@ end
<option value="normal"<%=c.policy=="normal" and not c.kicked and ' selected="selected"'%>><%:ff_splash_splashed splashed%></option> <option value="normal"<%=c.policy=="normal" and not c.kicked and ' selected="selected"'%>><%:ff_splash_splashed splashed%></option>
<option value="blacklist"<%=c.policy=="blacklist" and ' selected="selected"'%>><%:ff_splash_blacklisted blacklisted%></option> <option value="blacklist"<%=c.policy=="blacklist" and ' selected="selected"'%>><%:ff_splash_blacklisted blacklisted%></option>
<% if c.policy == "normal" then -%> <% if c.policy == "normal" then -%>
<option value="kick"<%=c.kicked and ' selected="selected"'%>><%:ff_splash_tempblock temporarily blocked%> (<%=wat.date_format(c.limit-os.time())%>)</option> <option value="kicked"><%:ff_splash_tempblock temporarily blocked%></option>
<%- end %> <%- end %>
</select> </select>
<input type="submit" class="cbi-button cbi-button-save" name="save.<%=c.mac:lower()%>" value="<%:save Save%>" /> <input type="submit" class="cbi-button cbi-button-save" name="save.<%=c.mac:lower()%>" value="<%:save Save%>" />

View file

@ -1,15 +1,27 @@
#!/bin/sh /etc/rc.common #!/bin/sh /etc/rc.common
START=70 START=70
EXTRA_COMMANDS=clear_leases EXTRA_COMMANDS=clear_leases
SPLASH_INTERFACES=""
LIMIT_DOWN=0 LIMIT_DOWN=0
LIMIT_DOWN_BURST=0 LIMIT_DOWN_BURST=0
LIMIT_UP=0 LIMIT_UP=0
IPT_REPLAY=/var/run/luci_splash.iptlog
LOCK=/var/run/luci_splash.lock
include /lib/network
scan_interfaces
config_load luci_splash
silent() { silent() {
"$@" 2>/dev/null "$@" 2>/dev/null
} }
ipt_log() {
iptables -I "$@"
echo iptables -D "$@" >> $IPT_REPLAY
}
iface_add() { iface_add() {
local cfg="$1" local cfg="$1"
@ -28,76 +40,65 @@ iface_add() {
config_get netmask "$net" netmask config_get netmask "$net" netmask
[ -n "$netmask" ] || return 0 [ -n "$netmask" ] || return 0
config_get parentiface "$net" interface
[ -n "$parentiface" ] && {
config_get parentproto "$parentiface" proto
config_get parentipaddr "$parentiface" ipaddr
config_get parentnetmask "$parentiface" netmask
}
eval "$(ipcalc.sh $ipaddr $netmask)" eval "$(ipcalc.sh $ipaddr $netmask)"
iptables -t nat -A prerouting_${zone} -j luci_splash_prerouting ### Add interface specific chain entry rules
iptables -t nat -A luci_splash_prerouting -s "$NETWORK/$PREFIX" -p ! tcp -j luci_splash_portal ipt_log "zone_${zone}_prerouting" -i "${ifname%:*}" -s "$NETWORK/$PREFIX" -j luci_splash_prerouting -t nat
iptables -t nat -A luci_splash_prerouting -s "$NETWORK/$PREFIX" -d ! "$ipaddr" -j luci_splash_portal ipt_log "zone_${zone}_forward" -i "${ifname%:*}" -s "$NETWORK/$PREFIX" -j luci_splash_forwarding -t filter
iptables -t nat -A luci_splash_prerouting -s "$NETWORK/$PREFIX" -d "$ipaddr" -p tcp -m multiport ! --dport 22,80,443 -j luci_splash_portal
### Allow traffic to the same subnet
iptables -t nat -I luci_splash_prerouting -d "$ipaddr/${netmask:-32}" -j RETURN
iptables -t filter -I luci_splash_forwarding -d "$ipaddr/${netmask:-32}" -j RETURN
### Allow traffic to the mesh subnet
[ "$parentproto" = "static" -a -n "$parentipaddr" ] && {
iptables -t nat -I luci_splash_prerouting -d "$parentipaddr/${parentnetmask:-32}" -j RETURN
iptables -t filter -I luci_splash_forwarding -d "$parentipaddr/${parentnetmask:-32}" -j RETURN
}
qos_iface_add "$ifname" qos_iface_add "$ifname"
append SPLASH_INTERFACES "$ifname"
} }
iface_del() { iface_del() {
config_get zone "$1" zone config_get zone "$1" zone
[ -n "$zone" ] || return 0 [ -n "$zone" ] || return 0
config_get ifname "$1" ifname config_get net "$1" network
[ -n "$net" ] || return 0
config_get ifname "$net" ifname
[ -n "$ifname" ] || return 0 [ -n "$ifname" ] || return 0
while iptables -t nat -D prerouting_${zone} -j luci_splash_prerouting 2>&-; do :; done # Clear interface specific rules
[ -s $IPT_REPLAY ] && {
grep -- "-i ${ifname%:*}" $IPT_REPLAY | while read ln; do silent $ln; done
sed -ie "/-i ${ifname%:*}/d" $IPT_REPLAY
}
qos_iface_del "$ifname" qos_iface_del "$ifname"
} }
blacklist_add() { mac_add() {
local cfg="$1" config_get mac "$1" mac
append MACS "$mac"
config_get mac "$cfg" mac
[ -n "$mac" ] && {
iptables -t filter -I luci_splash_counter -m mac --mac-source "$mac" -j RETURN
iptables -t nat -I luci_splash_leases -m mac --mac-source "$mac" -j DROP
}
} }
whitelist_add() { subnet_add() {
local cfg="$1" local cfg="$1"
config_get mac "$cfg" mac config_get ipaddr "$cfg" ipaddr
[ -n "$mac" ] && { config_get netmask "$cfg" netmask
iptables -t filter -I luci_splash_counter -m mac --mac-source "$mac" -j RETURN
iptables -t nat -I luci_splash_leases -m mac --mac-source "$mac" -j RETURN
}
}
lease_add() { [ -n "$ipaddr" ] && {
local cfg="$1" iptables -t nat -I luci_splash_prerouting -d "$ipaddr/${netmask:-32}" -j RETURN
iptables -t filter -I luci_splash_forwarding -d "$ipaddr/${netmask:-32}" -j RETURN
config_get mac "$cfg" mac
config_get ban "$cfg" kicked
ban=${ban:+DROP}
[ -n "$mac" ] && {
local oIFS="$IFS"; IFS=":"
set -- $mac
IFS="$oIFS"; unset oIFS
local mac_pre="$1$2"
local mac_post="$3$4$5$6"
local handle="$6"
iptables -t filter -I luci_splash_counter -m mac --mac-source "$mac" -j RETURN
iptables -t mangle -I luci_splash_mark -m mac --mac-source "$mac" -j MARK --set-mark 79
iptables -t nat -I luci_splash_leases -m mac --mac-source "$mac" -j "${ban:-RETURN}"
for i in $SPLASH_INTERFACES; do
tc filter add dev $i parent 77:0 protocol ip prio 2 handle ::$handle u32 \
match u16 0x0800 0xFFFF at -2 match u32 0x$mac_post 0xFFFFFFFF at -12 \
match u16 0x$mac_pre 0xFFFF at -14 flowid 77:10
done
} }
} }
@ -106,7 +107,8 @@ qos_iface_add() {
# 77 -> download root qdisc # 77 -> download root qdisc
# 78 -> upload root qdisc # 78 -> upload root qdisc
# 79 -> fwmark # 79 -> fwmark: client->inet
# 80 -> fwmark: inet->client
silent tc qdisc del dev "$iface" root handle 77: silent tc qdisc del dev "$iface" root handle 77:
@ -125,6 +127,10 @@ qos_iface_add() {
# adding ingress can result in "File exists" if qos-scripts are active # adding ingress can result in "File exists" if qos-scripts are active
silent tc qdisc add dev "$iface" ingress silent tc qdisc add dev "$iface" ingress
# set client download speed
tc filter add dev "$iface" parent 77: protocol ip prio 2 \
handle 80 fw flowid 77:10
# set client upload speed # set client upload speed
tc filter add dev "$iface" parent ffff: protocol ip prio 1 \ tc filter add dev "$iface" parent ffff: protocol ip prio 1 \
handle 79 fw police rate ${LIMIT_UP}kbit mtu 6k burst 6k drop handle 79 fw police rate ${LIMIT_UP}kbit mtu 6k burst 6k drop
@ -141,20 +147,16 @@ qos_iface_del() {
boot() { boot() {
### Setup splash-relay ### Setup splash-relay
uci get lucid.splashr || { uci get uhttpd.splash 2>/dev/null || {
uci batch <<EOF uci batch <<EOF
set lucid.splashr=daemon set uhttpd.splash=uhttpd
set lucid.splashr.slave=httpd set uhttpd.splash.home="/www/cgi-bin/splash/"
add_list lucid.splashr.address=8082 set uhttpd.splash.interpreter=".sh=/bin/ash"
add_list lucid.splashr.publisher=splashredir set uhttpd.splash.listen_http="8082"
set lucid.splashr.enabled=1 set uhttpd.splash.index_page="splash.sh"
set uhttpd.splash.error_page="/splash.sh"
set lucid.splashredir=Redirector commit uhttpd
set lucid.splashredir.name=Splashd
set lucid.splashredir.virtual='/'
set lucid.splashredir.physical=':80/luci/splash'
commit lucid
EOF EOF
} }
@ -163,96 +165,114 @@ EOF
} }
start() { start() {
### Read chains from config lock -w $LOCK && lock $LOCK
include /lib/network
scan_interfaces
config_load luci_splash
### Find QoS limits ### Find QoS limits
config_get LIMIT_UP general limit_up config_get LIMIT_UP general limit_up
config_get LIMIT_DOWN general limit_down config_get LIMIT_DOWN general limit_down
config_get LIMIT_DOWN_BURST general limit_down_burst config_get LIMIT_DOWN_BURST general limit_down_burst
LIMIT_UP="${LIMIT_UP:-0}" LIMIT_UP="$((8*${LIMIT_UP:-0}))"
LIMIT_DOWN="${LIMIT_DOWN:-0}" LIMIT_DOWN="$((8*${LIMIT_DOWN:-0}))"
LIMIT_DOWN_BURST="${LIMIT_DOWN_BURST:-$(($LIMIT_DOWN * 2))}" LIMIT_DOWN_BURST="${LIMIT_DOWN_BURST:+$((8*$LIMIT_DOWN_BURST))}"
LIMIT_DOWN_BURST="${LIMIT_DOWN_BURST:-$(($LIMIT_DOWN / 5 * 6))}"
### Load required modules ### Load required modules
[ "$LIMIT_UP" -gt 0 -a "$LIMIT_DOWN" -gt 0 ] && { [ "$LIMIT_UP" -gt 0 -a "$LIMIT_DOWN" -gt 0 ] && {
silent insmod act_police
silent insmod cls_fw silent insmod cls_fw
silent insmod cls_u32 silent insmod cls_u32
silent insmod sch_htb silent insmod sch_htb
silent insmod sch_sfq
silent insmod sch_ingress silent insmod sch_ingress
} }
### Create subchains ### Create subchains
iptables -t filter -N luci_splash_counter
iptables -t nat -N luci_splash_portal
iptables -t nat -N luci_splash_leases
iptables -t nat -N luci_splash_prerouting iptables -t nat -N luci_splash_prerouting
iptables -t nat -N luci_splash_leases
iptables -t filter -N luci_splash_forwarding
iptables -t filter -N luci_splash_filter
[ "$LIMIT_UP" -gt 0 -a "$LIMIT_DOWN" -gt 0 ] && \ ### Clear iptables replay log
iptables -t mangle -N luci_splash_mark [ -s $IPT_REPLAY ] && . $IPT_REPLAY
echo -n > $IPT_REPLAY
### Build the main and portal rule ### Build the main and portal rule
config_foreach iface_add iface config_foreach iface_add iface
config_foreach blacklist_add blacklist config_foreach subnet_add subnet
config_foreach whitelist_add whitelist
config_foreach lease_add lease
### Build the portal rule ### Add interface independant prerouting rules
iptables -t filter -I INPUT -j luci_splash_counter iptables -t nat -A luci_splash_prerouting -j luci_splash_leases
iptables -t filter -I FORWARD -j luci_splash_counter iptables -t nat -A luci_splash_leases -p udp --dport 53 -j REDIRECT --to-ports 53
[ "$LIMIT_UP" -gt 0 -a "$LIMIT_DOWN" -gt 0 ] && \
iptables -t mangle -I PREROUTING -j luci_splash_mark
iptables -t nat -A luci_splash_portal -p udp --dport 33434:33523 -j RETURN
iptables -t nat -A luci_splash_portal -p icmp -j RETURN
iptables -t nat -A luci_splash_portal -p udp --dport 53 -j RETURN
iptables -t nat -A luci_splash_portal -j luci_splash_leases
### Build the leases rule
iptables -t nat -A luci_splash_leases -p tcp --dport 80 -j REDIRECT --to-ports 8082 iptables -t nat -A luci_splash_leases -p tcp --dport 80 -j REDIRECT --to-ports 8082
iptables -t nat -A luci_splash_leases -j DROP
### Add interface independant forwarding rules
iptables -t filter -A luci_splash_forwarding -j luci_splash_filter
iptables -t filter -A luci_splash_filter -p tcp -j REJECT --reject-with tcp-reset
iptables -t filter -A luci_splash_filter -j REJECT --reject-with icmp-net-prohibited
### Add QoS chain
[ "$LIMIT_UP" -gt 0 -a "$LIMIT_DOWN" -gt 0 ] && {
iptables -t mangle -N luci_splash_mark_out
iptables -t mangle -N luci_splash_mark_in
iptables -t mangle -I PREROUTING -j luci_splash_mark_out
iptables -t mangle -I POSTROUTING -j luci_splash_mark_in
}
### Find active mac addresses
MACS=""
config_foreach mac_add lease
config_foreach mac_add blacklist
config_foreach mac_add whitelist
### Add crontab entry ### Add crontab entry
test -f /etc/crontabs/root || touch /etc/crontabs/root test -f /etc/crontabs/root || touch /etc/crontabs/root
grep -q luci-splash /etc/crontabs/root || { grep -q luci-splash /etc/crontabs/root || {
echo '*/5 * * * * /usr/sbin/luci-splash sync' >> /etc/crontabs/root echo '*/5 * * * * /usr/sbin/luci-splash sync' >> /etc/crontabs/root
} }
lock -u $LOCK
### Populate iptables
[ -n "$MACS" ] && luci-splash add-rules $MACS
} }
stop() { stop() {
lock -w $LOCK && lock $LOCK
### Clear interface rules ### Clear interface rules
config_load luci_splash
config_foreach iface_del iface config_foreach iface_del iface
silent iptables -t filter -D INPUT -j luci_splash_counter silent iptables -t mangle -D PREROUTING -j luci_splash_mark_out
silent iptables -t filter -D FORWARD -j luci_splash_counter silent iptables -t mangle -D POSTROUTING -j luci_splash_mark_in
silent iptables -t mangle -D PREROUTING -j luci_splash_mark
### Clear subchains ### Clear subchains
silent iptables -t nat -F luci_splash_leases
silent iptables -t nat -F luci_splash_portal
silent iptables -t nat -F luci_splash_prerouting silent iptables -t nat -F luci_splash_prerouting
silent iptables -t filter -F luci_splash_counter silent iptables -t nat -F luci_splash_leases
silent iptables -t mangle -F luci_splash_mark silent iptables -t filter -F luci_splash_forwarding
silent iptables -t filter -F luci_splash_filter
silent iptables -t mangle -F luci_splash_mark_out
silent iptables -t mangle -F luci_splash_mark_in
### Delete subchains ### Delete subchains
silent iptables -t nat -X luci_splash_leases
silent iptables -t nat -X luci_splash_portal
silent iptables -t nat -X luci_splash_prerouting silent iptables -t nat -X luci_splash_prerouting
silent iptables -t filter -X luci_splash_counter silent iptables -t nat -X luci_splash_leases
silent iptables -t mangle -X luci_splash_mark silent iptables -t filter -X luci_splash_forwarding
silent iptables -t filter -X luci_splash_filter
silent iptables -t mangle -X luci_splash_mark_out
silent iptables -t mangle -X luci_splash_mark_in
sed -ie '/\/usr\/sbin\/luci-splash sync/d' /var/spool/cron/crontabs/root sed -ie '/\/usr\/sbin\/luci-splash sync/d' /var/spool/cron/crontabs/root
}
lock -u $LOCK
}
clear_leases() { clear_leases() {
stop ### Find active mac addresses
while uci -P /var/state del luci_splash.@lease[0] 2>&-;do :; done MACS=""
start config_foreach mac_add lease
### Clear leases
[ -n "$MACS" ] && luci-splash remove $MACS
} }

View file

@ -2,189 +2,327 @@
require("luci.util") require("luci.util")
require("luci.model.uci") require("luci.model.uci")
require("luci.sys")
require("luci.sys.iptparser") require("luci.sys.iptparser")
-- Init state session -- Init state session
local uci = luci.model.uci.cursor_state() local uci = luci.model.uci.cursor_state()
local ipt = luci.sys.iptparser.IptParser() local ipt = luci.sys.iptparser.IptParser()
local net = luci.sys.net
local splash_interfaces = { }
local limit_up = 0 local limit_up = 0
local limit_down = 0 local limit_down = 0
function lock()
os.execute("lock -w /var/run/luci_splash.lock && lock /var/run/luci_splash.lock")
end
function unlock()
os.execute("lock -u /var/run/luci_splash.lock")
end
function main(argv) function main(argv)
local cmd = argv[1] local cmd = table.remove(argv, 1)
local arg = argv[2] local arg = argv[1]
limit_up = tonumber(uci:get("luci_splash", "general", "limit_up")) or 0 limit_up = tonumber(uci:get("luci_splash", "general", "limit_up")) or 0
limit_down = tonumber(uci:get("luci_splash", "general", "limit_down")) or 0 limit_down = tonumber(uci:get("luci_splash", "general", "limit_down")) or 0
uci:foreach("luci_splash", "iface", function(s) if ( cmd == "lease" or cmd == "add-rules" or cmd == "remove" or
if s.network then cmd == "whitelist" or cmd == "blacklist" or cmd == "status" ) and #argv > 0
splash_interfaces[#splash_interfaces+1] = uci:get("network", s.network, "ifname") then
end lock()
end)
if cmd == "status" and arg then local arp_cache = net.arptable()
if islisted("whitelist", arg) then local leased_macs = get_known_macs("lease")
print("whitelisted") local blacklist_macs = get_known_macs("blacklist")
elseif islisted("blacklist", arg) then local whitelist_macs = get_known_macs("whitelist")
print("blacklisted")
for i, adr in ipairs(argv) do
local mac = nil
if adr:find(":") then
mac = adr:lower()
else else
local lease = haslease(arg) for _, e in ipairs(arp_cache) do
if lease and lease.kicked then if e["IP address"] == adr then
print("kicked") mac = e["HW address"]:lower()
elseif lease then break
print("lease")
else
print("unknown")
end end
end end
os.exit(0)
elseif cmd == "add" and arg then
if not haslease(arg) then
add_lease(arg)
else
print("already leased!")
os.exit(2)
end end
os.exit(0)
elseif cmd == "remove" and arg then if mac and cmd == "add-rules" then
remove_lease(arg) if leased_macs[mac] then
add_lease(mac, arp_cache, true)
elseif blacklist_macs[mac] then
add_blacklist_rule(mac)
elseif whitelist_macs[mac] then
add_whitelist_rule(mac)
end
elseif mac and cmd == "status" then
print(leased_macs[mac] and "lease"
or whitelist_macs[mac] and "whitelist"
or blacklist_macs[mac] and "blacklist"
or "new")
elseif mac and ( cmd == "whitelist" or cmd == "blacklist" or cmd == "lease" ) then
if cmd ~= "lease" and leased_macs[mac] then
print("Removing %s from leases" % mac)
remove_lease(mac)
leased_macs[mac] = nil
end
if cmd ~= "whitelist" and whitelist_macs[mac] then
print("Removing %s from whitelist" % mac)
remove_whitelist(mac)
whitelist_macs[mac] = nil
end
if cmd ~= "blacklist" and blacklist_macs[mac] then
print("Removing %s from blacklist" % mac)
remove_blacklist(mac)
blacklist_macs[mac] = nil
end
if cmd == "lease" and not leased_macs[mac] then
print("Adding %s to leases" % mac)
add_lease(mac)
leased_macs[mac] = true
elseif cmd == "whitelist" and not whitelist_macs[mac] then
print("Adding %s to whitelist" % mac)
add_whitelist(mac)
whitelist_macs[mac] = true
elseif cmd == "blacklist" and not blacklist_macs[mac] then
print("Adding %s to blacklist" % mac)
add_blacklist(mac)
blacklist_macs[mac] = true
else
print("The mac %s is already %sed" %{ mac, cmd })
end
elseif mac and cmd == "remove" then
if leased_macs[mac] then
print("Removing %s from leases" % mac)
remove_lease(mac)
leased_macs[mac] = nil
elseif whitelist_macs[mac] then
print("Removing %s from whitelist" % mac)
remove_whitelist(mac)
whitelist_macs[mac] = nil
elseif blacklist_macs[mac] then
print("Removing %s from blacklist" % mac)
remove_blacklist(mac)
blacklist_macs[mac] = nil
else
print("The mac %s is not known" % mac)
end
else
print("Can not find mac for ip %s" % argv[i])
end
end
unlock()
os.exit(0) os.exit(0)
elseif cmd == "sync" then elseif cmd == "sync" then
sync() sync()
os.exit(0) os.exit(0)
elseif cmd == "list" then
list()
os.exit(0)
else else
print("Usage: " .. argv[0] .. " <status|add|remove|sync> [MAC]") print("Usage:")
print("\n luci-splash list\n List connected, black- and whitelisted clients")
print("\n luci-splash sync\n Synchronize firewall rules and clear expired leases")
print("\n luci-splash lease <MAC-or-IP>\n Create a lease for the given address")
print("\n luci-splash blacklist <MAC-or-IP>\n Add given address to blacklist")
print("\n luci-splash whitelist <MAC-or-IP>\n Add given address to whitelist")
print("\n luci-splash remove <MAC-or-IP>\n Remove given address from the lease-, black- or whitelist")
print("")
os.exit(1) os.exit(1)
end end
end end
-- Get a list of known mac addresses
function get_known_macs(list)
local leased_macs = { }
if not list or list == "lease" then
uci:foreach("luci_splash", "lease",
function(s) leased_macs[s.mac:lower()] = true end)
end
if not list or list == "whitelist" then
uci:foreach("luci_splash", "whitelist",
function(s) leased_macs[s.mac:lower()] = true end)
end
if not list or list == "blacklist" then
uci:foreach("luci_splash", "blacklist",
function(s) leased_macs[s.mac:lower()] = true end)
end
return leased_macs
end
-- Get a list of known ip addresses
function get_known_ips(macs, arp)
local leased_ips = { }
if not macs then macs = get_known_macs() end
for _, e in ipairs(arp or net.arptable()) do
if macs[e["HW address"]:lower()] then leased_ips[e["IP address"]] = true end
end
return leased_ips
end
-- Helper to delete iptables rules
function ipt_delete_all(args, comp, off)
off = off or { }
for i, r in ipairs(ipt:find(args)) do
if comp == nil or comp(r) then
off[r.table] = off[r.table] or { }
off[r.table][r.chain] = off[r.table][r.chain] or 0
os.execute("iptables -t %q -D %q %d 2>/dev/null"
%{ r.table, r.chain, r.index - off[r.table][r.chain] })
off[r.table][r.chain] = off[r.table][r.chain] + 1
end
end
end
-- Add a lease to state and invoke add_rule -- Add a lease to state and invoke add_rule
function add_lease(mac) function add_lease(mac, arp, no_uci)
mac = mac:lower()
-- Get current ip address
local ipaddr
for _, entry in ipairs(arp or net.arptable()) do
if entry["HW address"]:lower() == mac then
ipaddr = entry["IP address"]
break
end
end
-- Add lease if there is an ip addr
if ipaddr then
if not no_uci then
uci:section("luci_splash", "lease", nil, { uci:section("luci_splash", "lease", nil, {
mac = mac, mac = mac,
ipaddr = ipaddr,
start = os.time() start = os.time()
}) })
add_rule(mac)
uci:save("luci_splash") uci:save("luci_splash")
end
add_lease_rule(mac, ipaddr)
else
print("Found no active IP for %s, lease not added" % mac)
end
end end
-- Remove a lease from state and invoke remove_rule -- Remove a lease from state and invoke remove_rule
function remove_lease(mac) function remove_lease(mac)
mac = mac:lower() mac = mac:lower()
remove_rule(mac)
uci:delete_all("luci_splash", "lease", uci:delete_all("luci_splash", "lease",
function(s) return ( s.mac:lower() == mac ) end) function(s)
if s.mac:lower() == mac then
remove_lease_rule(mac, s.ipaddr)
return true
end
return false
end)
uci:save("luci_splash") uci:save("luci_splash")
end end
-- Add a whitelist entry
function add_whitelist(mac)
uci:section("luci_splash", "whitelist", nil, { mac = mac })
uci:save("luci_splash")
uci:commit("luci_splash")
add_whitelist_rule(mac)
end
-- Add a blacklist entry
function add_blacklist(mac)
uci:section("luci_splash", "blacklist", nil, { mac = mac })
uci:save("luci_splash")
uci:commit("luci_splash")
add_blacklist_rule(mac)
end
-- Remove a whitelist entry
function remove_whitelist(mac)
mac = mac:lower()
uci:delete_all("luci_splash", "whitelist",
function(s) return not s.mac or s.mac:lower() == mac end)
uci:save("luci_splash")
uci:commit("luci_splash")
remove_lease_rule(mac)
end
-- Remove a blacklist entry
function remove_blacklist(mac)
mac = mac:lower()
uci:delete_all("luci_splash", "blacklist",
function(s) return not s.mac or s.mac:lower() == mac end)
uci:save("luci_splash")
uci:commit("luci_splash")
remove_lease_rule(mac)
end
-- Add an iptables rule -- Add an iptables rule
function add_rule(mac) function add_lease_rule(mac, ipaddr)
local a, b, c, d, e, f = mac:match("(%w+):(%w+):(%w+):(%w+):(%w+):(%w+)")
local mac_pre = "%s%s" %{ a, b }
local mac_post = "%s%s%s%s" %{ c, d, e, f }
local handle = f
if limit_up > 0 and limit_down > 0 then if limit_up > 0 and limit_down > 0 then
os.execute("iptables -t mangle -I luci_splash_mark -m mac --mac-source %q -j MARK --set-mark 79" % mac) os.execute("iptables -t mangle -I luci_splash_mark_out -m mac --mac-source %q -j MARK --set-mark 79" % mac)
os.execute("iptables -t mangle -I luci_splash_mark_in -d %q -j MARK --set-mark 80" % ipaddr)
for _, i in ipairs(splash_interfaces) do
os.execute("tc filter add dev %q parent 77:0 protocol ip prio 2 " % i ..
"handle ::%q u32 " % handle ..
"match u16 0x0800 0xFFFF at -2 match u32 0x%q 0xFFFFFFFF at -12 " % mac_post ..
"match u16 0x%q 0xFFFF at -14 flowid 77:10" % mac_pre)
end
end end
os.execute("iptables -t filter -I luci_splash_counter -m mac --mac-source %q -j RETURN" % mac) os.execute("iptables -t filter -I luci_splash_filter -m mac --mac-source %q -j RETURN" % mac)
return os.execute("iptables -t nat -I luci_splash_leases -m mac --mac-source %q -j RETURN" % mac) os.execute("iptables -t nat -I luci_splash_leases -m mac --mac-source %q -j RETURN" % mac)
end end
-- Remove an iptables rule -- Remove lease, black- or whitelist rules
function remove_rule(mac) function remove_lease_rule(mac, ipaddr)
local handle = mac:match("%w+:%w+:%w+:%w+:%w+:(%w+)")
local function ipt_delete_foreach(args)
for _, r in ipairs(ipt:find(args)) do
if r.options and #r.options >= 2 and r.options[1] == "MAC" and
r.options[2]:lower() == mac:lower()
then
os.execute("iptables -t %q -D %q -m mac --mac-source %q %s 2>/dev/null"
%{ r.table, r.chain, mac,
r.target == "MARK" and "-j MARK --set-mark 79" or
r.target and "-j %q" % r.target or "" })
end
end
end
ipt_delete_foreach({table="filter", chain="luci_splash_counter"})
ipt_delete_foreach({table="mangle", chain="luci_splash_mark"})
ipt_delete_foreach({table="nat", chain="luci_splash_leases"})
for _, i in ipairs(splash_interfaces) do
os.execute("tc filter del dev %q parent 77:0 protocol ip prio 2 " % i ..
"handle 800::%q u32 2>/dev/null" % handle)
end
ipt:resync() ipt:resync()
if ipaddr then
ipt_delete_all({table="mangle", chain="luci_splash_mark_in", destination=ipaddr})
ipt_delete_all({table="mangle", chain="luci_splash_mark_out", options={"MAC", mac:upper()}})
end
ipt_delete_all({table="filter", chain="luci_splash_filter", options={"MAC", mac:upper()}})
ipt_delete_all({table="nat", chain="luci_splash_leases", options={"MAC", mac:upper()}})
end end
-- Check whether a MAC-Address is listed in the lease state list -- Add whitelist rules
function haslease(mac) function add_whitelist_rule(mac)
mac = mac:lower() os.execute("iptables -t filter -I luci_splash_filter -m mac --mac-source %q -j RETURN" % mac)
local lease = nil os.execute("iptables -t nat -I luci_splash_leases -m mac --mac-source %q -j RETURN" % mac)
uci:foreach("luci_splash", "lease",
function (section)
if section.mac:lower() == mac then
lease = section
end
end)
return lease
end end
-- Check whether a MAC-Address is in given list -- Add blacklist rules
function islisted(what, mac) function add_blacklist_rule(mac)
mac = mac:lower() os.execute("iptables -t filter -I luci_splash_filter -m mac --mac-source %q -j DROP" % mac)
os.execute("iptables -t nat -I luci_splash_leases -m mac --mac-source %q -j DROP" % mac)
uci:foreach("luci_splash", what,
function (section)
if section.mac:lower() == mac then
stat = true
return
end
end)
return false
end
-- Returns a list of MAC-Addresses for which a rule is existing
function listrules()
local macs = { }
for i, r in ipairs(ipt:find({table="nat", chain="luci_splash_leases"})) do
if r.options and #r.options >= 2 and r.options[1] == "MAC" then
macs[r.options[2]:lower()] = true
end
end
return luci.util.keys(macs)
end end
-- Synchronise leases, remove abandoned rules -- Synchronise leases, remove abandoned rules
function sync() function sync()
local written = {} lock()
local time = os.time() local time = os.time()
-- Current leases in state files -- Current leases in state files
@ -197,36 +335,105 @@ function sync()
uci:load("luci_splash") uci:load("luci_splash")
uci:revert("luci_splash") uci:revert("luci_splash")
-- For all leases -- For all leases
for k, v in pairs(leases) do for k, v in pairs(leases) do
if v[".type"] == "lease" then if v[".type"] == "lease" then
if os.difftime(time, tonumber(v.start)) > leasetime then if os.difftime(time, tonumber(v.start)) > leasetime then
-- Remove expired -- Remove expired
remove_rule(v.mac) remove_lease_rule(v.mac, v.ipaddr)
else else
-- Rewrite state -- Rewrite state
uci:section("luci_splash", "lease", nil, { uci:section("luci_splash", "lease", nil, {
mac = v.mac, mac = v.mac,
start = v.start, ipaddr = v.ipaddr,
kicked = v.kicked start = v.start
}) })
written[v.mac:lower()] = 1
end end
elseif v[".type"] == "whitelist" or v[".type"] == "blacklist" then
written[v.mac:lower()] = 1
end
end
-- Delete rules without state
for i, r in ipairs(listrules()) do
if #r > 0 and not written[r:lower()] then
remove_rule(r)
end end
end end
uci:save("luci_splash") uci:save("luci_splash")
-- Get current IPs and MAC addresses
local macs = get_known_macs()
local ips = get_known_ips(macs)
ipt:resync()
ipt_delete_all({table="filter", chain="luci_splash_filter", options={"MAC"}},
function(r) return not macs[r.options[2]:lower()] end)
ipt_delete_all({table="nat", chain="luci_splash_leases", options={"MAC"}},
function(r) return not macs[r.options[2]:lower()] end)
ipt_delete_all({table="mangle", chain="luci_splash_mark_out", options={"MAC", "MARK", "set"}},
function(r) return not macs[r.options[2]:lower()] end)
ipt_delete_all({table="mangle", chain="luci_splash_mark_in", options={"MARK", "set"}},
function(r) return not ips[r.destination] end)
unlock()
end
-- Show client info
function list()
-- Get current arp cache
local arpcache = { }
for _, entry in ipairs(net.arptable()) do
arpcache[entry["HW address"]:lower()] = { entry["Device"]:lower(), entry["IP address"]:lower() }
end
-- Find traffic usage
local function traffic(lease)
local traffic_in = 0
local traffic_out = 0
local rin = ipt:find({table="mangle", chain="luci_splash_mark_in", destination=lease.ipaddr})
local rout = ipt:find({table="mangle", chain="luci_splash_mark_out", options={"MAC", lease.mac:upper()}})
if rin and #rin > 0 then traffic_in = math.floor( rin[1].bytes / 1024) end
if rout and #rout > 0 then traffic_out = math.floor(rout[1].bytes / 1024) end
return traffic_in, traffic_out
end
-- Print listings
local leases = uci:get_all("luci_splash")
print(string.format(
"%-17s %-15s %-9s %-4s %-7s %20s",
"MAC", "IP", "State", "Dur.", "Intf.", "Traffic down/up"
))
-- Leases
for _, s in pairs(leases) do
if s[".type"] == "lease" and s.mac then
local ti, to = traffic(s)
local mac = s.mac:lower()
local arp = arpcache[mac]
print(string.format(
"%-17s %-15s %-9s %3dm %-7s %7dKB %7dKB",
mac, s.ipaddr, "leased",
math.floor(( os.time() - tonumber(s.start) ) / 60),
arp and arp[1] or "?", ti, to
))
end
end
-- Whitelist, Blacklist
for _, s in luci.util.spairs(leases,
function(a,b) return leases[a][".type"] > leases[b][".type"] end
) do
if (s[".type"] == "whitelist" or s[".type"] == "blacklist") and s.mac then
local mac = s.mac:lower()
local arp = arpcache[mac]
print(string.format(
"%-17s %-15s %-9s %4s %-7s %9s %9s",
mac, arp and arp[2] or "?", s[".type"],
"- ", arp and arp[1] or "?", "-", "-"
))
end
end
end end
main(arg) main(arg)

View file

@ -4,4 +4,6 @@
/etc/init.d/luci_statistics enabled || /etc/init.d/luci_statistics enable /etc/init.d/luci_statistics enabled || /etc/init.d/luci_statistics enable
/etc/init.d/collectd enabled || /etc/init.d/collectd enable /etc/init.d/collectd enabled || /etc/init.d/collectd enable
exit 0
} }

View file

@ -17,7 +17,7 @@ module("luci.controller.luci_statistics.luci_statistics", package.seeall)
function index() function index()
require("luci.fs") require("nixio.fs")
require("luci.util") require("luci.util")
require("luci.i18n") require("luci.i18n")
require("luci.statistics.datatree") require("luci.statistics.datatree")
@ -32,7 +32,7 @@ function index()
-- override entry(): check for existance <plugin>.so where <plugin> is derived from the called path -- override entry(): check for existance <plugin>.so where <plugin> is derived from the called path
function _entry( path, ... ) function _entry( path, ... )
local file = path[5] or path[4] local file = path[5] or path[4]
if luci.fs.access( "/usr/lib/collectd/" .. file .. ".so" ) then if nixio.fs.access( "/usr/lib/collectd/" .. file .. ".so" ) then
entry( path, ... ) entry( path, ... )
end end
end end
@ -161,6 +161,18 @@ function statistics_render()
local span = vars.timespan or uci:get( "luci_statistics", "rrdtool", "default_timespan" ) or spans[1] local span = vars.timespan or uci:get( "luci_statistics", "rrdtool", "default_timespan" ) or spans[1]
local graph = luci.statistics.rrdtool.Graph( luci.util.parse_units( span ) ) local graph = luci.statistics.rrdtool.Graph( luci.util.parse_units( span ) )
-- deliver image
if vars.img then
local l12 = require "luci.ltn12"
local png = io.open(graph.opts.imgpath .. "/" .. vars.img:gsub("%.+", "."), "r")
if png then
luci.http.prepare_content("image/png")
l12.pump.all(l12.source.file(png), luci.http.write)
png:close()
end
return
end
local plugin, instances local plugin, instances
local images = { } local images = { }

View file

@ -17,7 +17,7 @@ module("luci.statistics.datatree", package.seeall)
local util = require("luci.util") local util = require("luci.util")
local sys = require("luci.sys") local sys = require("luci.sys")
local fs = require("luci.fs") local fs = require("nixio.fs")
local uci = require("luci.model.uci").cursor() local uci = require("luci.model.uci").cursor()
local sections = uci:get_all("luci_statistics") local sections = uci:get_all("luci_statistics")
@ -50,6 +50,19 @@ function Instance._mkpath( self, plugin, pinstance )
return dir return dir
end end
function Instance._ls( self, ... )
local ditr = fs.dir(self:_mkpath(...))
if ditr then
local dirs = { }
while true do
local d = ditr()
if not d then break end
dirs[#dirs+1] = d
end
return dirs
end
end
function Instance._notzero( self, table ) function Instance._notzero( self, table )
for k in pairs(table) do for k in pairs(table) do
return true return true
@ -59,7 +72,7 @@ function Instance._notzero( self, table )
end end
function Instance._scan( self ) function Instance._scan( self )
local dirs = fs.dir( self:_mkpath() ) local dirs = self:_ls()
if not dirs then if not dirs then
return return
end end
@ -72,7 +85,7 @@ function Instance._scan( self )
for _, dir in ipairs(dirs) do for _, dir in ipairs(dirs) do
if dir ~= "." and dir ~= ".." and if dir ~= "." and dir ~= ".." and
fs.stat(self:_mkpath(dir)).type == "directory" fs.stat(self:_mkpath(dir)).type == "dir"
then then
local plugin = dir:gsub("%-.+$", "") local plugin = dir:gsub("%-.+$", "")
if not self._plugins[plugin] then if not self._plugins[plugin] then
@ -83,7 +96,7 @@ function Instance._scan( self )
for plugin, instances in pairs( self._plugins ) do for plugin, instances in pairs( self._plugins ) do
local dirs = fs.dir( self:_mkpath() ) local dirs = self:_ls()
if type(dirs) == "table" then if type(dirs) == "table" then
for i, dir in ipairs(dirs) do for i, dir in ipairs(dirs) do
@ -101,7 +114,7 @@ function Instance._scan( self )
for instance, data_instances in pairs( instances ) do for instance, data_instances in pairs( instances ) do
dirs = fs.dir( self:_mkpath( plugin, instance ) ) dirs = self:_ls(plugin, instance)
if type(dirs) == "table" then if type(dirs) == "table" then
for i, file in ipairs(dirs) do for i, file in ipairs(dirs) do

View file

@ -43,13 +43,13 @@ end
function Instance.title( self, plugin, pinst, dtype, dinst ) function Instance.title( self, plugin, pinst, dtype, dinst )
local title = self.i18n.translate( local title = self.i18n.string(
string.format( "stat_dg_title_%s_%s_%s", plugin, pinst, dtype ), string.format( "stat_dg_title_%s_%s_%s", plugin, pinst, dtype ),
self.i18n.translate( self.i18n.string(
string.format( "stat_dg_title_%s_%s", plugin, pinst ), string.format( "stat_dg_title_%s_%s", plugin, pinst ),
self.i18n.translate( self.i18n.string(
string.format( "stat_dg_title_%s__%s", plugin, dtype ), string.format( "stat_dg_title_%s__%s", plugin, dtype ),
self.i18n.translate( self.i18n.string(
string.format( "stat_dg_title_%s", plugin ), string.format( "stat_dg_title_%s", plugin ),
self.graph:_mkpath( plugin, pinst, dtype ) self.graph:_mkpath( plugin, pinst, dtype )
) )
@ -68,13 +68,13 @@ end
function Instance.label( self, plugin, pinst, dtype, dinst ) function Instance.label( self, plugin, pinst, dtype, dinst )
local label = self.i18n.translate( local label = self.i18n.string(
string.format( "stat_dg_label_%s_%s_%s", plugin, pinst, dtype ), string.format( "stat_dg_label_%s_%s_%s", plugin, pinst, dtype ),
self.i18n.translate( self.i18n.string(
string.format( "stat_dg_label_%s_%s", plugin, pinst ), string.format( "stat_dg_label_%s_%s", plugin, pinst ),
self.i18n.translate( self.i18n.string(
string.format( "stat_dg_label_%s__%s", plugin, dtype ), string.format( "stat_dg_label_%s__%s", plugin, dtype ),
self.i18n.translate( self.i18n.string(
string.format( "stat_dg_label_%s", plugin ), string.format( "stat_dg_label_%s", plugin ),
self.graph:_mkpath( plugin, pinst, dtype ) self.graph:_mkpath( plugin, pinst, dtype )
) )
@ -93,13 +93,13 @@ end
function Instance.ds( self, source ) function Instance.ds( self, source )
local label = self.i18n.translate( local label = self.i18n.string(
string.format( "stat_ds_%s_%s_%s", source.type, source.instance, source.ds ), string.format( "stat_ds_%s_%s_%s", source.type, source.instance, source.ds ),
self.i18n.translate( self.i18n.string(
string.format( "stat_ds_%s_%s", source.type, source.instance ), string.format( "stat_ds_%s_%s", source.type, source.instance ),
self.i18n.translate( self.i18n.string(
string.format( "stat_ds_label_%s__%s", source.type, source.ds ), string.format( "stat_ds_label_%s__%s", source.type, source.ds ),
self.i18n.translate( self.i18n.string(
string.format( "stat_ds_%s", source.type ), string.format( "stat_ds_%s", source.type ),
source.type .. "_" .. source.instance:gsub("[^%w]","_") .. "_" .. source.ds source.type .. "_" .. source.instance:gsub("[^%w]","_") .. "_" .. source.ds
) )

View file

@ -22,7 +22,8 @@ require("luci.statistics.i18n")
require("luci.model.uci") require("luci.model.uci")
require("luci.util") require("luci.util")
require("luci.sys") require("luci.sys")
require("luci.fs")
local fs = require "nixio.fs"
Graph = luci.util.class() Graph = luci.util.class()
@ -96,7 +97,7 @@ function Graph._rrdtool( self, def, rrd )
-- prepare directory -- prepare directory
local dir = def[1]:gsub("/[^/]+$","") local dir = def[1]:gsub("/[^/]+$","")
luci.fs.mkdir( dir, true ) fs.mkdirr( dir )
-- construct commandline -- construct commandline
local cmdline = "rrdtool graph" local cmdline = "rrdtool graph"
@ -500,7 +501,7 @@ function Graph.render( self, plugin, plugin_instance )
-- check for a whole graph handler -- check for a whole graph handler
local plugin_def = "luci.statistics.rrdtool.definitions." .. plugin local plugin_def = "luci.statistics.rrdtool.definitions." .. plugin
local stat, def = luci.util.copcall( require, plugin_def ) local stat, def = pcall( require, plugin_def )
if stat and def and type(def.rrdargs) == "function" then if stat and def and type(def.rrdargs) == "function" then
@ -539,7 +540,7 @@ function Graph.render( self, plugin, plugin_instance )
-- check for data type handler -- check for data type handler
local dtype_def = plugin_def .. "." .. dtype local dtype_def = plugin_def .. "." .. dtype
local stat, def = luci.util.copcall( require, dtype_def ) local stat, def = pcall( require, dtype_def )
if stat and def and type(def.rrdargs) == "function" then if stat and def and type(def.rrdargs) == "function" then

View file

@ -16,7 +16,6 @@ $Id$
module("luci.statistics.rrdtool.definitions", package.seeall) module("luci.statistics.rrdtool.definitions", package.seeall)
require("luci.util") require("luci.util")
require("luci.fs")
Instance = luci.util.class() Instance = luci.util.class()

View file

@ -22,7 +22,7 @@ about open tcp connections, interface traffic, iptables rules etc.%></p>
<p><%:stat_networkplugins_installed Installed network plugins:%> <p><%:stat_networkplugins_installed Installed network plugins:%>
<ul> <ul>
<% for plugin, desc in pairs(plugins) do %> <% for plugin, desc in pairs(plugins) do %>
<% if luci.fs.access("/usr/lib/collectd/" .. plugin .. ".so") then %> <% if nixio.fs.access("/usr/lib/collectd/" .. plugin .. ".so") then %>
<li><a href="<%=controller%>/admin/statistics/collectd/network/<%=plugin%>"><%=desc%></a></li> <li><a href="<%=controller%>/admin/statistics/collectd/network/<%=plugin%>"><%=desc%></a></li>
<% end %> <% end %>
<% end %> <% end %>

View file

@ -23,7 +23,7 @@ and to transmit the data over the network to other collectd instances.%></p>
<p><%:stat_outputplugins_installed Installed output plugins:%> <p><%:stat_outputplugins_installed Installed output plugins:%>
<ul> <ul>
<% for plugin, desc in pairs(plugins) do %> <% for plugin, desc in pairs(plugins) do %>
<% if luci.fs.access("/usr/lib/collectd/" .. plugin .. ".so") then %> <% if nixio.fs.access("/usr/lib/collectd/" .. plugin .. ".so") then %>
<li><a href="<%=controller%>/admin/statistics/collectd/output/<%=plugin%>"><%=desc%></a></li> <li><a href="<%=controller%>/admin/statistics/collectd/output/<%=plugin%>"><%=desc%></a></li>
<% end %> <% end %>
<% end %> <% end %>

View file

@ -19,7 +19,7 @@ $Id$
<p><%:stat_systemplugins_desc System plugins collecting values about system state and ressource usage on the device.:%> <p><%:stat_systemplugins_desc System plugins collecting values about system state and ressource usage on the device.:%>
<ul> <ul>
<% for plugin, desc in pairs(plugins) do %> <% for plugin, desc in pairs(plugins) do %>
<% if luci.fs.access("/usr/lib/collectd/" .. plugin .. ".so") then %> <% if nixio.fs.access("/usr/lib/collectd/" .. plugin .. ".so") then %>
<li><a href="<%=controller%>/admin/statistics/collectd/system/<%=plugin%>"><%=desc%></a></li> <li><a href="<%=controller%>/admin/statistics/collectd/system/<%=plugin%>"><%=desc%></a></li>
<% end %> <% end %>
<% end %> <% end %>

View file

@ -31,7 +31,7 @@ $Id$
<div style="text-align: center"> <div style="text-align: center">
<% for i, img in ipairs(images) do %> <% for i, img in ipairs(images) do %>
<img src="/rrdimg/<%=img%>" /> <img src="<%=REQUEST_URI%>?img=<%=img%>" />
<br /> <br />
<% end %> <% end %>
</div> </div>

View file

@ -1,6 +1,6 @@
config 'statistics' 'rrdtool' config 'statistics' 'rrdtool'
option 'default_timespan' '1hour' option 'default_timespan' '1hour'
option 'image_width' '400' option 'image_width' '600'
option 'image_path' '/tmp/rrdimg' option 'image_path' '/tmp/rrdimg'
config 'statistics' 'collectd' config 'statistics' 'collectd'
@ -8,7 +8,7 @@ config 'statistics' 'collectd'
option 'Include' '/etc/collectd/conf.d' option 'Include' '/etc/collectd/conf.d'
option 'PIDFile' '/var/run/collectd.pid' option 'PIDFile' '/var/run/collectd.pid'
option 'PluginDir' '/usr/lib/collectd' option 'PluginDir' '/usr/lib/collectd'
option 'TypesDB' '/usr/lib/collectd/types.db' option 'TypesDB' '/usr/share/collectd/types.db'
option 'Interval' '30' option 'Interval' '30'
option 'ReadThreads' '2' option 'ReadThreads' '2'

View file

@ -13,14 +13,13 @@ start() {
/usr/bin/stat-genconfig > /var/etc/collectd.conf /usr/bin/stat-genconfig > /var/etc/collectd.conf
### prepare rrdimg directory ### prepare rrdimg directory
if [ ! -L /www/rrdimg ]; then if [ -f /etc/config/lucid ] && [ -x /etc/init.d/lucid ] && /etc/init.d/lucid enabled && \
imagepath="$(uci get luci_statistics.rrdtool.image_path)" [ "$(uci get luci_statistics.rrdtool.image_path 2>/dev/null)" != "$(uci get lucid.statistics.physical 2>/dev/null)" ]; then
ln -s ${imagepath:-/tmp/rrdimg}/ /www/rrdimg uci set lucid.statistics.physical=$(uci get luci_statistics.rrdtool.image_path)
uci commit lucid
/etc/init.d/lucid restart
fi fi
### flush LuCI index cache
test -f /var/luci-indexcache && rm /var/luci-indexcache
### workaround broken permissions on /tmp ### workaround broken permissions on /tmp
chmod 1777 /tmp chmod 1777 /tmp
} }

View file

@ -1,7 +1,35 @@
#!/bin/sh #!/bin/sh
uci batch <<-EOF # register commit handler
[ -f /etc/config/ucitrack ] && \
[ "$(uci get ucitrack.@luci_statistics[0] 2>/dev/null)" != "luci_statistics" ] && \
uci batch <<-EOF >/dev/null 2>/dev/null
add ucitrack luci_statistics add ucitrack luci_statistics
set ucitrack.@luci_statistics[-1].init=luci_statistics set ucitrack.@luci_statistics[-1].init=luci_statistics
commit ucitrack commit ucitrack
EOF EOF
# register LuCId virtual path handler
[ -f /etc/config/lucid ] && \
[ "$(uci get lucid.statistics 2>/dev/null)" != "DirectoryPublisher" ] && \
uci batch <<-EOF >/dev/null 2>/dev/null
set lucid.statistics=DirectoryPublisher
set lucid.statistics.name='RRDTool Image Cache'
set lucid.statistics.physical=/tmp/rrdimg
set lucid.statistics.virtual=/rrdimg
set lucid.statistics.domain=''
add_list lucid.http.publisher=statistics
add_list lucid.https.publisher=statistics
commit lucid
EOF
# symlink for busybox httpd
[ -x /usr/sbin/httpd ] && [ ! -h /www/rrdimg ] && \
ln -s /tmp/rrdimg /www/rrdimg
# restart LuCId service
[ -x /etc/init.d/lucid ] && /etc/init.d/lucid enabled && /etc/init.d/lucid restart
exit 0

View file

@ -25,6 +25,11 @@ local uci = luci.model.uci.cursor()
local sections = uci:get_all( "luci_statistics" ) local sections = uci:get_all( "luci_statistics" )
function print(...)
nixio.stdout:write(...)
nixio.stdout:write("\n")
end
function section( plugin ) function section( plugin )
local config = sections[ "collectd_" .. plugin ] or sections["collectd"] local config = sections[ "collectd_" .. plugin ] or sections["collectd"]

View file

@ -15,7 +15,7 @@ $Id$
module("luci.controller.tinyproxy", package.seeall) module("luci.controller.tinyproxy", package.seeall)
function index() function index()
if not luci.fs.access("/etc/config/tinyproxy") then if not nixio.fs.access("/etc/config/tinyproxy") then
return return
end end

View file

@ -15,7 +15,7 @@ $Id$
module("luci.controller.upnp", package.seeall) module("luci.controller.upnp", package.seeall)
function index() function index()
if not luci.fs.access("/etc/config/upnpd") then if not nixio.fs.access("/etc/config/upnpd") then
return return
end end

View file

@ -18,18 +18,6 @@ s = m:section(NamedSection, "config", "upnpd", "")
e = s:option(Flag, "enabled", translate("enable")) e = s:option(Flag, "enabled", translate("enable"))
e.rmempty = false e.rmempty = false
function e.write(self, section, value)
local cmd = (value == "1") and "enable" or "disable"
if value ~= "1" then
os.execute("/etc/init.d/miniupnpd stop")
end
os.execute("/etc/init.d/miniupnpd " .. cmd)
end
function e.cfgvalue(self, section)
return (os.execute("/etc/init.d/miniupnpd enabled") == 0) and "1" or "0"
end
s:option(Flag, "secure_mode").rmempty = true s:option(Flag, "secure_mode").rmempty = true
s:option(Flag, "log_output").rmempty = true s:option(Flag, "log_output").rmempty = true
s:option(Value, "download", nil, "kByte/s").rmempty = true s:option(Value, "download", nil, "kByte/s").rmempty = true

View file

@ -18,18 +18,6 @@ s = m:section(NamedSection, "config", "upnpd", "")
e = s:option(Flag, "enabled", translate("enable")) e = s:option(Flag, "enabled", translate("enable"))
e.rmempty = false e.rmempty = false
function e.write(self, section, value)
local cmd = (value == "1") and "enable" or "disable"
if value ~= "1" then
os.execute("/etc/init.d/miniupnpd stop")
end
os.execute("/etc/init.d/miniupnpd " .. cmd)
end
function e.cfgvalue(self, section)
return (os.execute("/etc/init.d/miniupnpd enabled") == 0) and "1" or "0"
end
s:option(Value, "download", nil, "kByte/s").rmempty = true s:option(Value, "download", nil, "kByte/s").rmempty = true
s:option(Value, "upload", nil, "kByte/s").rmempty = true s:option(Value, "upload", nil, "kByte/s").rmempty = true

View file

@ -18,7 +18,7 @@ module("luci.controller.ushare", package.seeall)
function index() function index()
require("luci.i18n") require("luci.i18n")
luci.i18n.loadc("ushare") luci.i18n.loadc("ushare")
if not luci.fs.access("/etc/config/ushare") then if not nixio.fs.access("/etc/config/ushare") then
return return
end end

View file

@ -1,5 +0,0 @@
#!/bin/sh
[ -n "${IPKG_INSTROOT}" ] || {
( . /etc/uci-defaults/luci-uvc_streamer ) && rm -f /etc/uci-defaults/luci-uvc_streamer
/etc/init.d/uvc-streamer enabled || /etc/init.d/uvc-streamer enable
}

View file

@ -1,28 +0,0 @@
--[[
LuCI UVC Streamer
(c) 2008 Yanira <forum-2008@email.de>
Licensed under the Apache License, Version 2.0 (the "License");
you may not use this file except in compliance with the License.
You may obtain a copy of the License at
http://www.apache.org/licenses/LICENSE-2.0
$Id$
]]--
module("luci.controller.uvc_streamer", package.seeall)
function index()
require("luci.i18n")
luci.i18n.loadc("uvc_streamer")
if not luci.fs.access("/etc/config/uvc-streamer") then
return
end
local page = entry({"admin", "services", "uvc_streamer"}, cbi("uvc_streamer"), luci.i18n.translate("uvc_streamer", "UVC Streaming"), 60)
page.i18n = "uvc_streamer"
page.dependent = true
end

View file

@ -1,47 +0,0 @@
--[[
LuCI UVC Streamer
(c) 2008 Yanira <forum-2008@email.de>
Licensed under the Apache License, Version 2.0 (the "License");
you may not use this file except in compliance with the License.
You may obtain a copy of the License at
http://www.apache.org/licenses/LICENSE-2.0
$Id$
]]--
-- find current lan address and port of first uvc_streamer config section
local uci = luci.model.uci.cursor_state()
local addr = uci:get("network", "lan", "ipaddr")
local port
uci:foreach( "uvc-streamer", "uvc-streamer",
function(section) port = port or tonumber(section.port) end )
addr = addr or "192.168.1.1"
port = port or 8080
m = Map("uvc-streamer", translate("uvc_streamer"),
translatef("uvc_streamer_desc", nil, addr, port, addr, port))
s = m:section(TypedSection, "uvc-streamer", translate("settings"))
s.addremove = false
s.anonymous = true
s:option(Flag, "enabled", translate("enabled", "Enable"))
s:option(Value, "device", translate("device")).rmempty = true
nm = s:option(Value, "resolution", translate("resolution"))
nm:value("640x480")
nm:value("320x240")
nm:value("160x120")
s:option(Value, "framespersecond", translate("framespersecond")).rmempty = true
s:option(Value, "port", translate("port", "Port")).rmempty = true
return m

View file

@ -1,7 +0,0 @@
#!/bin/sh
uci batch <<-EOF
add ucitrack uvc-streamer
set ucitrack.@uvc-streamer[-1].init=uvc-streamer
commit ucitrack
EOF

View file

@ -1,41 +0,0 @@
#package uvc-streamer
config package
option title 'UVC-Streamer webcam streaming configuration'
config section
option name 'uvc-streamer'
option package 'uvc-streamer'
option title 'Settings'
option unique true
option required true
config variable
option name 'enabled'
option section 'uvc-streamer.uvc-streamer'
option title 'Enable'
option required true
option datatype boolean
config variable
option name 'device'
option section 'uvc-streamer.uvc-streamer'
option title 'Device'
config variable
option name 'resolution'
option section 'uvc-streamer.uvc-streamer'
option title 'Resolution'
option required true
config variable
option name 'framespersecond'
option section 'uvc-streamer.uvc-streamer'
option title 'Frames per second'
option datatype uint
config variable
option name 'port'
option section 'uvc-streamer.uvc-streamer'
option title 'Port'
option datatype port

View file

@ -10,7 +10,7 @@ RANLIB = ranlib
CFLAGS = -O2 CFLAGS = -O2
FPIC = -fPIC FPIC = -fPIC
EXTRA_CFLAGS = --std=gnu99 EXTRA_CFLAGS = --std=gnu99
WFLAGS = -Wall -Werror -pedantic WFLAGS = -Wall -pedantic
CPPFLAGS = CPPFLAGS =
COMPILE = $(CC) $(CPPFLAGS) $(CFLAGS) $(EXTRA_CFLAGS) $(WFLAGS) COMPILE = $(CC) $(CPPFLAGS) $(CFLAGS) $(EXTRA_CFLAGS) $(WFLAGS)
ifeq ($(OS),Darwin) ifeq ($(OS),Darwin)

View file

@ -10,67 +10,17 @@ if( ! -d $target_dir )
system('mkdir', '-p', $target_dir); system('mkdir', '-p', $target_dir);
} }
my %target_strings;
if( open F, "find $source_dir -type f -name '*.po' |" ) if( open F, "find $source_dir -type f -name '*.po' |" )
{ {
while( chomp( my $file = readline F ) ) while( chomp( my $file = readline F ) )
{ {
if( open L, "< $file" )
{
my $content = 0;
my ( $lang, $basename ) = $file =~ m{.+/(\w+)/([^/]+)\.po$}; my ( $lang, $basename ) = $file =~ m{.+/(\w+)/([^/]+)\.po$};
$lang = lc $lang; $lang = lc $lang;
$lang =~ s/_/-/g; $lang =~ s/_/-/g;
if( open D, "> $target_dir/$basename.$lang.lua" ) printf "Generating %-40s ", "$target_dir/$basename.$lang.lmo";
{ system("./build/po2lmo", $file, "$target_dir/$basename.$lang.lmo");
printf "Generating %-40s ", "$target_dir/$basename.$lang.lua"; print ( -f "$target_dir/$basename.$lang.lmo" ? "done\n" : "empty\n" );
my ( $k, $v );
while( chomp( my $line = readline L ) || ( defined($k) && defined($v) ) )
{
if( $line =~ /^msgid "(.+)"/ )
{
$k = $1;
}
elsif( $k && $line =~ /^msgstr "(.*)"/ )
{
$v = $1;
}
elsif( $k && defined($v) && $line =~ /^"(.+)"/ )
{
$v .= $1;
}
else
{
if( $k && defined($v) && length($v) > 0 )
{
$v =~ s/\\(['"\\])/$1/g;
$v =~ s/(['\\])/\\$1/g;
printf D "%s='%s'\n", $k, $v;
$content++;
}
$k = $v = undef;
}
}
print $content ? "done ($content strings)\n" : "empty\n";
close D;
unlink("$target_dir/$basename.$lang.lua")
unless( $content > 0 );
}
close L;
}
} }
close F; close F;

2
build/lucid.lua Normal file
View file

@ -0,0 +1,2 @@
dofile "build/setup.lua"
require "luci.lucid".start()

View file

@ -11,10 +11,17 @@ else
fi fi
cat <<EOF > $1 cat <<EOF > $1
local pcall, dofile, _G = pcall, dofile, _G
module "luci.version" module "luci.version"
distname = "${2:-OpenWrt}" if pcall(dofile, "/etc/openwrt_release") and _G.DISTRIB_DESCRIPTION then
distversion = "${3:-Development Snapshot}" distname = ""
distversion = _G.DISTRIB_DESCRIPTION
else
distname = "${2:-OpenWrt}"
distversion = "${3:-Development Snapshot}"
end
luciname = "$variant" luciname = "$variant"
luciversion = "${5:-svn}" luciversion = "${5:-svn}"

View file

@ -27,7 +27,7 @@ luasource:
ifneq ($(PO),) ifneq ($(PO),)
mkdir -p dist$(LUCI_I18NDIR) mkdir -p dist$(LUCI_I18NDIR)
for file in $(PO); do \ for file in $(PO); do \
cp $(HOST)/lua-po/$$file.$(if $(PO_LANG),$(PO_LANG),*).lua dist$(LUCI_I18NDIR)/ 2>/dev/null || true; \ cp $(HOST)/lua-po/$$file.$(if $(PO_LANG),$(PO_LANG),*).* dist$(LUCI_I18NDIR)/ 2>/dev/null || true; \
done done
endif endif

View file

@ -9,3 +9,5 @@
x(self, schemedir or SYSROOT .. "/lib/uci/schema") x(self, schemedir or SYSROOT .. "/lib/uci/schema")
end end
local sys = require "luci.sys"
sys.user.checkpasswd = function() return true end

View file

@ -1,62 +0,0 @@
#
# Copyright (C) 2008 OpenWrt.org
#
# This is free software, licensed under the GNU General Public License v2.
# See /LICENSE for more information.
#
# $Id$
include $(TOPDIR)/rules.mk
PKG_NAME:=axtls
PKG_VERSION:=1.2.0
PKG_RELEASE:=2
PKG_BUILD_DIR=$(BUILD_DIR)/axTLS
PKG_SOURCE:=axTLS-$(PKG_VERSION).tar.gz
PKG_SOURCE_URL:=@SF/axtls
PKG_MD5SUM:=af805c76c0da1dbfc0c5e6b8dbd6706a
include $(INCLUDE_DIR)/package.mk
# set to 1 to enable debugging
DEBUG=
define Package/libaxtls
SECTION:=libs
CATEGORY:=Libraries
TITLE:=axTLS embedded SSL library
endef
define Package/axhttpd
SUBMENU:=Web
SECTION:=net
CATEGORY:=Network
DEPENDS:=+libaxtls
TITLE:=axTLS embedded http/https server
endef
define Build/Configure
$(INSTALL_DIR) $(PKG_BUILD_DIR)/config
$(CP) ./files/axtls-config $(PKG_BUILD_DIR)/config/.config
$(CP) ./files/axtls-config.h $(PKG_BUILD_DIR)/config/config.h
endef
TARGET_CFLAGS += $(FPIC)
#define Build/Compile
# $(MAKE) -C $(PKG_BUILD_DIR)
#endef
define Package/libaxtls/install
$(INSTALL_DIR) $(1)/usr/lib
$(CP) $(PKG_BUILD_DIR)/_stage/libaxtls.so* $(1)/usr/lib/
endef
define Package/axhttpd/install
$(INSTALL_DIR) $(1)/usr/sbin
$(INSTALL_BIN) $(PKG_BUILD_DIR)/_stage/axhttpd $(1)/usr/sbin/
endef
$(eval $(call BuildPackage,libaxtls))
$(eval $(call BuildPackage,axhttpd))

View file

@ -1,116 +0,0 @@
#
# Automatically generated make config: don't edit
#
HAVE_DOT_CONFIG=y
CONFIG_PLATFORM_LINUX=y
# CONFIG_PLATFORM_CYGWIN is not set
# CONFIG_PLATFORM_WIN32 is not set
#
# General Configuration
#
PREFIX="/usr/local"
# CONFIG_DEBUG is not set
# CONFIG_STRIP_UNWANTED_SECTIONS is not set
# CONFIG_VISUAL_STUDIO_7_0 is not set
# CONFIG_VISUAL_STUDIO_8_0 is not set
CONFIG_VISUAL_STUDIO_7_0_BASE=""
CONFIG_VISUAL_STUDIO_8_0_BASE=""
CONFIG_EXTRA_CFLAGS_OPTIONS="-fPIC"
CONFIG_EXTRA_LDFLAGS_OPTIONS="-lc -lm"
#
# SSL Library
#
# CONFIG_SSL_SERVER_ONLY is not set
# CONFIG_SSL_CERT_VERIFICATION is not set
# CONFIG_SSL_ENABLE_CLIENT is not set
# CONFIG_SSL_FULL_MODE is not set
CONFIG_SSL_SKELETON_MODE=y
# CONFIG_SSL_PROT_LOW is not set
# CONFIG_SSL_PROT_MEDIUM is not set
# CONFIG_SSL_PROT_HIGH is not set
# CONFIG_SSL_USE_DEFAULT_KEY is not set
CONFIG_SSL_PRIVATE_KEY_LOCATION=""
CONFIG_SSL_PRIVATE_KEY_PASSWORD=""
CONFIG_SSL_X509_CERT_LOCATION=""
# CONFIG_SSL_GENERATE_X509_CERT is not set
CONFIG_SSL_X509_COMMON_NAME=""
CONFIG_SSL_X509_ORGANIZATION_NAME=""
CONFIG_SSL_X509_ORGANIZATION_UNIT_NAME=""
CONFIG_SSL_ENABLE_V23_HANDSHAKE=y
# CONFIG_SSL_HAS_PEM is not set
# CONFIG_SSL_USE_PKCS12 is not set
CONFIG_SSL_EXPIRY_TIME=0
CONFIG_X509_MAX_CA_CERTS=0
CONFIG_SSL_MAX_CERTS=2
# CONFIG_SSL_CTX_MUTEXING is not set
CONFIG_USE_DEV_URANDOM=y
# CONFIG_WIN32_USE_CRYPTO_LIB is not set
# CONFIG_OPENSSL_COMPATIBLE is not set
# CONFIG_PERFORMANCE_TESTING is not set
# CONFIG_SSL_TEST is not set
CONFIG_AXHTTPD=y
#
# Axhttpd Configuration
#
# CONFIG_HTTP_STATIC_BUILD is not set
CONFIG_HTTP_PORT=80
CONFIG_HTTP_HTTPS_PORT=443
CONFIG_HTTP_SESSION_CACHE_SIZE=5
CONFIG_HTTP_WEBROOT="/www"
CONFIG_HTTP_TIMEOUT=300
#
# CGI
#
CONFIG_HTTP_HAS_CGI=y
CONFIG_HTTP_CGI_EXTENSIONS="luci"
# CONFIG_HTTP_ENABLE_LUA is not set
CONFIG_HTTP_LUA_PREFIX=""
CONFIG_HTTP_LUA_CGI_LAUNCHER=""
# CONFIG_HTTP_BUILD_LUA is not set
CONFIG_HTTP_DIRECTORIES=y
# CONFIG_HTTP_HAS_AUTHORIZATION is not set
# CONFIG_HTTP_HAS_IPV6 is not set
# CONFIG_HTTP_ENABLE_DIFFERENT_USER is not set
CONFIG_HTTP_USER=""
# CONFIG_HTTP_VERBOSE is not set
CONFIG_HTTP_IS_DAEMON=y
#
# Language Bindings
#
# CONFIG_BINDINGS is not set
# CONFIG_CSHARP_BINDINGS is not set
# CONFIG_VBNET_BINDINGS is not set
CONFIG_DOT_NET_FRAMEWORK_BASE=""
# CONFIG_JAVA_BINDINGS is not set
CONFIG_JAVA_HOME=""
# CONFIG_PERL_BINDINGS is not set
CONFIG_PERL_CORE=""
CONFIG_PERL_LIB=""
# CONFIG_LUA_BINDINGS is not set
CONFIG_LUA_CORE=""
#
# Samples
#
# CONFIG_SAMPLES is not set
# CONFIG_C_SAMPLES is not set
# CONFIG_CSHARP_SAMPLES is not set
# CONFIG_VBNET_SAMPLES is not set
# CONFIG_JAVA_SAMPLES is not set
# CONFIG_PERL_SAMPLES is not set
# CONFIG_LUA_SAMPLES is not set
# CONFIG_BIGINT_CLASSICAL is not set
# CONFIG_BIGINT_MONTGOMERY is not set
# CONFIG_BIGINT_BARRETT is not set
# CONFIG_BIGINT_CRT is not set
# CONFIG_BIGINT_KARATSUBA is not set
MUL_KARATSUBA_THRESH=0
SQU_KARATSUBA_THRESH=0
# CONFIG_BIGINT_SLIDING_WINDOW is not set
# CONFIG_BIGINT_SQUARE is not set
# CONFIG_BIGINT_CHECK_ON is not set

View file

@ -1,117 +0,0 @@
/*
* Automatically generated header file: don't edit
*/
#define HAVE_DOT_CONFIG 1
#define CONFIG_PLATFORM_LINUX 1
#undef CONFIG_PLATFORM_CYGWIN
#undef CONFIG_PLATFORM_WIN32
/*
* General Configuration
*/
#define PREFIX "/usr/local"
#undef CONFIG_DEBUG
#undef CONFIG_STRIP_UNWANTED_SECTIONS
#undef CONFIG_VISUAL_STUDIO_7_0
#undef CONFIG_VISUAL_STUDIO_8_0
#define CONFIG_VISUAL_STUDIO_7_0_BASE ""
#define CONFIG_VISUAL_STUDIO_8_0_BASE ""
#define CONFIG_EXTRA_CFLAGS_OPTIONS "-fPIC"
#define CONFIG_EXTRA_LDFLAGS_OPTIONS "-lc -lm"
/*
* SSL Library
*/
#undef CONFIG_SSL_SERVER_ONLY
#undef CONFIG_SSL_CERT_VERIFICATION
#undef CONFIG_SSL_ENABLE_CLIENT
#undef CONFIG_SSL_FULL_MODE
#define CONFIG_SSL_SKELETON_MODE 1
#undef CONFIG_SSL_PROT_LOW
#undef CONFIG_SSL_PROT_MEDIUM
#undef CONFIG_SSL_PROT_HIGH
#undef CONFIG_SSL_USE_DEFAULT_KEY
#define CONFIG_SSL_PRIVATE_KEY_LOCATION ""
#define CONFIG_SSL_PRIVATE_KEY_PASSWORD ""
#define CONFIG_SSL_X509_CERT_LOCATION ""
#undef CONFIG_SSL_GENERATE_X509_CERT
#define CONFIG_SSL_X509_COMMON_NAME ""
#define CONFIG_SSL_X509_ORGANIZATION_NAME ""
#define CONFIG_SSL_X509_ORGANIZATION_UNIT_NAME ""
#define CONFIG_SSL_ENABLE_V23_HANDSHAKE 1
#undef CONFIG_SSL_HAS_PEM
#undef CONFIG_SSL_USE_PKCS12
#define CONFIG_SSL_EXPIRY_TIME
#define CONFIG_X509_MAX_CA_CERTS
#define CONFIG_SSL_MAX_CERTS 2
#undef CONFIG_SSL_CTX_MUTEXING
#define CONFIG_USE_DEV_URANDOM 1
#undef CONFIG_WIN32_USE_CRYPTO_LIB
#undef CONFIG_OPENSSL_COMPATIBLE
#undef CONFIG_PERFORMANCE_TESTING
#undef CONFIG_SSL_TEST
#define CONFIG_AXHTTPD 1
/*
* Axhttpd Configuration
*/
#undef CONFIG_HTTP_STATIC_BUILD
#define CONFIG_HTTP_PORT 80
#define CONFIG_HTTP_HTTPS_PORT 443
#define CONFIG_HTTP_SESSION_CACHE_SIZE 5
#define CONFIG_HTTP_WEBROOT "/www"
#define CONFIG_HTTP_TIMEOUT 300
/*
* CGI
*/
#define CONFIG_HTTP_HAS_CGI 1
#define CONFIG_HTTP_CGI_EXTENSIONS "luci"
#undef CONFIG_HTTP_ENABLE_LUA
#define CONFIG_HTTP_LUA_PREFIX ""
#define CONFIG_HTTP_LUA_CGI_LAUNCHER ""
#undef CONFIG_HTTP_BUILD_LUA
#define CONFIG_HTTP_DIRECTORIES 1
#undef CONFIG_HTTP_HAS_AUTHORIZATION
#undef CONFIG_HTTP_HAS_IPV6
#undef CONFIG_HTTP_ENABLE_DIFFERENT_USER
#define CONFIG_HTTP_USER ""
#undef CONFIG_HTTP_VERBOSE
#define CONFIG_HTTP_IS_DAEMON 1
/*
* Language Bindings
*/
#undef CONFIG_BINDINGS
#undef CONFIG_CSHARP_BINDINGS
#undef CONFIG_VBNET_BINDINGS
#define CONFIG_DOT_NET_FRAMEWORK_BASE ""
#undef CONFIG_JAVA_BINDINGS
#define CONFIG_JAVA_HOME ""
#undef CONFIG_PERL_BINDINGS
#define CONFIG_PERL_CORE ""
#define CONFIG_PERL_LIB ""
#undef CONFIG_LUA_BINDINGS
#define CONFIG_LUA_CORE ""
/*
* Samples
*/
#undef CONFIG_SAMPLES
#undef CONFIG_C_SAMPLES
#undef CONFIG_CSHARP_SAMPLES
#undef CONFIG_VBNET_SAMPLES
#undef CONFIG_JAVA_SAMPLES
#undef CONFIG_PERL_SAMPLES
#undef CONFIG_LUA_SAMPLES
#undef CONFIG_BIGINT_CLASSICAL
#undef CONFIG_BIGINT_MONTGOMERY
#undef CONFIG_BIGINT_BARRETT
#undef CONFIG_BIGINT_CRT
#undef CONFIG_BIGINT_KARATSUBA
#define MUL_KARATSUBA_THRESH
#define SQU_KARATSUBA_THRESH
#undef CONFIG_BIGINT_SLIDING_WINDOW
#undef CONFIG_BIGINT_SQUARE
#undef CONFIG_BIGINT_CHECK_ON

View file

@ -1,12 +0,0 @@
diff -urb axTLS.orig/ssl/Makefile axTLS/ssl/Makefile
--- axTLS.orig/ssl/Makefile 2008-11-09 00:58:43.000000000 +0000
+++ axTLS/ssl/Makefile 2008-11-09 00:58:57.000000000 +0000
@@ -96,7 +96,7 @@
$(TARGET2) : $(OBJ)
ifndef CONFIG_PLATFORM_CYGWIN
- $(LD) $(LDFLAGS) $(LDSHARED) -Wl,-soname,$(LIBMAJOR) -o $(AXTLS_HOME)/$(STAGE)/$(LIBMINOR) $(CRYPTO_OBJ) $(OBJ)
+ $(LD) $(LDFLAGS) $(LDSHARED) -o $(AXTLS_HOME)/$(STAGE)/$(LIBMINOR) $(CRYPTO_OBJ) $(OBJ)
cd $(AXTLS_HOME)/$(STAGE); ln -sf $(LIBMINOR) $(LIBMAJOR); ln -sf $(LIBMAJOR) $(BASETARGET); cd -
else
$(LD) $(LDFLAGS) $(LDSHARED) -o $(AXTLS_HOME)/$(STAGE)/cygaxtls.dll \

View file

@ -1,12 +0,0 @@
diff -urb axTLS.orig/httpd/Makefile axTLS/httpd/Makefile
--- axTLS.orig/httpd/Makefile 2008-11-09 00:58:44.000000000 +0000
+++ axTLS/httpd/Makefile 2008-11-09 01:29:55.000000000 +0000
@@ -95,7 +95,7 @@
ifndef CONFIG_PLATFORM_WIN32
$(TARGET): $(OBJ) $(AXTLS_HOME)/$(STAGE)/libaxtls.a
- $(LD) $(LDFLAGS) -o $@ $(OBJ) $(LIBS)
+ $(CC) $(LDFLAGS) -o $@ $(OBJ) $(LIBS)
ifdef CONFIG_STRIP_UNWANTED_SECTIONS
strip --remove-section=.comment $(TARGET)
endif

View file

@ -1,37 +0,0 @@
diff -urb axTLS.orig/httpd/axhttp.h axTLS/httpd/axhttp.h
--- axTLS.orig/httpd/axhttp.h 2008-11-09 00:58:44.000000000 +0000
+++ axTLS/httpd/axhttp.h 2008-11-09 02:33:44.000000000 +0000
@@ -91,6 +91,7 @@
uint8_t is_lua;
#endif
int content_length;
+ char content_type[MAXREQUESTLENGTH];
char remote_addr[MAXREQUESTLENGTH];
char uri_request[MAXREQUESTLENGTH];
char uri_path_info[MAXREQUESTLENGTH];
diff -urb axTLS.orig/httpd/proc.c axTLS/httpd/proc.c
--- axTLS.orig/httpd/proc.c 2008-11-09 00:58:44.000000000 +0000
+++ axTLS/httpd/proc.c 2008-11-09 02:43:32.000000000 +0000
@@ -129,6 +129,10 @@
my_strncpy(cn->server_name, value, MAXREQUESTLENGTH);
}
+ else if (strcmp(buf, "Content-Type:") == 0 )
+ {
+ my_strncpy(cn->content_type, value, MAXREQUESTLENGTH);
+ }
else if (strcmp(buf, "Connection:") == 0 && strcmp(value, "close") == 0)
{
cn->close_when_done = 1;
@@ -673,8 +677,9 @@
type = "POST";
sprintf(cgienv[cgi_index++],
"CONTENT_LENGTH=%d", cn->content_length);
- strcpy(cgienv[cgi_index++], /* hard-code? */
- "CONTENT_TYPE=application/x-www-form-urlencoded");
+ snprintf(cgienv[cgi_index++], MAXREQUESTLENGTH,
+ "CONTENT_TYPE=%s", cn->content_type);
+
break;
}

View file

@ -1,20 +0,0 @@
--- axTLS/httpd/proc.c 2008-11-13 14:05:02.000000000 +0100
+++ axTLS.new/httpd/proc.c 2008-11-13 16:07:12.000000000 +0100
@@ -556,13 +556,13 @@
int tmp_stdout;
#endif
- snprintf(cgienv[0], MAXREQUESTLENGTH,
+ if (cn->reqtype == TYPE_HEAD)
+ {
+ snprintf(cgienv[0], MAXREQUESTLENGTH,
HTTP_VERSION" 200 OK\nServer: %s\n%s",
server_version, (cn->reqtype == TYPE_HEAD) ? "\n" : "");
- special_write(cn, cgienv[0], strlen(cgienv[0]));
+ special_write(cn, cgienv[0], strlen(cgienv[0]));
- if (cn->reqtype == TYPE_HEAD)
- {
removeconnection(cn);
return;
}

View file

@ -1 +0,0 @@
bitlib-*

View file

@ -1,36 +0,0 @@
include ../../build/config.mk
include ../../build/gccconfig.mk
BITLIB_VERSION = 25
BITLIB_SITE = http://dev.luci.freifunk-halle.net/sources/
BITLIB_DIR = bitlib-$(BITLIB_VERSION)
BITLIB_FILE = $(BITLIB_DIR).tar.gz
BITLIB_URL = $(BITLIB_SITE)/$(BITLIB_FILE)
all: compile
include ../../build/module.mk
$(BITLIB_FILE):
wget -O $@ $(BITLIB_URL) || rm -f $@
$(BITLIB_DIR)/.prepared: $(BITLIB_FILE)
rm -rf $(BITLIB_DIR)
tar xvfz $(BITLIB_FILE)
test -f $(BITLIB_DIR)/config.h || cp $(BITLIB_DIR)/config.h.in $(BITLIB_DIR)/config.h
touch $@
compile: $(BITLIB_DIR)/.prepared dist$(LUA_LIBRARYDIR)/bit.so
dist$(LUA_LIBRARYDIR)/bit.so:
mkdir -p dist$(LUA_LIBRARYDIR)
$(COMPILE) -DHAVE_CONFIG_H -I$(BITLIB_DIR) -O2 -c $(BITLIB_DIR)/lbitlib.c $(FPIC) $(LUA_CFLAGS) -o $(BITLIB_DIR)/lbitlib.o
$(LINK) $(SHLIB_FLAGS) $(LDFLAGS) $(BITLIB_DIR)/lbitlib.o $(LUA_SHLIBS) -lm -ldl -o dist$(LUA_LIBRARYDIR)/bit.so
luasource:
luastrip:
luacompile:
compile-all: compile
clean:
rm -rf $(BITLIB_DIR) $(BITLIB_FILE)

View file

@ -5,6 +5,7 @@ LDFLAGS :=
OBJ = cli.o lar.o md5.o OBJ = cli.o lar.o md5.o
BIN = lar BIN = lar
compile:
cli: $(OBJ) cli: $(OBJ)
$(GCC) $(CFLAGS) -o $(BIN) $(OBJ) $(LDFLAGS) $(GCC) $(CFLAGS) -o $(BIN) $(OBJ) $(LDFLAGS)

View file

@ -14,7 +14,7 @@
local assert, getfenv, ipairs, loadstring, pairs, setfenv, tostring, tonumber, type = assert, getfenv, ipairs, loadstring, pairs, setfenv, tostring, tonumber, type local assert, getfenv, ipairs, loadstring, pairs, setfenv, tostring, tonumber, type = assert, getfenv, ipairs, loadstring, pairs, setfenv, tostring, tonumber, type
local io = require"io" local io = require"io"
local posix = require "posix" local posix = require "nixio.fs"
local lp = require "luadoc.lp" local lp = require "luadoc.lp"
local luadoc = require"luadoc" local luadoc = require"luadoc"
local package = package local package = package

View file

@ -4,7 +4,7 @@
local assert, pairs, tostring, type = assert, pairs, tostring, type local assert, pairs, tostring, type = assert, pairs, tostring, type
local io = require "io" local io = require "io"
local posix = require "posix" local posix = require "nixio.fs"
local luadoc = require "luadoc" local luadoc = require "luadoc"
local util = require "luadoc.util" local util = require "luadoc.util"
local tags = require "luadoc.taglet.standard.tags" local tags = require "luadoc.taglet.standard.tags"
@ -505,14 +505,14 @@ end
-- @return table with documentation -- @return table with documentation
function directory (path, doc) function directory (path, doc)
for f in posix.files(path) do for f in posix.dir(path) do
local fullpath = path .. "/" .. f local fullpath = path .. "/" .. f
local attr = posix.stat(fullpath) local attr = posix.stat(fullpath)
assert(attr, string.format("error stating file `%s'", fullpath)) assert(attr, string.format("error stating file `%s'", fullpath))
if attr.type == "regular" then if attr.type == "reg" then
doc = file(fullpath, doc) doc = file(fullpath, doc)
elseif attr.type == "directory" and f ~= "." and f ~= ".." then elseif attr.type == "dir" and f ~= "." and f ~= ".." then
doc = directory(fullpath, doc) doc = directory(fullpath, doc)
end end
end end
@ -550,9 +550,9 @@ function start (files, doc)
local attr = posix.stat(path) local attr = posix.stat(path)
assert(attr, string.format("error stating path `%s'", path)) assert(attr, string.format("error stating path `%s'", path))
if attr.type == "regular" then if attr.type == "reg" then
doc = file(path, doc) doc = file(path, doc)
elseif attr.type == "directory" then elseif attr.type == "dir" then
doc = directory(path, doc) doc = directory(path, doc)
end end
end) end)

View file

@ -3,7 +3,7 @@
-- @release $Id: util.lua,v 1.16 2008/02/17 06:42:51 jasonsantos Exp $ -- @release $Id: util.lua,v 1.16 2008/02/17 06:42:51 jasonsantos Exp $
------------------------------------------------------------------------------- -------------------------------------------------------------------------------
local posix = require "posix" local posix = require "nixio.fs"
local type, table, string, io, assert, tostring, setmetatable, pcall = type, table, string, io, assert, tostring, setmetatable, pcall local type, table, string, io, assert, tostring, setmetatable, pcall = type, table, string, io, assert, tostring, setmetatable, pcall
------------------------------------------------------------------------------- -------------------------------------------------------------------------------

View file

@ -1,3 +0,0 @@
luaposix-*
lua-posix_*
patches/series

View file

@ -1,35 +0,0 @@
include ../../build/config.mk
include ../../build/gccconfig.mk
LUAPOSIX_VERSION = 5.1.4
LUAPOSIX_SITE = http://dev.luci.freifunk-halle.net/sources/
LUAPOSIX_DIR = luaposix-$(LUAPOSIX_VERSION)
LUAPOSIX_FILE = lua-posix_5.1.4.orig.tar.gz
LUAPOSIX_URL = $(LUAPOSIX_SITE)/$(LUAPOSIX_FILE)
LUAPOSIX_PATCHDIR = patches
all: compile
include ../../build/module.mk
$(LUAPOSIX_FILE):
wget -O $@ $(LUAPOSIX_URL) || rm -f $@
$(LUAPOSIX_DIR)/.prepared: $(LUAPOSIX_FILE)
rm -rf $(LUAPOSIX_DIR)
tar xvfz $(LUAPOSIX_FILE)
touch $@
compile: $(LUAPOSIX_DIR)/.prepared
$(MAKE) -C $(LUAPOSIX_DIR) CC=$(CC) CFLAGS="$(CFLAGS) $(LUA_CFLAGS)" LDFLAGS="$(LDFLAGS) $(LUA_SHLIBS)" OS="$(OS)"
mkdir -p dist$(LUA_LIBRARYDIR)
cp $(LUAPOSIX_DIR)/posix.so dist$(LUA_LIBRARYDIR)
luasource:
luastrip:
luacompile:
compile-all: compile
clean:
rm -rf $(LUAPOSIX_DIR) $(LUAPOSIX_FILE)
rm -f $(LUAPOSIX_PATCHDIR)/series

File diff suppressed because it is too large Load diff

View file

@ -1,4 +0,0 @@
## startup options for /etc/init.d/asterisk
ENABLE_ASTERISK="uci"
OPTIONS=""

View file

@ -1,127 +0,0 @@
#!/bin/sh /etc/rc.common
# Copyright (C) 2006 OpenWrt.org
START=50
STOP=50
DEST=
OPTIONS=""
DEFAULT=$DEST/etc/default/asterisk
UCILIB=$DEST/usr/lib/asterisk/uci
EXTRAPARAM=$1
export EXTRA_COMMANDS="console check down"
export EXTRA_HELP="\
console Start asterisk console
check Test asterisk uci config
down Force asterisk to stop"
reboot_ata() {
cd /tmp
wget -q http://ata.lan/admin/reboot -O - >&- 2>&-
}
load_ucilib() . ${UCILIB}/asteriskuci
start_uci() {
load_ucilib
start_uci_asterisk $DEST
}
restart_uci() {
load_ucilib
restart_uci_asterisk $DEST
}
stop_uci() {
load_ucilib
stop_uci_asterisk $DEST
}
reload_uci() {
load_ucilib
reload_uci_asterisk "$DEST"
}
start() {
[ -f $DEFAULT ] && . $DEFAULT
case ${ENABLE_ASTERISK-no} in
uci) start_uci ;;
yes)
# Handle zappseudo in the wrong place.
[ -e /dev/zappseudo ] && [ ! -d /dev/zap -o ! -e /dev/zap/pseudo ] && mkdir -p /dev/zap && ln -s /dev/zappseudo /dev/zap/pseudo
[ -d /var/run ] || mkdir -p /var/run
[ -d $DEST/var/log/asterisk ] || mkdir -p $DEST/var/log/asterisk
[ -d $DEST/var/spool/asterisk ] || mkdir -p $DEST/var/spool/asterisk
[ -d /var/spool/asterisk ] || mkdir -p /var/spool/asterisk
[ -h $DEST/usr/lib/asterisk/astdb ] || ln -sf /var/spool/asterisk/astdb $DEST/usr/lib/asterisk/astdb
$DEST/usr/sbin/asterisk $OPTIONS -f 2>&1 > $DEST/var/log/asterisk/asterisk_proc &
( sleep 5; reboot_ata ) &
;;
*) return 1 ;;
esac
}
stop() {
[ -f $DEFAULT ] && . $DEFAULT
case ${ENABLE_ASTERISK} in
uci) stop_uci ;;
*) [ -f /var/run/asterisk.pid ] && kill $(cat /var/run/asterisk.pid) 2>&- >&-
esac
}
console() {
[ -f $DEFAULT ] && . $DEFAULT
case ${ENABLE_ASTERISK} in
uci) $DEST/usr/sbin/asterisk $UCIOPTIONS -C /tmp/asterisk/asterisk.conf -r ;;
yes) $DEST/usr/sbin/asterisk $OPTIONS -r ;;
esac
}
check() {
load_ucilib
setup_asterisk "$DEST" test "$EXTRAPARAM"
}
reload() {
[ -f $DEFAULT ] && . $DEFAULT
case ${ENABLE_ASTERISK-no} in
uci) reload_uci ;;
yes) restart ;;
esac
}
restart() {
[ -f $DEFAULT ] && . $DEFAULT
case ${ENABLE_ASTERISK-no} in
uci) restart_uci ;;
yes)
if [ -r /var/run/asterisk.ctl ] ; then
if $DEST/usr/sbin/asterisk -r -x "restart gracefully" 2>&- >&- ; then
echo "Restarting when convenient"
return 0
fi
fi
stop
start
esac
}
down() {
if [ -r /var/run/asterisk.ctl ] ; then
[ -f $DEFAULT ] && . $DEFAULT
case ${ENABLE_ASTERISK} in
uci) $DEST/usr/sbin/asterisk -C /tmp/asterisk/asterisk.conf -r -x "stop now" 2>&- >&- ;;
*) $DEST/usr/sbin/asterisk $OPTIONS -r -x "stop now" 2>&- >&-
esac
[ -f /var/run/asterisk.pid ] && sleep 1
fi
[ -f /var/run/asterisk.pid ] && kill $(cat /var/run/asterisk.pid) 2>&- >&-
[ -f /var/run/asterisk.pid ] && sleep 2
[ -f /var/run/asterisk.pid ] && kill -9 $(cat /var/run/asterisk.pid) 2>&- >&-
}
# vim:ts=2 sw=2

View file

@ -1,23 +0,0 @@
; Talking clock by Michael Geddes
; Borrowed from bits here and there.
[macro-talkingclock] ; (TimeFormat, DateFormat, Zone)
exten => s,1,Answer
exten => s,n,set(tcTimeFormat=${ARG1})
exten => s,n,GotoIf($["${tcTimeFormat}" = ""]?:tfOK)
exten => s,n,set(tcTimeFormat=HM\'vm-and\'S\'seconds\')
exten => s,n(tfOK),set(tcDateFormat=${ARG2})
exten => s,n,GotoIf($["${tcDateFormat}" = ""]?:dfOK)
exten => s,n,set(tcDateFormat=AdBY)
exten => s,n(dfOK),set(tcZone=${ARG3})
exten => s,n,GotoIf($["${tcZone}" = ""]?:znOK)
exten => s,n,set(tcZone=${TalkingClockZone})
exten => s,n(znOK),SayUnixTime(,${tcZone},${tcDateFormat})
exten => s,n(again),Wait(2)
exten => s,n,Set(FutureTime=$[${EPOCH} + 6])
exten => s,n,Playback(misc/at-tone-time-exactly)
exten => s,n,SayUnixTime(${FutureTime},${tcZone},${tcTimeFormat})
; Wait to say the beep.
exten => s,n(waitforit),noop
exten => s,n,GotoIf($[ ${EPOCH} < ${FutureTime} ]?waitforit:)
exten => s,n,playback(beep)
exten => s,n,goto(again)

View file

@ -1,88 +0,0 @@
; Last-Called number storage and calling.
; Author: Michael Geddes aka FrogOnWheels
; depends: app_macro app_system app_record func_callerid
; app_sayunixtime app_playback func_db
; format_gsm codec_gsm
;[globals]
;LASTCALL_DIR=/etc/asterisk/directory
[macro-lastcallstore] ; (Number , EntryType, BufferSize)
exten => s,1,set(lcsName=lastcall)
exten => s,n,set(lcsCount=10)
exten => s,n,GotoIf($["${ARG2}" = ""]?blankarg)
exten => s,n,GotoIf($["${ARG2}" = "lastcall"]?blankarg)
exten => s,n,Set(lcsName=lastcall_${ARG2})
exten => s,n(blankarg),GotoIf($["${ARG3}" = ""]?nocount)
exten => s,n,Set(lcsCount=${ARG3})
exten => s,n(nocount),Noop(${lcsName}:${DB(${lcsName}/number1)}:${ARG1})
exten => s,n,GotoIf($["${DB(${lcsName}/number1)}" = "${ARG1}"]?setdate)
exten => s,n,set(CallerPointer=1)
exten => s,n(again),GotoIf($["${DB(${lcsName}/ddate${CallerPointer})}" = ""]?copynext)
exten => s,n,GotoIf($["${DB(${lcsName}/number${CallerPointer})}" = "${ARG1}"]?copynext)
exten => s,n,Set(CallerPointer=$[${CallerPointer}+1])
exten => s,n,GotoIf($[${CallerPointer} <= ${lcsCount}]?again)
exten => s,n(copynext),set(DB(${lcsName}/ddate$[${CallerPointer}])=${DB(${lcsName}/ddate$[${CallerPointer}-1])})
exten => s,n,set(DB(${lcsName}/number$[${CallerPointer}])=${DB(${lcsName}/number$[${CallerPointer}-1])})
exten => s,n,set(CallerPointer=$[${CallerPointer}-1])
exten => s,n,GotoIf($[${CallerPointer} > 0]?copynext)
exten => s,n,set(DB(${lcsName}/number1)=${ARG1})
exten => s,n(setdate),set(DB(${lcsName}/ddate1)=${EPOCH})
[macro-lastcallapp] ; (Entrytype, Count, RingContext, Tag)
exten => s,1,set(lcsName=lastcall)
exten => s,n,set(lcsCount=10)
exten => s,n,GotoIf($["${ARG1}" = ""]?blankName)
exten => s,n,Set(lcsName=lastcall_${ARG1})
exten => s,n(blankName),GotoIf($["${ARG2}" = ""]?nocount)
exten => s,n,Set(lcsCount=${ARG2})
exten => s,n(nocount),set(lcsCallContext=internal)
exten => s,n,GotoIf($["${ARG3}" = ""]?blankContext)
exten => s,n,Set(lcsCallContext=${ARG3})
exten => s,n(blankContext),set(lcsTag=${ARG4})
exten => s,n,GotoIf($["${lcsTag}" != ""]?hasTag)
exten => s,n,Set(lcsTag=lastcall/previous-numbers)
exten => s,n(hasTag),Set(lcsPointer=1)
exten => s,n,GotoIf($["${DB(${lcsName}/ddate1)}" != ""]?macrobody_lastcallapp|s|1)
exten => s,n,playback(${lcsTag}&lastcall/none-available)
[macrobody_lastcallapp]
exten => s,1(repeat),Background(${lcsTag})
exten => s,n(again),wait(1)
exten => s,n,Set(lcsLastnum=${DB(${lcsName}/number${lcsPointer})})
exten => s,n,Set(ddate=${DB(${lcsName}/ddate${lcsPointer})})
exten => s,n,Set(lcsLastDate=${DB(${lcsName}/ddate$[ ${lcsPointer} + 1])})
exten => s,n,GotoIf($["${lcsLastnum}" != "anonymous"]?checkblank)
exten => s,n,Set(lcsLastnum="")
exten => s,n(checkblank),GotoIf($["${lcsLastnum}" = ""]?noinfo)
exten => s,n,Macro(backgroundtagnumber,${lcsLastnum},${LASTCALL_DIR})
exten => s,n,wait(.5)
exten => s,n,sayunixtime(${ddate},${LASTCALLZONE},QIMp)
exten => s,n(saymenu),background(silence/1)
exten => s,n,GotoIf($[$[${lcsPointer} = ${lcsCount}] | $["${lcsLastDate}" = ""]]?noprev)
exten => s,n,background(lastcall/next)
exten => s,n(noprev),GotoIf($["${lcsLastnum}" = ""]?nocall)
exten => s,n,background(lastcall/call-number)
exten => s,n,background(lastcall/tag-number)
exten => s,n(nocall),GotoIf($[${lcsPointer} = 1]?nonext)
exten => s,n,background(lastcall/previous)
exten => s,n(nonext),background(silence/10)
exten => s,n,Goto(repeat)
exten => s,n(noinfo),background(lastcall/no-number-info)
exten => s,n,goto(saycalltime)
exten => 5,1,GotoIf($["${lcsLastnum}" = ""]?noinfo])
exten => 5,n,Ringing()
exten => 5,n,Goto(${lcsCallContext},${lcsLastnum},1)
exten => 6,1,GotoIf($[$[${lcsPointer} = ${lcsCount}] | $["${lcsLastDate}" = ""]]?sayn)
exten => 6,n,Set(lcsPointer=$[${lcsPointer} + 1])
exten => 4,1,GotoIf($[${lcsPointer}=1]?sayn)
exten => 4,n,Set(lcsPointer=$[${lcsPointer} - 1])
exten => _[46],n(sayn),Background(h-${lcsPointer})
exten => _[46],n,goto(s|again)
exten => 7,1,GotoIf($["${lcsLastNum}" = ""]?noinfo])
exten => 7,2,macro(tagnumber,${lcsLastNum},${LASTCALL_DIR})
exten => 7,3,goto(s|again)
exten => i,1,Goto(s|again)
exten => t,1,playback(goodbye)
exten => t,n,Hangup

View file

@ -1,58 +0,0 @@
; Number tagging
; Author: Michael Geddes aka FrogOnWheels
; Depends: app_stack app_macro app_system
[macro-tagnumber] ; Number / Tag Directory / Return
exten => s,1,Set(tagNumber=${ARG1})
exten => s,n,Set(tagDirectory=${ARG2})
exten => s,n,Set(tagRetContext=${MACRO_CONTEXT})
exten => s,n,Set(tagRetExtn=${MACRO_EXTEN})
exten => s,n,Set(tagRetPriority=$[${MACRO_PRIORITY} + 1])
;exten => s,n,Set(tagReturn=${ARG3})
;exten => s,n,Gosub(macrobody_tagnumber,s,1)
exten => s,n,Goto(macrobody_tagnumber,s,1)
exten => s,n(return),Noop(Returned)
[macrobody_tagnumber]
exten => s,1(again),Background(voicetag/recordname)
exten => s,n,Record(/tmp/tmprectag:gsm|2|5)
exten => s,n(askagain),Background(voicetag/tagfor)
exten => s,n,Macro(backgroundphone,${tagNumber})
exten => s,n,Background(/tmp/tmprectag)
exten => s,n,Background(voicetag/confirmnumber)
exten => s,n,Background(voicetag/tryagain)
exten => s,n,Background(voicetag/cancelrecord)
exten => s,n,WaitExten(5)
exten => s,n,Goto(s|askagain)
exten => 1,1,System(mkdir -p ${tagDirectory})
exten => 1,2,System(mv /tmp/tmprectag.gsm ${tagDirectory}/${tagNumber}.gsm)
exten => 1,3,Goto(${tagRetContext}|${tagRetExtn}|${tagRetPriority})
exten => 2,1,Goto(s|again)
exten => 3,1,system(rm -f /tmp/tmprectag.gsm)
exten => 3,2,Goto(${tagRetContext}|${tagRetExtn}|${tagRetPriority})
exten => h,1,system(rm -f /tmp/tmrectag.gsm)
[macro-backgroundtagnumber] ; Number, directory
exten => s,1,TrySystem(test -f ${ARG2}/${ARG1}.gsm)
exten => s,n,GotoIf($[${SYSTEMSTATUS} != SUCCESS]?s-saynum|1)
exten => s,n,Background(${ARG2}/${ARG1})
exten => s-saynum,1,Macro(backgroundphone,${ARG1})
; Say Phone number in the background
[macro-backgroundphone]
exten => s,1,Set(bgDigits=${ARG1})
exten => s,n(loop),Set(bgDigit=${bgDigits:0:1})
exten => s,n,GotoIf($["${bgDigits:0:3}" = "000"]?saythousand)
exten => s,n,GotoIf($["${bgDigits:0:2}" = "00"]?sayhundred)
exten => s,n,GotoIf($["${bgDigits}" = ""]?exitloop)
exten => s,n,Set(bgDigits=${bgDigits:1})
exten => s,n,Background(digits/${bgDigit})
exten => s,n,Goto(loop)
exten => s,n(saythousand),Background(digits/thousand)
exten => s,n,Set(bgDigits=${bgDigits:3})
exten => s,n,Goto(loop)
exten => s,n(sayhundred),Background(digits/hundred)
exten => s,n,Set(bgDigits=${bgDigits:2})
exten => s,n,Goto(loop)
exten => s,n(exitloop),NOOP

View file

@ -1,137 +0,0 @@
;
; Asterisk configuration file
;
; Module Loader configuration file
;
[modules]
autoload=yes
;
; Any modules that need to be loaded before the Asterisk core has been
; initialized (just after the logger has been initialized) can be loaded
; using 'preload'. This will frequently be needed if you wish to map all
; module configuration files into Realtime storage, since the Realtime
; driver will need to be loaded before the modules using those configuration
; files are initialized.
;
; An example of loading ODBC support would be:
;preload => res_odbc.so
;preload => res_config_odbc.so
;
noload => res_config_mysql.so ;
noload => res_crypto.so ; Cryptographic Digital Signatures
; load => res_features.so ; Call Parking Resource
noload => res_indications.so ; Indications Configuration
noload => res_monitor.so ; Call Monitoring Resource
; load => res_musiconhold.so ; Music On Hold Resource
noload => cdr_csv.so ; Comma Separated Values CDR Backend
noload => cdr_custom.so ; Customizable Comma Separated Values CDR Backend
noload => cdr_manager.so ; Asterisk Call Manager CDR Backend
noload => cdr_mysql.so ; MySQL CDR Backend
noload => cdr_pgsql.so ; PostgreSQL CDR Backend
noload => cdr_sqlite.so ; SQLite CDR Backend
noload => chan_alsa.so ; Channel driver for GTalk
noload => chan_agent.so ; Agent Proxy Channel
noload => chan_gtalk.so ; Channel driver for GTalk
; load => chan_iax2.so ; Inter Asterisk eXchange (Ver 2)
; load => chan_local.so ; Local Proxy Channel
; load => chan_sip.so ; Session Initiation Protocol (SIP)
noload => codec_a_mu.so ; A-law and Mulaw direct Coder/Decoder
noload => codec_adpcm.so ; Adaptive Differential PCM Coder/Decoder
noload => codec_alaw.so ; A-law Coder/Decoder
noload => codec_g726.so ; ITU G.726-32kbps G726 Transcoder
; load => codec_gsm.so ; GSM/PCM16 (signed linear) Codec Translation
; load => codec_ulaw.so ; Mu-law Coder/Decoder
noload => codec_speex.so ; Speex/PCM16 (signed linear) Codec Translator
noload => format_au.so ; Sun Microsystems AU format (signed linear)
noload => format_g723.so ; G.723.1 Simple Timestamp File Format
noload => format_g726.so ; Raw G.726 (16/24/32/40kbps) data
noload => format_g729.so ; Raw G729 data
; load => format_gsm.so ; Raw GSM data
noload => format_h263.so ; Raw h263 data
noload => format_jpeg.so ; JPEG (Joint Picture Experts Group) Image
; load => format_pcm.so ; Raw uLaw 8khz Audio support (PCM)
noload => format_pcm_alaw.so ; Raw aLaw 8khz PCM Audio support
noload => format_sln.so ; Raw Signed Linear Audio support (SLN)
noload => format_vox.so ; Dialogic VOX (ADPCM) File Format
; load => format_wav.so ; Microsoft WAV format (8000hz Signed Line
; load => format_wav_gsm.so ; Microsoft WAV format (Proprietary GSM)
noload => app_alarmreceiver.so ; Alarm Receiver Application
noload => app_authenticate.so ; Authentication Application
noload => app_cdr.so ; Make sure asterisk doesn't save CDR
noload => app_chanisavail.so ; Check if channel is available
noload => app_chanspy.so ; Listen in on any channel
noload => app_controlplayback.so ; Control Playback Application
noload => app_cut.so ; Cuts up variables
noload => app_db.so ; Database access functions
; load => app_dial.so ; Dialing Application
noload => app_dictate.so ; Virtual Dictation Machine Application
noload => app_directory.so ; Extension Directory
noload => app_directed_pickup.so ; Directed Call Pickup Support
noload => app_disa.so ; DISA (Direct Inward System Access) Application
noload => app_dumpchan.so ; Dump channel variables Application
; load => app_echo.so ; Simple Echo Application
noload => app_enumlookup.so ; ENUM Lookup
noload => app_eval.so ; Reevaluates strings
noload => app_exec.so ; Executes applications
noload => app_externalivr.so ; External IVR application interface
noload => app_forkcdr.so ; Fork The CDR into 2 seperate entities
noload => app_getcpeid.so ; Get ADSI CPE ID
noload => app_groupcount.so ; Group Management Routines
noload => app_ices.so ; Encode and Stream via icecast and ices
noload => app_image.so ; Image Transmission Application
noload => app_lookupblacklist.so ; Look up Caller*ID name/number from black
noload => app_lookupcidname.so ; Look up CallerID Name from local databas
; load => app_macro.so ; Extension Macros
noload => app_math.so ; A simple math Application
noload => app_md5.so ; MD5 checksum Application
; load => app_milliwatt.so ; Digital Milliwatt (mu-law) Test Application
noload => app_mixmonitor.so ; Record a call and mix the audio during the recording
noload => app_parkandannounce.so ; Call Parking and Announce Application
; load => app_playback.so ; Trivial Playback Application
noload => app_privacy.so ; Require phone number to be entered
noload => app_queue.so ; True Call Queueing
noload => app_random.so ; Random goto
noload => app_read.so ; Read Variable Application
noload => app_readfile.so ; Read in a file
noload => app_realtime.so ; Realtime Data Lookup/Rewrite
noload => app_record.so ; Trivial Record Application
; load => app_sayunixtime.so ; Say time
noload => app_senddtmf.so ; Send DTMF digits Application
noload => app_sendtext.so ; Send Text Applications
noload => app_setcallerid.so ; Set CallerID Application
noload => app_setcdruserfield.so ; CDR user field apps
noload => app_setcidname.so ; Set CallerID Name
noload => app_setcidnum.so ; Set CallerID Number
noload => app_setrdnis.so ; Set RDNIS Number
noload => app_settransfercapability.so ; Set ISDN Transfer Capability
noload => app_sms.so ; SMS/PSTN handler
noload => app_softhangup.so ; Hangs up the requested channel
noload => app_stack.so ; Stack Routines
noload => app_system.so ; Generic System() application
noload => app_talkdetect.so ; Playback with Talk Detection
noload => app_test.so ; Interface Test Application
noload => app_transfer.so ; Transfer
noload => app_txtcidname.so ; TXTCIDName
noload => app_url.so ; Send URL Applications
noload => app_userevent.so ; Custom User Event Application
; load => app_verbose.so ; Send verbose output
noload => app_waitforring.so ; Waits until first ring after time
noload => app_waitforsilence.so ; Wait For Silence Application
noload => app_while.so ; While Loops and Conditional Execution
noload => func_callerid.so ; Caller ID related dialplan functions
noload => func_enum.so ; ENUM Functions
noload => func_uri.so ; URI encoding / decoding functions
noload => pbx_ael.so ; Asterisk Extension Language Compiler
; load => pbx_config.so ; Text Extension Configuration
noload => pbx_functions.so ; Builtin dialplan functions
noload => pbx_loopback.so ; Loopback Switch
noload => pbx_realtime.so ; Realtime Switch
noload => pbx_spool.so ; Outgoing Spool Support
noload => pbx_wilcalu.so ; Wil Cal U (Auto Dialer)
;
; Module names listed in "global" section will have symbols globally
; exported to modules loaded after them.
;
[global]
chan_modem.so=no

View file

@ -1,144 +0,0 @@
#!/bin/sh
# Asterisk.conf
init_asteriskconf() {
ast_add_reload dialplan
ast_enable_type asterisk
ast_enable_type setglobal
ast_enable_type include
# ast_enable_type hardware
ast_enable_type hardwarereboot
asterisk_zone="Australia/Perth"
asterisk_spooldir="${DEST}/var/spool/asterisk"
asterisk_logdir="${DEST}/var/log/asterisk"
asterisk_agidir="${DEST}/usr/lib/asterisk/agi-bin"
return 0
}
asterisk_option_list="verbose debug quiet dontwarn timestamp execincludes \
highpriority initcrypto nocolor dumpcore languageprefix internal_timing \
systemname maxcalls maxload cache_record_files record_cache_dir \
transmit_silence_during_record transcode_via_sln runuser rungroup"
asterisk_path_list="spooldir logdir agidir"
valid_asterisk_option() {
is_in_list $1 ${asterisk_option_list} ${asterisk_path_list} zone
return $?
}
create_asteriskconf() {
# echo ${DEST_DIR}
file=${DEST_DIR}/asterisk.conf
get_checksum asterisk_conf $file
echo "${asteriskuci_gen}${N}[directories]
astetcdir => ${DEST_DIR}
astmoddir => ${DEST}/usr/lib/asterisk/modules
astvarlibdir => ${DEST}/usr/lib/asterisk
astdatadir => ${DEST}/usr/lib/asterisk
astrundir => /var/run" > $file
for i in ${asterisk_path_list} ; do
eval "value=\"\${asterisk_$i}\""
if [ ! -z $value ] ; then
echo "ast$i => $value" >> $file
fi
done
echo "${N}[options]" >> $file
for i in ${asterisk_option_list} ; do
eval "value=\"\${asterisk_$i}\""
if [ ! -z $value ] ; then
echo "$i => $value" >> $file
fi
done
echo "${N}; Changing the following lines may compromise your security.
[files]
astctlpermissions = 0660
astctlowner = root
astctlgroup = nogroup
astctl = asterisk.ctl " >> $file
check_checksum "$asterisk_conf" "$file" || ast_restart=1
}
handle_asterisk() {
option_cb() {
case $1 in
zone)
asterisk_zone="$2";;
*)
if valid_asterisk_option $1 $2 ; then
eval "asterisk_${1}=\"$2\""
else
logerror "Invalid Asterisk option: $1"
fi
esac
}
}
handle_include(){
option_cb() {
case $1 in
dialplan|dialplan_ITEM*)
append dialplan_includes "#include <$2>" "${N}"
;;
dialplan_COUNT) ;;
*) logerror "Invalid option \"$1\" for include" ;;
esac
}
}
handle_setglobal() {
option_cb() {
case $1 in
set_COUNT) ;;
set|set_ITEM*)
if [ "${2%=*}" == "${2}" ] ; then
logerror "SetGlobal option \"$2\" not of the form VARIABLE=Value"
else
append dialplan_globals "" "${N}"
fi ;;
*) logerror "Invalid option \"$1\" for setglobal" ;;
esac
}
}
handle_hardwarereboot() handle_hardware reboot
# Handle hardware options (reboot) for Softphones
handle_hardware() {
case $1 in
reboot)
hardware_method=
hardware_param=
option_cb() {
case $1 in
method)
hardware_method="$2";;
param)
case ${hardware_method} in
web) append hardware_reboots "wget -q $2 -O - >&- 2>&-" "${N}" ;;
system) append hardware_reboots "$2 >&- 2>&-" "${N}" ;;
*) logerror "Invalid Hardware reboot method: ${hardware_method}"
esac
esac
}
;;
*) logerror "Invalid Hardware option: $1"
esac
}
reboot_hardware() {
cd /tmp
eval ${hardware_reboots}
}
# vim: ts=2 sw=2 noet foldmethod=indent

View file

@ -1,41 +0,0 @@
asterisk
zone - Default TimeZone
Various asterisk.conf options
verbose
debug
quiet
dontwarn
timestamp
execincludes
highpriority
initcrypto
nocolor
dumpcore
languageprefix
internal_timing
systemname
maxcalls
maxload
cache_record_files
record_cache_dir
transmit_silence_during_record
transcode_via_sln
runuser
rungroup
spooldir
logdir
agidir
setglobal
set (list) - VARIABLE=Value Global Variables
include
dialplan (list) - Files to #include
hardwarereboot - Reboot phone hardware
method - web (wget), system
param - url/program for reboot

View file

@ -1,377 +0,0 @@
#!/bin/sh
# Author: Michael Geddes <michael at frog dot wheelycreek dot net>
# Copyright 2008 Michael Geddes
# Licensed under GPL
Version=0.8
# Todo
# Calling of Macros in dialplan
# Create a Menu
# Incoming Zones
debuglevel=0
. /etc/functions.sh
asteriskuci_gen="; Generated by Openwrt AstriskUCI script version ${Version}$N"
# Utils
logerror() {
echo "Error: $1"
}
logdebug() {
if [ $(expr $1 "<=" ${debuglevel-0}) == 1 ] ; then
echo "Log: $2"
fi
}
is_in_list(){
val=$1
shift
for i in $* ; do
[ $i == $val ] && return 0
done
return 1
}
split_append() { # {list} {prefix} {item} {func call}
local lhs="$2"
local rhs="$3"
while [ ! -z "$rhs" ] ; do
cur=${rhs%%,*}
nvar=${rhs#*,}
[ -z "$5" ] || eval "$5 ${cur}"
append $1 "${lhs}${cur}" "$4"
[ "$nvar" == "$rhs" ] && break
rhs=${nvar}
done
}
get_checksum() {
if [ -r "$2" ] ; then
local sum=`md5sum $2 | cut -d " " -f 1`
eval "$1=\"$sum\""
else
eval "$1=NONE"
fi
#eval "logdebug 1 \"Checksum $2 : \${$1}\""
}
check_checksum() {
if [ -r "$2" ] ; then
local sum=`md5sum $2 | cut -d " " -f 1`
else
eval sum=NONE
fi
#logdebug 1 "Compare $1 checksum $2 with new checksum $sum "
[ "$sum" == "$1" ]
return $?
}
# Add config module to initialise list
ast_add_conf() append asterisk_conf_list $1 " "
# Add module to initialise list
ast_add_module() {
append asterisk_module_list $1 " "
eval "createdialplan_$1() return 0"
}
# Add to 'reload' list.
ast_add_reload() append asterisk_load_list $1 " "
# Enable a top-level type
ast_enable_type() eval "enabled_section_${1}=1"
# Is a top-level type enabled?
ast_type_enabled() {
eval "local res=\${enabled_section_${1}}"
if [ "$res" != 1 ] ; then
return 1 #Fail
fi
return 0
}
# For use in sections - make sure that the last section is processed
check_add() {
logdebug 1 "Check add $1"
if [ ! -z "${last_added_checked}" ] ; then
logdebug 1 "Eval check-add ${last_added_checked}"
eval "check_add_${last_added_checked}"
fi
last_added_checked=$1
}
# Process the section yet to be checked.
check_all_added() check_add ""
# Create static links for stuff we dont want to configure yet.
create_staticlinks() {
logdebug 1 "Link in a few mostly static configurations"
linkconfigs="codecs.conf say.conf sip_notify.conf udptl.conf logger.conf"
module_enabled res_indications && append linkconfigs indications.conf " "
for i in ${linkconfigs} ; do
[ -e $DEST_DIR/$i ] || ln -s $DEST/etc/asterisk/$i $DEST_DIR
done
logdebug 1 "Link in #include directories"
for i in include inc libs lib library macro macros ; do
if [ -e $DEST/etc/asterisk/$i -a ! -d "$DEST_DIR/$i" -a ! -e "$DEST_DIR/$i" ] ; then
ln -s $DEST/etc/asterisk/$i $DEST_DIR
fi
done
}
# default reboot
reboot_hardware() {}
# Top level handler
setup_asterisk() {
DEST=${1%/}
DEST_DIR=/tmp/asterisk
testing_mode=0
if [ "$2" == "testonly" ] ; then
testing_mode=1
elif [ "$2" == "test" ] ; then
DEST_DIR=/tmp/asterisk.tmp
echo Using Test dir: $DEST_DIR
testing_mode=2
fi
[ -z "$3" ] || debuglevel=$3
logdebug 1 "Loading Asterisk Config"
. ${UCILIB}/asteriskconf
logdebug 2 "Loading Module Config"
. ${UCILIB}/moduleconf
logdebug 2 "Loading Dialplan Config"
. ${UCILIB}/dialplanconf
for f in ${DEST}/etc/asterisk/conf.d/* ; do
logdebug 1 "Loading Module $f"
[ -f $f ] && . $f
done
include /lib/network
scan_interfaces
init_asteriskconf
init_moduleconf
init_dialplanconf
for i in ${asterisk_module_list} ; do
logdebug 1 "Init $i module"
eval "init_${i}"
done
for i in ${asterisk_conf_list} ; do
logdebug 1 "Init $i config"
eval "init_${i}conf"
done
config_cb() {
cur_section=$1/$2
logdebug 2 "Load $1/$2"
eval "local val=\"\${dups_$2}\""
if [ "${val}" == "" ] ; then
eval "dups_$2=1"
else
logerror "Duplicate Section Name: $2 (type $1)"
fi
if ast_type_enabled $1 ; then
eval "handle_$1 \$2"
elif [ ! -z "$1" ] ; then
logerror "Unknown section: $1/$2"
option_cb() {
logerror "Invalid option '$1' for invalid section"
}
fi
}
config_load asterisk
check_all_added
if [ "$testing_mode" != "1" ] ; then
mkdir -p ${DEST_DIR}
create_asteriskconf
for i in ${asterisk_conf_list} ; do
logdebug 1 "Create $i config"
eval "create_${i}conf"
done
for i in ${asterisk_module_list} ; do
logdebug 1 "Create Dialplan for module $i"
eval "createdialplan_${i}"
done
create_dialplanconf
create_moduleconf
# Link in a few mostly static configurations
create_staticlinks
fi
[ "$testing_mode" == "2" ] && reload_check_asterisk
return 0
}
astcmd() {
ASTCMD="${DEST%/}/usr/sbin/asterisk -C /tmp/asterisk/asterisk.conf "
logdebug 1 "Command: $1"
if [ -z "${2-}" ] ; then
${ASTCMD} -r -x "$1" 2>&- 1>&-
else
eval "$2=`${ASTCMD} -r -x \"$1\"`"
fi
return $?
}
# waitfor() {
# while [ -d /proc/$1 ] ; do
# sleep 1
# done
# }
restart_gracefully() {
stop_uci_asterisk "$DEST"
startup_asterisk "$DEST"
#ret=0
#echo "Check for pid"
#if [ -r /var/run/asterisk.ctl ] ; then
# astcmd "stop gracefully"
# local ret=$?
# [ ${ret} = 0 ] || return $ret
# waitfor `cat /var/run/asterisk.pid`
#fi
#startup_asterisk ${DEST}
return 0
}
astcmds() {
while [ ! -z "$1" ] ; do
astcmd "$1"
shift
done
}
reload_check_asterisk() {
logdebug 1 "Check Reloading"
local reboot=0
if [ "${ast_restart-}" == 1 ] ; then
logdebug 1 "Restarting Gracefully"
reboot=0
else
for i in ${asterisk_load_list} ; do
logdebug 1 "Checking ${i} reload"
eval "local doload=\${ast_${i}_restart}"
case $doload in
1) logdebug 1 "Reloading ${i}" ;;
2) logdebug 1 "Unloading ${i}" ;;
esac
done
fi
[ ${reboot} = 1 ] && logdebug 1 "reboot hardware"
}
reload_asterisk() {
logdebug 1 "Reloading"
local reboot=0
if [ "${ast_restart-}" == 1 ] ; then
logdebug 2 "Restarting Gracefully"
restart_gracefully
reboot=0
else
for i in ${asterisk_load_list} ; do
logdebug 3 "Checking ${i} reload"
eval "local doload=\${ast_${i}_restart}"
case $doload in
1) logdebug 1 "Reloading ${i}"
eval "reload_${i}" || reboot=1 ;;
2) logdebug 1 "Unloading ${i}"
eval "unload_${i}" || reboot=1 ;;
esac
done
fi
if [ ${reboot} = 1 ] ; then
( sleep 5; reboot_hardware ) &
fi
}
startup_asterisk() {
DEST="${1%/}"
DEFAULT=$DEST/etc/default/asterisk
[ -f $DEFAULT ] && . $DEFAULT
[ -d /var/run ] || mkdir -p /var/run
[ -d ${asterisk_logdir} ] || mkdir -p ${asterisk_logdir}
[ -d ${asterisk_spooldir} ] || mkdir -p ${asterisk_spooldir}
[ -d /var/spool/asterisk ] || mkdir -p /var/spool/asterisk
[ -h $DEST/usr/lib/asterisk/astdb ] || ln -sf /var/spool/asterisk/astdb $DEST/usr/lib/asterisk/astdb
[ -e /dev/zappseudo ] && [ ! -d /dev/zap -o ! -e /dev/zap/pseudo ] && mkdir -p /dev/zap && ln -s /dev/zappseudo /dev/zap/pseudo
$DEST/usr/sbin/asterisk -C /tmp/asterisk/asterisk.conf $UCIOPTIONS -f 2>&1 > ${asterisk_logdir}/asterisk_proc &
# Wait a bit then reboot the hardware
( sleep 5; reboot_hardware ) &
}
# Init.d start() handler
start_uci_asterisk() {
DEST="${1%/}"
if setup_asterisk $DEST ; then
startup_asterisk "$DEST"
fi
}
restart_uci_asterisk() {
DEST="${1%/}"
if setup_asterisk $DEST ; then
echo "Trying to Restart gracefully"
if [ -r /var/run/asterisk.ctl ] ; then
# if astcmd "restart gracefully" ; then
echo "Sending restart"
if restart_gracefully ; then
echo "Restarting gracefully"
return 0
fi
fi
stop_uci_asterisk "$DEST"
startup_asterisk "$DEST"
else
stop_uci_asterisk $1
echo "Setup Failed"
return 1
fi
}
# init.d stop() handler
stop_uci_asterisk() {
DEST=${1%/}
if [ -r /var/run/asterisk.ctl ] ; then
astcmd "stop now"
sleep 1
fi
[ -f /var/run/asterisk.pid ] && kill $(cat /var/run/asterisk.pid) >/dev/null 2>&1
}
reload_uci_asterisk() {
DEST=${1%/}
DEFAULT=$DEST/etc/default/asterisk
if [ -r /var/run/asterisk.ctl ] ; then
[ -e /dev/zappseudo ] && [ ! -d /dev/zap -o ! -e /dev/zap/pseudo ] && mkdir -p /dev/zap && ln -s /dev/zappseudo /dev/zap/pseudo
if setup_asterisk "$DEST" ; then
# Selective reload modules.
reload_asterisk
fi
else
start_uci_asterisk "$1"
fi
}
# vim: ts=2 sw=2 noet foldmethod=indent

View file

@ -1,855 +0,0 @@
#!/bin/sh
# Dialplans (extensions.conf)
# Implicit: ast_add_conf dialplan
init_dialplanconf() {
ast_enable_type dialplangeneral
ast_enable_type dialplan
ast_enable_type dialplanexten
ast_enable_type dialplangoto
ast_enable_type dialplansaytime
ast_enable_type dialzone
ast_enable_type inzone
ast_enable_type incominggeneral
ast_enable_type incoming
dialplan_allowtransfer=no
dialplan_dialtimeout=30
dialplan_answerfirst=no
dialplan_static=yes
dialplan_writeprotect=no
dialplan_canreinvite=no
dialplan_includes=
dialplan_globals=
return 0
}
match_all="_[0-9*+#]."
match_all_s="_[0-9*+#s]."
dialplangeneral_list="static writeprotect canreinvite clearglobalvars"
dialplangeneral_list_ex="lastdialed lastdialedtype voiceboxext answerfirst dialtimeout allowtransfer international internationalout"
valid_dialplangeneral() {
for i in ${dialplangeneral_list} ${dialplangeneral_list_ex} ; do
[ "$i" == "$1" ] && return 0
done
return 1
}
check_add_context() {
local context="${1}"
local check="${context#macro-}"
[ "${context}" == ${check} ] || check="macro__${check}"
eval "local isadded=\"\${dialplan_add_context_${check}-0}\""
if [ "$isadded" != "1" ] ; then
eval "dialplan_add_context_${check}=1"
append dialplan_contexts "$context"
return 0
else
return 1
fi
}
append_dialplan_context() {
local context="${1}"
local check="${context#macro-}"
[ "${context}" == ${check} ] || check="macro__${check}"
append dialplan_context_${check} "${2}" "${N}"
}
reload_dialplan() astcmd "dialplan reload"
add_dialplan_exten() {
local context=$1
logdebug 3 "Exten: $2"
local ext="exten => $2,"
local planopt=
local timeout=${dialplan_dialtimeout}
# Answer extensions first.
local answerfirst=${dialplan_answerfirst}
local mailbox=$4
[ -z "$5" ] || timeout=$5
[ -z "$6" ] || answerfirst=$6
check_add_context "$context"
if [ "$dialplan_allowtransfer" == "yes" ] ; then
planopt=${planopt}t
fi
if [ ! -z "${planopt}" ] ; then
planopt=",${timeout},${planopt}"
elif [ ! -z "${timeout}" ] ; then
planopt=",${timeout}"
fi
local dial="Dial($3$planopt)"
local item="1,"
if [ "$answerfirst" == "yes" ] ; then
append_dialplan_context ${context} "${ext}1,Answer"
item="n,"
fi
append_dialplan_context ${context} "${ext}${item}${dial}"
if [ ! -z "${mailbox}" ] ; then
enable_voicemail
append_dialplan_context ${context} "${ext}n,VoiceMail(${mailbox})"
fi
append_dialplan_context ${context} "${ext}n,Congestion"
}
add_dialplan_include() {
local context=$1
logdebug 1 "Adding Dialplan Include $1 $2"
check_add_context "$context"
split_append dialplan_context_${context} "include => " "$2" "${N}"
}
add_dialplan_saytime() {
local context=$1
logdebug 1 "Adding Dialplan saytime $1 $2"
check_add_context "$context"
local ext="exten => $2,"
if [ "$dialplan_add_context_saytime" != 1 ] ; then
append dialplan_contexts saytime " "
dialplan_add_context_saytime=1
enable_format gsm
enable_module app_sayunixtime
local zone=${asterisk_zone}
[ ! -z "$3" ] && zone="$3"
local format="IMp AdbY"
[ ! -z "$4" ] && format="$4"
append dialplan_context_saytime "exten => s,1,SayUnixTime(,${zone},${format})" "${N}"
fi
append_dialplan_context ${context} "${ext}1,Goto(saytime,s,1)"
}
add_dialplan_goto() {
local context=$1
logdebug 1 "Adding Dialplan goto $1 $2 $3"
check_add_context "$context"
append dialplan_context_${context} "exten => $2,1,Goto($3,\${EXTEN},1)" "${N}"
}
dialplan_inzone_list="match caller goto"
valid_dialplan_inzone() {
is_in_list $1 ${valid_inzone_list}
return $?
}
check_append_inzone() {
local context="${1}"
eval "local isadded=\"\${dialplan_add_inzone_${context}-0}\""
if [ "$isadded" != "1" ] ; then
eval "dialplan_add_inzone_${check}=1"
append inzone_contexts "$context"
return 0
else
return 1
fi
}
handle_inzone() {
context_name=${1}
check_append_inzone ${context_name}
option_cb(){
case $1 in
goto) eval "inzone_${context_name}_goto=\"\$2\"" ;;
match_ITEM*|match) append inzone_${context_name}_match "$2" " " ;;
caller_ITEM*|caller) append inzone_${context_name}_caller "$2" " " ;;
include_ITEM*|include) append inzone_${context_name}_include "$2" " " ;;
match_LENGTH|caller_LENGTH|include_LENGTH) ;;
_*) ;;
*) logerror "Invalid Dialplan inzone option: $1" ;;
esac
}
}
append_dialplan_inzone() {
local file=$1
for context in ${inzone_contexts} ; do
for i in goto match caller include ; do
eval "iz_$i=\"\${inzone_${context}_${i}}\""
done
if [ -z "${iz_goto}" ] ; then
logerror "Missing goto for inzone: ${context}"
elif [ -z "${iz_match}" -a -z "${iz_caller}" ] ; then
logerror "Missing match for inzone: ${context}"
else
echo "${N}[${context}]" >> ${file}
for curmatch in ${iz_include} ; do
echo "include => ${curmatch}" >> $file
done
local gotoline="Goto(${iz_goto},\${EXTEN},1)"
[ -z "${iz_match}" ] && iz_match=${match_all}
for curmatch in ${iz_match} ; do
if [ -z "${iz_caller}" ] ; then
echo "exten => ${curmatch},1,${gotoline}" >> $file
else
for curcaller in ${iz_caller} ; do
echo "exten => ${curmatch}/${curcaller},1,${gotoline}" >> $file
done
fi
done
fi
done
}
append_dialplan_dialzone() {
local file=$1
# Add the dialzone contexts
logdebug 1 "Dialplan: Add the dialzone contexts"
for zonename in ${dzones_match} ; do
eval "local diallist=\${dzone_${zonename}_match-}"
echo "${N}[${zonename}]" >> $file
eval "dialz=\${dzone_match_use_${zonename}-}"
logdebug 3 "Find international options for zone ${zonename} from ${dialz}"
for v in prefix internationalprefix alwaysinternational countrycode ; do
eval "local $v=\${target_${v}_${dialz}:-}"
eval logdebug 3 "\"${v} = '\${$v}'\""
done
for v in localzone addprefix localprefix; do
eval "local $v=\${dzone_${zonename}_${v}:-}"
done
while [ ! -z "$diallist" ] ; do
cur=${diallist%%,*}
nvar=${diallist#*,}
if [ "${alwaysinternational}" = "yes" ] ; then
# Always dial international number with this target
# remove 'localprefix' (usually 0) from 'addprefix'
logdebug 3 "Removing ${localprefix} from ${addprefix}"
addprefix=${addprefix#$localprefix}
local curlen=`expr length "${localprefix}"`
if [ $curlen != 0 ] ; then
# remove 0 (or local prefix)
echo "exten => _${localprefix}${cur},1,Goto(${dialz}_dial,${countrycode}${addprefix}\${EXTEN:$curlen},1)" >> $file
fi
echo "exten => _${cur},1,Goto(${dialz}_dial,${countrycode}${addprefix}\${EXTEN},1)" >> $file
else
echo "exten => _${cur},1,Goto(${dialz}_dial,${addprefix}\${EXTEN},1)" >> $file
fi
[ "$nvar" == "$diallist" ] && break
diallist=${nvar}
done
eval "local diallist=\${dzone_${zonename}_international-}"
if [ ! -z "${diallist}" ] ; then
logdebug 2 "International: ${diallist}"
while [ ! -z "$diallist" ] ; do
cur="${diallist%%,*}"
nvar="${diallist#*,}"
logdebug 4 "Adding international ${cur}"
local curlen=`expr length "${cur}"`
if [ "$alwaysinternational" = "yes" ] ; then
echo "exten => _${cur},1,Goto(${dialz}_dial,${addprefix}\${EXTEN:${curlen}},1)" >> $file
else
echo "exten => _${cur}.,1,Goto(${zonename}_check,${addprefix}\${EXTEN:${curlen}},1)" >> $file
fi
[ "$nvar" == "$diallist" ] && break
diallist="${nvar}"
done
if [ "$alwaysinternational" != "yes" ] ; then
logdebug 2 "Not Always International:"
# Check for local country code
echo "[${zonename}_check]" >> $file
local locallen=`expr length "${countrycode}"`
echo "exten => _${countrycode}X.,1,Goto(${localzone-default},${localprefix-0}\${EXTEN:${locallen}},1)" >> $file
echo "exten => _X.,1,Goto(${dialz}_dial,${internationalprefix}\${EXTEN},1)" >> $file
fi
fi
done
logdebug 1 "Dialplan: Finish the dialzone contexts"
}
append_dialplan_dialzone_out(){
local file=$1
# Add the dialzone target contexts (dialing out)
logdebug 1 "Dialplan: Add the dialzone target contexts"
for contype in SIP IAX ; do
eval local conlist=\${dzones_${contype}-}
logdebug 1 "Adding ${contype} targets: ${conlist}"
for conname in $conlist ; do
echo "${N}[${contype}_${conname}_dial]" >> $file
for v in prefix internationalprefix alwaysinternational countrycode timeout lastdialed lastdialedtype ; do
eval "local $v=\${target_${v}_${contype}_${conname}:-}"
done
if [ -z "${lastdialed}" ] ; then
lastdialed=${dialplan_lastdialed}
lastdialedtype=${dialplan_lastdialedtype}
fi
# [ -z "${lastcallout}" ] && lastcallout=${feature_lastcall_outqueue}
# if [ ! -z "${lastcalloutexten}" ] ; then
# eval "local added=\${lastcallout_outqueue_extension_${lastcalloutexten}}"
# if [ ! "${added}" == 1 ] ; then
# add_dialplan_lastcall extensions "${lastcalloutexten}" "${lastcallout}" "${feature_lastcall_outcount}"
# eval "local lastcallout_outqueue_extension_${lastcalloutexten}=1"
# fi
# fi
local ext="exten => _X.,"
local en="1,"
# Do not use prefix unles 'alwaysinternational' is yes
[ "$alwaysinternational" != "yes" ] && internationalprefix=
# if [ ! -z "${lastcallout}" ] ; then # Add lastcall out
# enable_lastcall
# echo "${ext}${en}Macro(lastcallstore,${internationalprefix}\${EXTEN},${lastcallout},${feature_lastcall_outcount})" >> $file
# en="n,"
# fi
if [ ! -z "${lastdialed}" ] ; then
enable_module func_callerid
local lastparam="\${EXTEN}"
local lastmacro=${lastdialed}
local lastmacrotype=${lastdialedtype}
[ -z ${lastdialedtype} ] && lastdialedtype=macro
local jumpmacroline=
gen_jumpmacro jumpmacroline "${ext}${en}" "" "${lastmacrotype}" "${lastmacro}" "${lastparam}"
echo ${jumpmacroline} >> $file
en="n,"
fi
echo "${ext}${en}Dial(${contype}/${prefix}${internationalprefix}\${EXTEN}@${conname},$timeout)" >> $file
echo "exten => _X.,n,Congestion" >> $file
done
done
}
gen_jumpmacro() {
logdebug 3 "Gen JumpMacro /$1/=/$2/$3/$4/$5/$6/"
local leader=$2
local condition=$3
local macrotype=$4
local name=$5
local param=$6
if [ -z "${condition}" ] ; then
local cond="("
else
local cond="If(${condition}?"
fi
case ${macrotype} in
gosub)
enable_module app_stack # for gosub
logdebug 1 "${1}=\"\${leader}Gosub\${cond}\${name},\${param},1)\""
eval "${1}=\"\${leader}Gosub\${cond}\${name},\${param},1)\"" ;;
gosub_s)
enable_module app_stack # for gosub
logdebug 1 "${1}=\"\${leader}Gosub\${cond}\${name},s,1(\${param}))\""
eval "${1}=\"\${leader}Gosub\${cond}\${name},s,1(\${param}))\"" ;;
macro)
enable_module app_macro
logdebug 1 "${1}=\"\${leader}Macro\${cond}\${name},\${param})\""
eval "${1}=\"\${leader}Macro\${cond}\${name},\${param})\"" ;;
s|start)
enable_module app_goto
logdebug 1 "${1}=\"\${leader}Goto(\${iz_target},s,1)\""
eval "${1}=\"\${leader}Goto(\${iz_target},s,1)\"" ;;
*)
enable_module app_goto
logdebug 1 "${1}=\"\${leader}Goto\${cond}\${name},\${param},1)\""
eval "${1}=\"\${leader}Goto\${cond}\${name},\${param},1)\"" ;;
esac
}
append_jumpmacro(){
local context=$1
local jumpmacroline=""
gen_jumpmacro "jumpmacroline" "$2" "$3" "$4" "$5" "$6"
append_dialplan_context ${context} "${jumpmacroline}"
}
append_dialplan_incoming(){
local file=$1
# Evaluate the incoming ringing dialplans
logdebug 1 "Add the 'incoming' dialplans: ${dialplan_extensions_incoming}"
for context in ${dialplan_extensions_incoming} ; do
eval "local curext=\"\${dialplan_incoming_$context}\""
logdebug 2 "Adding incoming ${curext}"
check_add_context "$context"
# lastcall lastcallexten lastmissed lastmissedexten
for i in answerfirst beforeanswer timeout menucontext \
lastcall lastcalltype missed missedtype allowtransfer mailbox match matchcaller aftertimeout aftertimeouttype; do
eval "local iz_$i=\"\${incoming_${context}_$i}\""
eval "logdebug 1 \"Incoming \$context: iz_\$i=\${iz_$i}\""
done
[ ! -z ${iz_menucontext} ] && iz_answerfirst=yes
if [ ! -z ${curext} ] ; then
[ -z ${iz_answerfirst} ] && iz_answerfirst=${incoming_answerfirst}
# [ -z ${iz_lastcall} ] && iz_lastcall=${feature_lastcall_inqueue}
if [ -z ${iz_lastcall} ] ; then
iz_lastcall=${incoming_lastcall}
iz_lastcalltype=${incoming_lastcalltype}
fi
if [ -z ${iz_missed} ] ; then
iz_missed=${incoming_missed}
iz_missedtype=${incoming_missedtype}
fi
[ -z ${iz_mailbox} ] && iz_mailbox=${incoming_mailbox}
[ -z ${iz_timeout} ] && iz_timeout=${incoming_timeout}
[ -z ${iz_allowtransfer} ] && iz_allowtransfer=${incoming_allowtransfer}
fi
[ -z ${iz_match} ] && iz_match=_X.
[ ! -z ${iz_matchcaller} ] && iz_match=${iz_match}/${iz_matchcaller}
local ext="exten => ${iz_match},"
local planopt=
[ "${iz_allowtransfer}" == "yes" ] && planopt=${planopt}t
local item="1,"
#append_dialplan_context ${context} "${ext}${item}Ringing()"
if [ ! -z "${iz_lastcall}" ] ; then
enable_module func_callerid
local lastparam="\${CALLERID(num)}"
local lastmacrotype="${iz_lastcalltype}"
[ -z "${iz_lastcalltype}" ] && lastmacrotype=macro
local lastmacro=${iz_lastcall}
append_jumpmacro "${context}" "${ext}${item}" "" "${lastmacrotype}" "${lastmacro}" "${lastparam}"
item="n,"
fi
if [ ! -z "${iz_missed}" ] ; then
enable_module func_callerid
local missedparam="\${CALLERID(num)}"
[ -z "${iz_missedtype}" ] && iz_missedtype=macro
append_dialplan_context ${context} "${ext}${item}Set(lcsMissed=\${CALLERID(num)})"
item="n,"
fi
# Ring before answering
if [ ! -z "${iz_beforeanswer}" -a ! -z "${curext}" ] ; then
append_dialplan_context ${context} "${ext}${item}Dial(${curext},${iz_beforeanswer},${planopt})"
iz_answerfirst=yes
item="n,"
fi
# Now answer
if [ "$iz_answerfirst" == "yes" ] ; then
append_dialplan_context ${context} "${ext}${item}Answer"
item="n,"
fi
# if [ ! -z ${iz_lastcallexten} ] ; then
# enable_lastcall
# add_dialplan_lastcall extensions "${iz_lastcallexten}" "${iz_lastcall}" "${feature_lastcall_incount}"
# fi
if [ ! -z ${curext} ] ; then
if [ ! -z ${iz_menucontext} ] ; then
planopt=${planopt}rd
enable_module res_indications
# wait so the next ring connects.
append_dialplan_context ${context} "${ext}${item}Wait(1)"
append_dialplan_context ${context} "${ext}n,Set(EXITCONTEXT=${iz_menucontext})"
fi
if [ ! -z ${planopt} ] ; then
planopt=",${iz_timeout-},${planopt}"
elif [ ! -z ${iz_timeout-} ] ; then
planopt=",${iz_timeout-}"
fi
local dial="Dial(${curext}${planopt})"
append_dialplan_context ${context} "${ext}n,${dial})"
if [ ! -z ${iz_missed} ] ; then
# It went to voicemail or was hung up - consider missed
append_jumpmacro ${context} "${ext}${item}" "" "${iz_missedtype}" "${iz_missed}" "\${lcsMissed}"
fi
fi
local need_hangup=1
# Add a goto or macro at the end
if [ ! -z ${iz_target} ] ; then
case ${iz_aftertimeouttype} in
macro) append_dialplan_context ${context} "${ext}${item}Macro(${iz_target})";;
s|start) append_dialplan_context ${context} "${ext}${item}Goto(${iz_target},s,1)"
need_hangup=0;;
*) append_dialplan_context ${context} "${ext}${item}Goto(${iz_target},\${EXTEN},1)"
need_hangup=0;;
esac
fi
if [ ! -z ${iz_mailbox} ] ; then
enable_voicemail
append_dialplan_context ${context} "${ext}n,VoiceMail(${iz_mailbox})"
fi
[ "${need_hangup}" = "1" ] && append_dialplan_context ${context} "${ext}n,Hangup"
if [ ! -z ${iz_missed} ] ; then
# Check for missed call
append_jumpmacro ${context} "exten => h,1," "\$[\"\${DIALSTATUS}\" = \"CANCEL\"]" "${iz_missedtype}" "${iz_missed}" "\${lcsMissed}"
#append dialplan_context_${context} \
# "exten => h,1,MacroIf(\$[\"\${DIALSTATUS}\" = \"CANCEL\"]?lastcallstore,\${lcsMissed},${iz_lastmissed},${feature_lastcall_incount})" "${N}"
# [ ! -z ${iz_lastmissedexten} ] && \
# add_dialplan_lastcall extensions "${iz_lastmissedexten}" "${iz_lastmissed}" "${feature_lastcall_incount}"
fi
done
}
append_dialplan_extensions(){
local file=$1
# Evaluate the 'extension' dialplans
logdebug 1 "Add the 'extension' dialplans: ${dialplan_exts}"
for i in ${dialplan_exts} ; do
eval "local curext=\"\${dialplan_ext_$i}\""
add_dialplan_exten extensions $i $curext
done
}
append_include() {
append dialplan_includes "#include <$1>" "$N"
}
create_dialplanconf() {
# Add general section
logdebug 1 "Dialplan: Add general section"
local file=${DEST_DIR}/extensions.conf
get_checksum dialplan_conf $file
echo "${asteriskuci_gen}" > $file
[ -z "${dialplan_includes}" ] || (echo "${dialplan_includes}${N}" >> $file)
if [ ! -z "${dialplan_globals}" ] ; then
echo "[globals]${N}${dialplan_globals}${N}" >> $file
fi
echo "[general]" >> $file
for i in ${dialplangeneral_list} ; do
eval "local val=\"\$dialplan_$i\""
if [ ! -z "$val" ] ; then
echo "$i=$val" >> $file
fi
done
append_dialplan_dialzone "$file"
append_dialplan_dialzone_out "$file"
append_dialplan_park "$file"
append_dialplan_extensions "$file"
append_dialplan_inzone "$file"
append_dialplan_incoming "$file"
# append_dialplan_lastcall "$file"
# Add all the contexts
logdebug 1 "Dialplan: Add all the contexts"
for i in ${dialplan_contexts} ; do
echo "${N}[$i]" >> $file
[ "${i#macro-}" == "${i}" ] || i=macro__${i#macro-}
eval "local curcontext=\"\${dialplan_context_$i-}\""
echo "$curcontext">> $file
eval unset dialplan_context_$i
done
check_checksum "$dialplan_conf" "$file" || ast_dialplan_restart=1
return 0
}
handle_dialplangeneral() {
option_cb(){
if valid_dialplangeneral $1 $2 ; then
eval "dialplan_$1=\"$2\""
else
logerror "Invalid Dialplan General option: $1"
fi
}
}
handle_dialplan(){
context_name=$1
if [ -z ${context_name} ] ; then
logerror "Context name required for dialplan"
context_name=default
fi
option_cb() {
logdebug 4 "dialplan ${context_name}: '$1' '$2'"
case $1 in
include_LENGTH) ;;
include|include_ITEM*) add_dialplan_include ${context_name} $2 ;;
_*) ;;
*)
lhs=$1
logdebug 4 "Add extension $lhs"
if [ "$(expr $lhs : [0-9][0-9]\*)" != 0 ] ; then
addtype=${2%%:*}
if [ "${addtype}" == "$2" ]; then
addparam=
else
addparam=${2#*:}
fi
case ${addtype} in
mailbox|voice)
add_dialplan_voice ${context_name} $1 $addparam ;;
meetme|conf|conference) add_dialplan_meetme ${context_name} $1 $addparam ;;
saytime|time) add_dialplan_saytime ${context_name} $1 $addparam ;;
clock) add_dialplan_talkclock ${context_name} $1 $addparam ;;
*) logerror "Unknown type '${addtype}' in dialplan ${context_name}, extension ${1}"
esac
else
logerror "Invalid option: $1 for dialplan ${context_name}"
fi
esac
}
}
handle_dialplanexten() {
check_add dialplanexten
option_cb() {
case $1 in
dialplan|extension|type|target|dialextension|voicebox|timeout|answerfirst)
eval "dial_exten_$1=\"$2\""
esac
}
}
check_add_dialplanexten() {
if [ ! -z "${dial_exten_dialplan}" -a ! -z "${dial_exten_extension}" ] ; then
local dialext_type=
local dialext_ext=
if ! split_targettype dialext_type dialext_ext "${dial_exten_target}" ; then
if [ -z "${dial_exten_type}" ] ; then
logerror "No extension type specified for ${dial_exten_dialplan} ${dial_exten_extension}"
return 1
fi
dialext_type="${dial_exten_type}"
dialext_ext="${dial_exten_target}"
fi
local dialtarget="${dialext_type}/${dialexten_ext}${dial_exten_dialextension+/}${dial_exten_dialextension}"
check_add_context ${dial_exten_dialplan}
add_dialplan_exten "${dial_exten_dialplan}" "${dial_exten_extension}" \
"${dialtarget}" "${dial_exten_voicebox}" "${dial_exten_timeout}" \
"${dial_exten_answerfirst}"
fi
for i in dialplan extension voicebox type target dialextension timeout answerfirst ; do
eval "unset dial_voice_$i"
done
}
handle_dialplansaytime() {
check_add dialplansaytime
option_cb() {
case $1 in
dialplan|extension|zone|format)
eval "dial_saytime_$1=\"$2\""
esac
}
}
check_add_dialplansaytime() {
logdebug 1 "Add Saytime to $1 / $2"
if [ ! -z "${dial_saytime_dialplan}" -a ! -z "${dial_saytime_extension}" ] ; then
# local ext="exten => ${dial_saytime_extension},"
[ -z "${dial_saytime_dialplan}" ] && dial_saytime_dialplan=default
add_dialplan_saytime "${dial_saytime_dialplan}" "${dial_saytime_extension}" \
"${dial_saytime_zone}" "${dial_saytime_format}"
fi
for i in dialplan extension zone format; do
eval "unset dial_saytime_$i"
done
}
handle_dialzone_match() {
eval "local isadded=\"\${dzone_${zone_name}-0}\""
if [ "${isadded}" != "1" ] ; then
eval "dzone_${zone_name}=1"
append dzones_match ${zone_name} " "
fi
append dzone_${zone_name}_match $1 ","
}
# Set up outgoing zones (match patterns)
handle_dialzone() {
zone_name=$1
logdebug 2 "Loading dialzone: $zone_name"
option_cb(){
logdebug 2 "Dialzone $1/$2"
case $1 in
uses)
local areatype=
local areaname=
split_targettype areatype areaname "$2"
logdebug 3 "Added: $areatype $areaname"
eval "local isadded=\"\${dzone_${areatype}_${areaname}-0}\""
if [ "${isadded}" != "1" ] ; then
eval dzone_${areatype}_${areaname}=1
append dzones_${areatype} "${areaname}" " "
fi
eval "dzone_match_use_${zone_name}=${areatype}_${areaname}"
logdebug 3 "Finished uses"
;;
match_LENGTH) ;;
match|match_ITEM*)
handle_dialzone_match "$2"
;;
international_LENGTH) ;;
international|international_ITEM*)
eval "local isadded=\"$dzone_${zone_name}\""
if [ "${isadded}" != "1" ] ; then
eval "dzone_${zone_name}=1"
append dzones_match ${zone_name} " "
fi
append dzone_${zone_name}_international $2 ","
;;
countrycode|localzone|addprefix|localprefix)
eval "dzone_${zone_name}_${1}=\"$2\""
eval "y=\${dzone_${zone_name}_${1}}"
;;
*)
logerror "Invalid Dialzone option: $1 in zone '${zone_name}'" ;;
esac
}
}
check_add_dialplangoto() {
logdebug 1 "Add Goto to $1 / $2"
if [ ! -z "${dial_goto_dialplan}" -a ! -z "${dial_goto_extension}" ] ; then
local ext="exten => ${dial_goto_extension},"
check_add_context ${dial_goto_dialplan}
append_dialplan_context ${dial_goto_dialplan} "${ext}1,Goto(${dial_goto_target})"
fi
for i in dialplan extension room ; do
eval "unset dial_goto_$i"
done
}
handle_dialplangoto(){
check_add dialplangoto
option_cb() {
case $1 in
dialplan|extension|target)
eval "dial_goto_$1=\"$2\"" ;;
*) logerror "Invalid dialplangoto option: $1"
esac
}
}
# Options for incoming calls.
valid_incoming_list="allowtransfer timeout answerfirst mailbox lastcall lastcalltype missed missedtype"
valid_incoming_option() {
is_in_list $1 ${valid_incoming_list}
return $?
}
handle_incominggeneral() {
option_cb() {
if valid_incoming_option $1 ; then
logdebug 3 "Add Incoming General option $1=$2"
eval "incoming_${1}=\"$2\""
else
logerror "Invalid incominggeneral option $1"
fi
}
}
add_incoming_context() {
local context=$1
eval "local added=\${dialplan_incoming_${context}_added}"
if [ "${added}" != "1" ] ; then
append dialplan_extensions_incoming "${context}" " "
eval "dialplan_incoming_${context}_added=1"
fi
}
# Add to incoming ringing
add_incoming() {
local rhs="$3"
while [ ! -z "$rhs" ] ; do
cur=${rhs%%,*}
nvar=${rhs#*,}
add_incoming_context ${cur}
append dialplan_incoming_${cur} "$1/$2" "&"
[ "$nvar" == "$rhs" ] && break
rhs=${nvar}
done
}
to_upper() {
eval "$1=`echo \"$2\"|tr [a-z] [A-Z]`"
}
to_lower() {
eval "$1=`echo \"$2\"|tr [A-Z] [a-z]`"
}
split_targettype() { # TYPE target inputEntry
local l_targettype="${3%[-_/]*}"
if [ "${l_targettype}" == "$3" ] ; then
return 1
fi
local l_targetname="${3#*[-_/]}"
to_upper "$1" "${l_targettype}"
eval "$2=\"${l_targetname}\""
return 0
}
handle_incoming() {
incoming_context=$1
incoming_list=
add_incoming_context "${incoming_context}"
option_cb() {
logdebug 1 "Incoming ${incoming_context} $1=$2"
case $1 in
lastcall|lastcalltype|missed|missedtype) eval "incoming_${incoming_context}_${1}=\"$2\"" ;;
# lastcall|lastcallexten|lastmissed|lastmissedexten)
# enable_lastcall
# eval "incoming_${incoming_context}_${1}=\"$2\""
# ;;
mailbox|allowtransfer|answerfirst|beforeanswer|timeout|menucontext|match|matchcaller|aftertimeout|aftertimeouttype)
eval "incoming_${incoming_context}_${1}=\"$2\""
;;
target|target_ITEM*)
local targettype=
local targetname=
if split_targettype targettype targetname "${2}" ; then
append dialplan_incoming_${incoming_context} "${targettype}/${targetname}" "&"
else
logerror "No target type specified for target=$2 in ${incoming_context}"
fi
;;
target_LENGTH|member_LENGTH) ;;
*) logerror "Invalid option $1 in incoming" ;;
esac
}
}
# vim: ts=2 sw=2 noet foldmethod=indent

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