-
Notifications
You must be signed in to change notification settings - Fork 0
/
tashutdownserver
executable file
·47 lines (39 loc) · 1.47 KB
/
tashutdownserver
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
#!/usr/bin/perl
BEGIN {
if(my($dir) = $0 =~ m/^(.+)\/[^\/]+$/) {
eval "use lib \"$dir/lib\"";
}
}
use strict;
use warnings;
use IO::Socket;
use IO::Socket::INET;
use Thundaural::Server::Settings;
my $host = Thundaural::Server::Settings::listenhost();
$host = "0.0.0.0" if (!$host); # doesn't work on all systems!
my $port = Thundaural::Server::Settings::listenport();
die("no port specified\n") if (!$port);
# should have some kind of authentication here -- anyone could shutdown the server
# even remotely
my $conn = new IO::Socket::INET(PeerAddr=>$host, PeerPort=>$port, proto=>'tcp') or die("$!\n");
if ($conn->connected()) {
print $conn "shut\n";
sleep 1;
}
close($conn);
# Thundaural Jukebox
# Copyright (C) 2003-2005 Andrew A. Bakun
#
# This program is free software; you can redistribute it and/or modify
# it under the terms of the GNU General Public License as published by
# the Free Software Foundation; either version 2 of the License, or
# (at your option) any later version.
#
# This program is distributed in the hope that it will be useful,
# but WITHOUT ANY WARRANTY; without even the implied warranty of
# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
# GNU General Public License for more details.
#
# You should have received a copy of the GNU General Public License
# along with this program; if not, write to the Free Software
# Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA