From d4e23c78ff38bd873975d84fba75187053a47b06 Mon Sep 17 00:00:00 2001 From: cecilihf Date: Mon, 16 Jul 2007 08:39:50 +0000 Subject: [PATCH] Webmin plugin for varnish git-svn-id: svn+ssh://projects.linpro.no/svn/varnish/trunk@1706 d4fa192b-c00b-0410-8231-f00ffab90ce4 --- varnish-tools/webmin/Varnish/CLI.pm | 60 +++++++++++++++++ varnish-tools/webmin/config.info | 2 + varnish-tools/webmin/images/icon.gif | Bin 0 -> 1658 bytes varnish-tools/webmin/images/params_icon.gif | Bin 0 -> 5346 bytes varnish-tools/webmin/images/purge_icon.gif | Bin 0 -> 2545 bytes varnish-tools/webmin/images/status_icon.gif | Bin 0 -> 2563 bytes varnish-tools/webmin/images/vcl_icon.gif | Bin 0 -> 5031 bytes varnish-tools/webmin/index.cgi | 13 ++++ varnish-tools/webmin/module.info | 3 + varnish-tools/webmin/varnish_params.cgi | 71 ++++++++++++++++++++ varnish-tools/webmin/varnish_purge.cgi | 34 ++++++++++ varnish-tools/webmin/varnish_start.cgi | 19 ++++++ varnish-tools/webmin/varnish_status.cgi | 43 ++++++++++++ varnish-tools/webmin/varnish_stop.cgi | 19 ++++++ varnish-tools/webmin/varnish_vcl.cgi | 60 +++++++++++++++++ varnish-tools/webmin/varnish_vcl_upload.cgi | 30 +++++++++ varnish-tools/webmin/varnish_vcl_use.cgi | 22 ++++++ varnish-tools/webmin/varnish_vcl_view.cgi | 29 ++++++++ varnish-tools/webmin/varnishadm-lib.pl | 14 ++++ 19 files changed, 419 insertions(+) create mode 100755 varnish-tools/webmin/Varnish/CLI.pm create mode 100644 varnish-tools/webmin/config.info create mode 100644 varnish-tools/webmin/images/icon.gif create mode 100755 varnish-tools/webmin/images/params_icon.gif create mode 100755 varnish-tools/webmin/images/purge_icon.gif create mode 100755 varnish-tools/webmin/images/status_icon.gif create mode 100755 varnish-tools/webmin/images/vcl_icon.gif create mode 100644 varnish-tools/webmin/index.cgi create mode 100644 varnish-tools/webmin/module.info create mode 100644 varnish-tools/webmin/varnish_params.cgi create mode 100644 varnish-tools/webmin/varnish_purge.cgi create mode 100644 varnish-tools/webmin/varnish_start.cgi create mode 100644 varnish-tools/webmin/varnish_status.cgi create mode 100644 varnish-tools/webmin/varnish_stop.cgi create mode 100644 varnish-tools/webmin/varnish_vcl.cgi create mode 100644 varnish-tools/webmin/varnish_vcl_upload.cgi create mode 100644 varnish-tools/webmin/varnish_vcl_use.cgi create mode 100644 varnish-tools/webmin/varnish_vcl_view.cgi create mode 100644 varnish-tools/webmin/varnishadm-lib.pl diff --git a/varnish-tools/webmin/Varnish/CLI.pm b/varnish-tools/webmin/Varnish/CLI.pm new file mode 100755 index 00000000..c4930df9 --- /dev/null +++ b/varnish-tools/webmin/Varnish/CLI.pm @@ -0,0 +1,60 @@ +#!/usr/local/bin/perl + +# Author: Cecilie Fritzvold + +package Varnish::CLI; + +use IO::Socket; + +# Send a command to varnish over telnet. +# This function takes a hash as parameter. +# Valid keys for the hash are: +# * address : Address of varnish +# * port: port where varnish listens for telnet connections +# * command : the command to send +# * params : parameters to the command as a string. (optional) +# The function returns a tuple with the return code and the result. +# If missing or invalid parameters, 0 is returned. +sub send_command { + my ($args) = shift; + my $sock; + my $line; + my $status, $size, $read; + my $response = ""; + + if (!$args->{'address'} || !$args->{'port'} || !$args->{'command'}) { + return 0; + } + + $sock = IO::Socket::INET->new( + Proto => "tcp", + PeerAddr => $args->{'address'}, + PeerPort => $args->{'port'}, + ) or return 0; + + if ($args->{'params'}) { + $args->{'command'} .= " $args->{'params'}"; + } + print $sock "$args->{'command'}\r\n"; + + if (!($line = <$sock>)) { + return 0; + } + $line =~ /^(\d+) (\d+)/; + $status = $1; + $size = $2; + + while ($line = <$sock>) { + $response .= $line; + $read += length($line); + if ($read >= $size) { + last; + } + } + + close $sock; + + return ($status, $response); +} + +return 1; \ No newline at end of file diff --git a/varnish-tools/webmin/config.info b/varnish-tools/webmin/config.info new file mode 100644 index 00000000..905e8ffa --- /dev/null +++ b/varnish-tools/webmin/config.info @@ -0,0 +1,2 @@ +address=Address to varnish,3,localhost +port=Port number varnish listens for telnet connections on,3,23 diff --git a/varnish-tools/webmin/images/icon.gif b/varnish-tools/webmin/images/icon.gif new file mode 100644 index 0000000000000000000000000000000000000000..fc5b8e9e1c0bc18a2cd57d72613cd99f0d43ad40 GIT binary patch literal 1658 zcmV-=28H=YNk%w1VK4wN0O$Vz00967000L7009I52>}2P000990T2NJ1qcKd00RdJ z1sMSV9RL6w0015V00;{QApigh3q7+3)V8yp&10stHx8({zfVgLXh zA024`0BZmOAR!+t92zAdAZ`NybN~T%001K-B6k1)c>(}^004gg0)hYlCMYE*C?h>l001p6ESLZQnF0Wr0|hWLFPjGk zGc+=r2o9VI2$T*BoeU5-IX9jT3ZM}ZJwH4^K|eu5L8KTPr5PMdLPA7FL#G=Zb2Kt= zH#ka6N=;8poGvY@DJNJ>O{*&{QdCh_Qc_VO(3ALq)PWI3X=klWOK56mxkyO1O-{E?Pi}B+ zxlmENQd4qtakN=kx>r?nc5{?!XuMfhc6fEYT32{_cX@kwgnxd*Wn{xC}bjER(ph{mRYD1TW;N9Qh z-tOAm;Nsuq;NJ1v-s9!r<>%z^%?FN0E?CJ8Bl6ZylN3vWmN>>;@$-^lXs!e&GFodX3$|-sK@bM$*kKew1@k&iW zXysHopF4Y^6BPxc9B)Z^O8vQyTNoq-@r;y8GHJJ~6Zy2`N|q-+duDLxkr%b>K6qVl zL}U}MtlgjR=+w2#Gv_)PG!{zP=94ekoH-3k#fM8k5QU)4n7ICYCZGetT4bX=08pU` z!aRKOB_e%72y(9V1|&Gx#2Qz8Z2@4|5I&2IW557Kkf(=T zeg-uG$YT50Q-yH}vC<44bxe|m7IeIW895*ffI&h}Y(-K|@1zl!K~lhS89%eo@In|r zDRzz$8xo<=eN+7;%q4|1vPwBp+0z3CqbymLGd)z8!$M6oBOE@lA+{JKpg77EHGcpA z00TlY#08>d5lCQP`(zOfS^n1;!bluF2mn9=Cv+Im8ER(M!m5kWk-!KeumI&nTNIPp zKGkU97C8j0z)_TkRHN8Fsz7qrAO+yYQHO8Xm5dn^08oW9sXjBn3DX{A2e3TdLK_4x z6oG^@Q!Aixg@DKnKn`_Li4o6|m# z%6CmtkWen)?K1}e_3`U3SHcXCK|(DG*Tn$Rw%bG??m+nCJY12z%LV5_>50A zCQMq;7u$HMjgu4)9ZaD3oTG^!f}}DQS@>i!KmkJ+v>?|QBURQtG7Nxa*uX@09wrh; z9rhLSrAE>*1n?MkT0t_YQ8#AQpfCUg-tNuB8Q7$@iwC#LZFoUan6g({FEq!I5DJrocC EJLLG(7ytkO literal 0 HcmV?d00001 diff --git a/varnish-tools/webmin/images/params_icon.gif b/varnish-tools/webmin/images/params_icon.gif new file mode 100755 index 0000000000000000000000000000000000000000..495a429284bd10b0ce73553799ddd5793513ad38 GIT binary patch literal 5346 zcmW+)dpwiv8-I4NS;kg~In66V#AXUbn>QsdNhhh4Ilq;13OQ~|O(Mr+%3+mMQgn0( z8*^HY(HkO}Df&5|$4gayTYi zasR&ZFxmGMcs)tBKm+X$+XFy(o0Z({-?D$q)dL<^j|T@_jq(oj2kiZVef)KuE_(<1 zAM^M2iw@=b+X8^fRVN4g6W6}^h@?^?#|;L6jIfEC^7clzx?0m!NR63pH{qsiS7V?3 zWsPPortI`*jH;x%nb7ToJga3L-ACom?_Phuwaez(Txg-Hp2f&u@@dqWwZcQc`5A}( zye_^Z5GXZi{Xb~=;ZqXDfK+>V5WdCHsw)<5Y;gD3e3%zlo&&M9wMEkDbn^YYJWR2N z>g42w-rh~S!@_oG`S@%>dJfwnT~b|;M2dubZEbcZC)*IEu47jt9_1uiwdXMyhM<)? zs?E4?Ef@(`($eQHXlQ64V`5^EwY9ZmNB$B(0$%H0vb3=98RhdKm!QTQ!Zq_lmuT79 zMJbOTn+#yFelpu)-zd8x_Gv^%`xFSy|VSf8BnAEG<2AY;V-7v+I+e539PnukOx> z-mzl`DO^ezu8Bxt!bKvHdV+Z4=Gc4@k@6`tENm+feZQ>C)Q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*HIqCk*0Ngq!+mUn=#@IhB3gByzp{P%wln4Nz*kUdZLRHjCJc|Cg~{t)OD}`H zE2GjrGYaxTA7|sTEm0=Q9C1+xvbCOIJG8`KOKoRS4#O4Qk@pVh;G$$ileHT}2(Y&% z^>SI#-hsS4ze16e@^hBOdQdNwQto(XfEXV^;9H^3%qv0iI3W0((C~hM(jM6*CE#?x L)#25j+jXLI;y literal 0 HcmV?d00001 diff --git a/varnish-tools/webmin/images/purge_icon.gif b/varnish-tools/webmin/images/purge_icon.gif new file mode 100755 index 0000000000000000000000000000000000000000..3da735b6af3e3d6e290d43b9e94ea9e3285493a4 GIT binary patch literal 2545 zcmWkwX;_k38$R#~D7-G^25O3vnYogfOKKumY55g3ehr$18`_tq=2GSgQb<|Zn7O5i zURq|3;@Ff^mKc?pYc=E2SME7xHtsvZyz}Fn=Q=;0=ef^)-)FhZJhWdGuZIT!sCs#N z97Q7K-=T~}=AY238AwnHbN`P!0JU!%Fju}JYf{`^R@{$Kp>gK}V>rM)Br1qQ_Bs<7 z#yQFf47qT&mE!_{3g64a-6!E=kW8U)gOn+@wzl1P7D>Miy01dB1Z7#pu1|mV3x$+4 zG@%q4UkPGx^>BR10g_@x8Ef}B6dHKf2H_)UWfqyYnmu##+=aYS$?Luqm+q~y96eZr zwlD{XLOjJb&hq$cjmer;@@q+e0z<2KTWpDuMwdoR`OECnBJ zOECb6Wq15X0a_?GTv;bv{l4{A(&TzL$vb3~=JXUbad~6RWCs_NHR0sRn8YEA{A1mZ zIhDm9r9;8@UW4{AHCl^5NTio&{aa$(kbCzmMoV3Wy)dLtj3o%EA@+7V$2dup%4mwY znBnsC;p$a@dg+;&2qw4*WNiulr9TbZeFQe3H8!fSbbPy@er$8Jg|Q5mmu0(P?;YH* zF1L~H4>(KE@&-L5quG9p2F+(4*lp;5gSkqE0Ybh(O|?l!K+ydbQAKShxz?mb($RJ) z+U4a@c&T^!Fex<7JJ>PiZzrjKK!l8+F!FGV@wSm7MyAO$+n%Hj32wK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~iFwzsgx(D* z*QTYWj>`Njdrp{b>t#oKdwW;bfmV`S>It$Nds@W#S(h;N;2r^!luB~#MH{~_h}8bt zCH~QWrklaWE7d9JVsdKeN_4+Ic4!DSPIMhey{Ekg=fUj4;o@!6-cmD$&K7dmI literal 0 HcmV?d00001 diff --git a/varnish-tools/webmin/images/vcl_icon.gif b/varnish-tools/webmin/images/vcl_icon.gif new file mode 100755 index 0000000000000000000000000000000000000000..ce1f3a3f0f26f8785b26cb947ef331c791c11e3f GIT binary patch literal 5031 zcmW+)dpy(a`~U1LKP_m(PAXbm!`}CAKtJFpck!_}-1EMFSnx1-| z`j)Z|Du--q&gZ98k}&5In?nq<&u`z~ANPH|u7B>=bzkrI^}4S2mB#eiZD_F40002P zy?b^Z)LHWXjy^_r`yyvkbOs&fvfl*&ifZlkE`8Vegy>y<(Z8`nqhkW1LI9Uwc3=o; z@2P;Wkb@xs!EupwAx;3W%yI8d7oXUUKn)DjF=PP zx`Mo8Xdi2|5kt_7x*}}2TGhYvu;p4mgY&~2@}4s^vL+xnRR6{G0H*O!pjz|GO7Jkr z0rmRIVSrh(Sr^kI&&G#kp8kx3oU;*0C8_!5Sb-@XCI6}f!J#`ea>9H=V^0XFngfsG zg){yz)hRfrPix?L2te#S2a-$cf7>z*73b`Y#EsjgdcE?QqV|U}6+tZZR5o8xZ-Wu~ zGIFTMj~p?D0@aEntoAo1?2QU>E9klN~FhVO41m)(Da&KSd z2YhY*3VzMm)FI;(hiqVuoaF&)>QO(p{;-v37d&n-`~EvV{wjy^*`8&zba}8^vtT11 z`1%?8^s{s7`}lZS(yiZW9Oz9 z$zSH-;Jr`dwY0s>yhF^SjJzY6DF^l(%v210CW1NBx8Mt7?H>p5TJ1@Cqm*OflPEAN zdYPGj?P6pc^U)Lb!Q3?hOzSvZ%gAby;~6zHSJykshSfneBC>5>$(%-V+447Dy2P+; z@r3jU4@e5@jdgdQ_6NZ{Q`^R^jfI6tk+|RNUNQ1kXF8{?14h6UkW3whQf||2tB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9;lKu}c C`+kG~ literal 0 HcmV?d00001 diff --git a/varnish-tools/webmin/index.cgi b/varnish-tools/webmin/index.cgi new file mode 100644 index 00000000..e5186dc1 --- /dev/null +++ b/varnish-tools/webmin/index.cgi @@ -0,0 +1,13 @@ +#!/usr/local/bin/perl + +# Author: Cecilie Fritzvold + +require './varnishadm-lib.pl'; + +&ui_print_header(undef, $module_info{'name'}, "", undef, 1, 1); + +@olinks = ("varnish_vcl.cgi", "varnish_params.cgi", "varnish_status.cgi", "varnish_purge.cgi"); +@otitles = ("VCL", "Params", "Start/Stop", "Purge"); +@oicons = ("images/vcl_icon.gif", "images/params_icon.gif", "images/status_icon.gif", "images/purge_icon.gif"); + +&icons_table(\@olinks, \@otitles, \@oicons); diff --git a/varnish-tools/webmin/module.info b/varnish-tools/webmin/module.info new file mode 100644 index 00000000..6bb49135 --- /dev/null +++ b/varnish-tools/webmin/module.info @@ -0,0 +1,3 @@ +name=Varnish Admin +desc=Varnish Admin + diff --git a/varnish-tools/webmin/varnish_params.cgi b/varnish-tools/webmin/varnish_params.cgi new file mode 100644 index 00000000..12e03041 --- /dev/null +++ b/varnish-tools/webmin/varnish_params.cgi @@ -0,0 +1,71 @@ +#!/usr/local/bin/perl + +# Author: Cecilie Fritzvold + +require './varnishadm-lib.pl'; +use Varnish::CLI; + +&ui_print_header(undef, "Params", "", undef, 1, 1); +&ReadParse(); +&error_setup("Failed"); + +my %attrs = ('address' => $config{'address'}, 'port' => $config{'port'}, + 'command' => 'param.show'); +my ($status, $res) = Varnish::CLI::send_command(\%attrs); + +if (!($status eq '200')) { + &error("$status - $res"); +} + +my @params = (); +foreach my $line (split(/\n/, $res)) { + if ($line =~ /(\w+)\s+([a-zA-z0-9.:]+)(\s+(\[|\()(\w+|%)(\]|\)))?/) { + push @params, {'name' => $1, 'value' => $2, 'unit' => $5}; + } +} +if ($in{'save'}) { + foreach $param (@params) { + if ($in{$param->{'name'}} && !($in{$param->{'name'}} eq $param->{'value'})) { + $attrs{'command'} = 'param.set'; + $attrs{'params'} = "$param->{'name'} $in{$param->{'name'}}"; + $status, $res = Varnish::CLI::send_command(\%attrs); + if (!($status eq '200')) { + &error("$status - $res"); + } + $param->{'value'} = $in{$param->{'name'}}; + } + } +} + +my $cmd_num = 0; +print "
"; +print "\n"; +print "\n"; +print "
params
\n"; +foreach $param (@params) { + if (($cmd_num % 2) == 0) { + print "\n"; + } + print "\n"; + if (($cmd_num % 2) != 0) { + print "\n"; + } + $cmd_num++; +} +print "
$param->{'name'}"; + if ($param->{'unit'} eq 'bool') { + print "{'name'} value=on " . + (($param->{'value'} eq 'on') ? "checked" : "") . " /> On\n"; + print "{'name'} value=off " . + (($param->{'value'} eq 'off') ? "checked" : "") . " /> Off\n"; + + } + else { + print "{'name'} value=$param->{'value'} size=25 /> $param->{'unit'}"; + } + print "
"; +print "
"; +print ""; +print "
"; + +&ui_print_footer("", 'module index'); diff --git a/varnish-tools/webmin/varnish_purge.cgi b/varnish-tools/webmin/varnish_purge.cgi new file mode 100644 index 00000000..13b0c205 --- /dev/null +++ b/varnish-tools/webmin/varnish_purge.cgi @@ -0,0 +1,34 @@ +#!/usr/local/bin/perl + +# Author: Cecilie Fritzvold + +require './varnishadm-lib.pl'; +use Varnish::CLI; + +&ui_print_header(undef, "Purge", "", undef, 1, 1); + +&ReadParse(); +&error_setup("Purge failed"); + +my %attrs = ('address' => $config{'address'}, 'port' => $config{'port'}, + 'command' => 'url.purge'); +if ($in{'regexp'}) { + $attrs{'params'} = $in{'regexp'}; + my ($status, $res) = Varnish::CLI::send_command(\%attrs); + + if ($status eq '200') { + print "Purging succesful
"; + print "$res
"; + print "
"; + } + else { + &error("$status - $res"); + } +} + +print "
\n"; +print "What to purge (regexp):
\n"; +print "
\n"; +print "
"; + +&ui_print_footer("", 'module index'); diff --git a/varnish-tools/webmin/varnish_start.cgi b/varnish-tools/webmin/varnish_start.cgi new file mode 100644 index 00000000..9c1abb7c --- /dev/null +++ b/varnish-tools/webmin/varnish_start.cgi @@ -0,0 +1,19 @@ +#!/usr/local/bin/perl + +# Author: Cecilie Fritzvold + +require './varnishadm-lib.pl'; +use Varnish::CLI; + +&ReadParse(); +&error_setup("Start command failed: "); + +my %attrs = ('address' => $config{'address'}, 'port' => $config{'port'}, + 'command' => 'start'); +my ($status, $res) = Varnish::CLI::send_command(\%attrs); +if (!($status eq 200)) { + &error("$status - $res"); +} +&webmin_log("start"); +&redirect("varnish_status.cgi"); + diff --git a/varnish-tools/webmin/varnish_status.cgi b/varnish-tools/webmin/varnish_status.cgi new file mode 100644 index 00000000..c8e114a3 --- /dev/null +++ b/varnish-tools/webmin/varnish_status.cgi @@ -0,0 +1,43 @@ +#!/usr/local/bin/perl + +# Author: Cecilie Fritzvold + +require './varnishadm-lib.pl'; +use Varnish::CLI; + +&ui_print_header(undef, "Status", "", undef, 1, 1); +&error_setup("Could not get status"); + +my %attrs = ('address' => $config{'address'}, 'port' => $config{'port'}, + 'command' => 'ping'); +my ($status, $res) = Varnish::CLI::send_command(\%attrs); +if ($status eq '200') { + if ($res =~ /^PONG/) { + print "Varnish is up
"; + } + else { + print "Varnish is down
"; + } +} +else { + &error("$status - $res"); +} + +$attrs{'command'} = 'status'; +$status, $res = Varnish::CLI::send_command(\%attrs); +if ($status eq '200') { + print "$res
"; +} +else { + &error("$status - $res"); +} + +print "
\n"; +print &ui_buttons_start(); + +print &ui_buttons_row("varnish_stop.cgi","Stop varnish child"); +print &ui_buttons_row("varnish_start.cgi", "Start varnish child"); + +print &ui_buttons_end(); + +&ui_print_footer("", 'module index'); diff --git a/varnish-tools/webmin/varnish_stop.cgi b/varnish-tools/webmin/varnish_stop.cgi new file mode 100644 index 00000000..3565cb18 --- /dev/null +++ b/varnish-tools/webmin/varnish_stop.cgi @@ -0,0 +1,19 @@ +#!/usr/local/bin/perl + +# Author: Cecilie Fritzvold + +require './varnishadm-lib.pl'; +use Varnish::CLI; + +&ReadParse(); +&error_setup("Stop command failed: "); + +my %attrs = ('address' => $config{'address'}, 'port' => $config{'port'}, + 'command' => 'stop'); +my ($status, $res) = Varnish::CLI::send_command(\%attrs); +if (!($status eq 200)) { + &error("$status - $res"); +} +&webmin_log("stop"); +&redirect("varnish_status.cgi"); + diff --git a/varnish-tools/webmin/varnish_vcl.cgi b/varnish-tools/webmin/varnish_vcl.cgi new file mode 100644 index 00000000..283ce4a6 --- /dev/null +++ b/varnish-tools/webmin/varnish_vcl.cgi @@ -0,0 +1,60 @@ +#!/usr/local/bin/perl + +# Author: Cecilie Fritzvold + +require './varnishadm-lib.pl'; +use Varnish::CLI; + +&ui_print_header(undef, "VCL Admin", "", undef, 1, 1); +&error_setup("Failed"); + +my %attrs = ('address' => $config{'address'}, 'port' => $config{'port'}, + 'command' => 'vcl.list'); +my ($status, $res) = Varnish::CLI::send_command(\%attrs); + +if (!($status eq '200')) { + &error("$status - $res"); +} + +print ""; +print "\n"; +print ""; +print "\n"; +print ""; +print "
Available vcl files
"; +print "
"; +my $confname = ""; +my $set = 0; +foreach my $line (split(/\n/, $res)) { + if ($line =~ /\*?\s+\d\s+(\w+)/) { + $confname = $1; + if ($line =~ /^\*/) { + $set = 1; + } + } + print "\n"; + print "$confname"; + print "
\n"; + $set = 0; +} + +print "\n"; +print "
"; + +print "
Upload new vcl file
"; +print ""; +print ""; +print "
"; +print "Config name: "; +print "
"; +print "VCL file: "; +print &ui_upload("vcl_file", 25); +print "
"; +print "\n"; +print "
"; +print ""; + +print "
"; + +&ui_print_footer("", 'module index'); diff --git a/varnish-tools/webmin/varnish_vcl_upload.cgi b/varnish-tools/webmin/varnish_vcl_upload.cgi new file mode 100644 index 00000000..c918f3fd --- /dev/null +++ b/varnish-tools/webmin/varnish_vcl_upload.cgi @@ -0,0 +1,30 @@ +#!/usr/local/bin/perl + +# Author: Cecilie Fritzvold + +require './varnishadm-lib.pl'; +use Varnish::CLI; +use File::Temp qw (mkstemp); +use Fcntl qw (F_SETFD F_GETFD :mode); + +&ReadParseMime(); +&error_setup("Failed"); + +my %attrs = ('address' => $config{'address'}, 'port' => $config{'port'}, + 'command' => 'vcl.load'); + +my ($fh, $file) = mkstemp("/tmp/tmp.vcl.XXXXXXX"); +print $fh $in{'vcl_file'}; +close($fh); + +chmod S_IRUSR|S_IWUSR|S_IRGRP|S_IROTH, $file; + +$attrs{'params'} = "$in{'vcl_name'} $file"; + +my ($status, $res) = Varnish::CLI::send_command(\%attrs); + +if (!($status eq '200')) { + &error("$status - $res"); +} + +&redirect("varnish_vcl.cgi"); diff --git a/varnish-tools/webmin/varnish_vcl_use.cgi b/varnish-tools/webmin/varnish_vcl_use.cgi new file mode 100644 index 00000000..af28c9f4 --- /dev/null +++ b/varnish-tools/webmin/varnish_vcl_use.cgi @@ -0,0 +1,22 @@ +#!/usr/local/bin/perl + +# Author: Cecilie Fritzvold + +require './varnishadm-lib.pl'; +use Varnish::CLI; + +&ReadParse(); +&error_setup("Failed"); + +my %attrs = ('address' => $config{'address'}, 'port' => $config{'port'}, + 'command' => 'vcl.use'); + +$attrs{'params'} = "$in{'vcl_name'}"; + +my ($status, $res) = Varnish::CLI::send_command(\%attrs); + +if (!($status eq '200')) { + &error("$status - $res"); +} + +&redirect("varnish_vcl.cgi"); \ No newline at end of file diff --git a/varnish-tools/webmin/varnish_vcl_view.cgi b/varnish-tools/webmin/varnish_vcl_view.cgi new file mode 100644 index 00000000..8270cc64 --- /dev/null +++ b/varnish-tools/webmin/varnish_vcl_view.cgi @@ -0,0 +1,29 @@ +#!/usr/local/bin/perl + +# Author: Cecilie Fritzvold + +require './varnishadm-lib.pl'; +use Varnish::CLI; + +&ReadParse(); +&error_setup("Failed"); + +&ui_print_header(undef, "vcl file: $in{'vcl_file'}", "", undef, 1, 1); + +my %attrs = ('address' => $config{'address'}, 'port' => $config{'port'}, + 'command' => 'vcl.show'); + +$attrs{'params'} = "$in{'vcl_file'}"; + +my ($status, $res) = Varnish::CLI::send_command(\%attrs); + +if (!($status eq '200')) { + &error("$status - $res"); +} + +$res =~ s/ / /g; +$res =~ s/\n/
/g; + +print $res; + +&ui_print_footer("varnish_vcl.cgi", 'vcl index'); diff --git a/varnish-tools/webmin/varnishadm-lib.pl b/varnish-tools/webmin/varnishadm-lib.pl new file mode 100644 index 00000000..28994261 --- /dev/null +++ b/varnish-tools/webmin/varnishadm-lib.pl @@ -0,0 +1,14 @@ +#!/usr/local/bin/perl + +do '../web-lib.pl'; +&init_config(); +do '../ui-lib.pl'; + +if (!$config{'address'}) { + $config{'address'} = 'localhost'; +} +if (!$config{'port'}) { + $config{'port'} = 23; +} + +return 1; -- 2.39.5