-
-
Save tuxpowered/4df671c5391173ce6aa3 to your computer and use it in GitHub Desktop.
lighttpd sites enabled
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| # File in: /etc/lighttpd/conf-available/99-sites-enabled.conf | |
| include_shell "/usr/share/lighttpd/include-sites-enabled.pl" |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| #!/usr/bin/perl -wl | |
| # File in: /usr/share/lighttpd/include-sites-enabled.pl | |
| use strict; | |
| use File::Glob ':glob'; | |
| my $enabled = "/etc/lighttpd/sites-enabled/*.conf"; | |
| my @files = bsd_glob($enabled); | |
| for my $file (@files) | |
| { | |
| print "include \"$file\""; | |
| } |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| #!/bin/bash | |
| # Install sites-enabled option to Ubuntu based stock install of | |
| # lighttpd | |
| # | |
| # Setup structure | |
| mkdir -p /etc/lighttpd/sites-{enabled,available} | |
| # Install module script | |
| chmod +x include-sites-enabled.pl | |
| cp include-sites-enabled.pl /usr/share/lighttpd/include-sites-enabled.pl | |
| # Add new module and enable | |
| cp 99-sites-enabled.conf /etc/lighttpd/conf-available | |
| lighttpd-enable-mod sites-enabled | |
| # Append to rule to lighttpd config | |
| #echo 'include_shell "/usr/share/lighttpd/include-sites-enabled.pl"' >> /etc/lighttpd/lighttpd.conf | |
| # Install new lighty-enable-site script. | |
| chmod +x lighty-enable-site | |
| cp lighty-enable-site /usr/sbin/lighty-enable-site | |
| cd /usr/sbin | |
| ln -s lighty-enable-site lighttpd-enable-site | |
| ln -s lighty-enable-site lighttpd-disable-site | |
| echo Done. |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| #!/usr/bin/perl -w | |
| # Ben Davis <[email protected]> | |
| # | |
| # Based on original works by: | |
| # Copyright (c) 2006 Krzysztof Krzyzaniak | |
| # | |
| # Contains changes from: | |
| # - Tobias Gruetzmacher <[email protected]> | |
| # | |
| # You may distribute under the terms of either the GNU General Public | |
| # License[1] or the Artistic License[2]. | |
| # | |
| # [1] http://www.gnu.org/licenses/gpl.html | |
| # [2] http://www.perl.com/pub/a/language/misc/Artistic.html | |
| # | |
| use strict; | |
| use Term::ReadLine; | |
| use File::Basename; | |
| use File::Glob ':glob'; | |
| use File::stat; | |
| #--- some initializations | |
| my $confdir = "/etc/lighttpd/"; | |
| my %available = (); | |
| my %enabled = (); | |
| my @todo = (); | |
| my %moduledeps = (); | |
| my $enabling = 1; | |
| #--- first check if we enabling or disabling | |
| if ($0 =~ /disable-site$/) { | |
| #--- disabling mode | |
| $enabling = 0; | |
| } | |
| #--- list of available sites | |
| my @files = bsd_glob($confdir.'sites-available/*.conf'); | |
| print "Available sites: "; | |
| foreach my $file (@files) { | |
| if (basename($file) =~ /^([\w\-\.]+)\.conf$/) { | |
| $available{$1} = $file; | |
| print qq{$1 }; | |
| } | |
| } | |
| print "\n"; | |
| #--- list of already enabled sites | |
| @files = bsd_glob($confdir.'sites-enabled/*.conf'); | |
| print "Already enabled sites: "; | |
| foreach my $file (@files) { | |
| if (basename($file) =~ /^([\w\-\.]+)\.conf$/) { | |
| $enabled{$1} = $file; | |
| print qq{$1 }; | |
| } | |
| } | |
| print "\n"; | |
| unless (defined($ARGV[0])) { | |
| my $prompt = $enabling ? 'Enable site: ' : 'Disable site: '; | |
| my $term = new Term::ReadLine $prompt; | |
| my $OUT = $term->OUT || \*STDOUT; | |
| my $var = lc($term->readline($prompt)); | |
| @todo = split(/ /, $var); | |
| } | |
| else { | |
| @todo = @ARGV; | |
| } | |
| #--- activate (link) or deactivate (remove) site | |
| foreach my $do (@todo) { | |
| if ($enabling) { | |
| next unless defined($available{$do}); | |
| my $target = sprintf("%s/sites-enabled/%s", $confdir,basename($available{$do})); | |
| print qq{Enabling $do: }; | |
| my $st = stat($target); | |
| unless ( -f $target ) { | |
| if (symlink($available{$do}, $target)) { | |
| print "ok\n"; | |
| } | |
| else { | |
| print "failure: $!\n"; | |
| } | |
| } | |
| else { | |
| print "already enabled\n"; | |
| } | |
| #--- check dependencies | |
| for my $module (@{$moduledeps{$do}}) | |
| { | |
| unless ( -f $target && -l $target ) | |
| { | |
| print qq{Module $do depends on module $module which is not activated.\n}; | |
| } | |
| } | |
| } | |
| else { | |
| if (defined($enabled{$do})) { | |
| print qq{Disabling $do\n}; | |
| my $target = sprintf("%s/sites-enabled/%s", $confdir,basename($enabled{$do})); | |
| unlink($target); | |
| } else { | |
| print qq{Already disabled $do\n}; | |
| } | |
| } | |
| } | |
| print "Run /etc/init.d/lighttpd force-reload to enable changes\n"; |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment