]> bicyclesonthemoon.info Git - ott/bsta/blob - reset.1.pl
add frame size to viewer, update css
[ott/bsta] / reset.1.pl
1 ###RUN_PERL: #!/usr/bin/perl
2
3 # reset is generated from reset.1.pl.
4 #
5 # Reset BSTA state
6 #
7 # Copyright (C) 2016, 2017, 2018, 2023, 2024  Balthasar SzczepaƄski
8 #
9 # This program is free software: you can redistribute it and/or modify
10 # it under the terms of the GNU Affero General Public License as
11 # published by the Free Software Foundation, either version 3 of the
12 # License, or (at your option) any later version.
13 #
14 # This program is distributed in the hope that it will be useful,
15 # but WITHOUT ANY WARRANTY; without even the implied warranty of
16 # MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
17 # GNU Affero General Public License for more details.
18 #
19 # You should have received a copy of the GNU Affero General Public License
20 # along with this program.  If not, see <http://www.gnu.org/licenses/>.
21
22 use strict;
23 use utf8;
24 use Encode::Locale ('decode_argv');
25 use Encode ('encode', 'decode');
26
27 ###PERL_LIB: use lib /botm/lib/bsta
28 use botm_common (
29         'read_data_file', 'write_data_file',
30 );
31 use bsta_lib (
32         'STATE', 'INTF_STATE', 'CHAT_STATE',
33         'write_index'
34 );
35
36 binmode STDIN,  ':encoding(UTF-8)';
37 binmode STDOUT, ':encoding(UTF-8)';
38 binmode STDERR, ':encoding(UTF-8)';
39 decode_argv();
40
41 ###PERL_DATA_CHAT_PATH:     DATA_CHAT_PATH     = /botm/data/bsta/chat
42 ###PERL_DATA_LIST_PATH:     DATA_LIST_PATH     = /botm/data/bsta/list
43 ###PERL_DATA_SETTINGS_PATH: DATA_SETTINGS_PATH = /botm/data/bsta/state
44 ###PERL_DATA_STATE_PATH:    DATA_STATE_PATH    = /botm/data/bsta/state
45 ###PERL_DATA_STORY_PATH:    DATA_STORY_PATH    = /botm/data/bsta/story
46
47 ###PERL_RESET_PASSWORD:     RESET_PASSWORD     = ''
48
49 my %story;
50 my %state;
51 my %chat;
52 my %settings;
53 my %goto_list;
54
55 delete @ENV{qw(IFS CDPATH ENV BASH_ENV)};
56 ###PERL_SET_PATH: $ENV{'PATH'} = /usr/local/bin:/usr/bin:/bin;
57
58 %settings = read_data_file(DATA_SETTINGS_PATH());
59 unless (
60         ($ARGV[0] ne '') && (
61                 ($ARGV[0] eq $settings{'password'}) ||
62                 ($ARGV[0] eq RESET_PASSWORD())
63         )
64 ) {
65         print STDERR "Wrong password; no reset.\n";
66         exit 1;
67 }
68
69 %state = (
70         'state' => STATE->{'inactive'},
71         'last'  => 0,
72         'ongtime' => '',
73         'nextong' => '',
74         'ip1' => '',
75         'ip2' => '',
76         'ip3' => ''
77 );
78 %story = (
79         'id'      => 0,
80         'letter'  => '',
81         'lastip'  => '0.0.0.0',
82         'content' => '',
83         'pass'    => 0,
84         'state'   => INTF_STATE->{'X'}
85 );
86 %chat = (
87         'id'      => 0,
88         'state'   => CHAT_STATE->{'disconnected'},
89         'content' => ''
90 );
91 %goto_list = (
92 );
93
94 write_data_file(DATA_STATE_PATH(), '', '', \%state);
95 write_data_file(DATA_STORY_PATH(), '', '', \%story);
96 write_data_file(DATA_CHAT_PATH() , '', '', \%chat);
97 write_data_file(DATA_LIST_PATH() , '', '', \%goto_list);
98
99 write_index(
100         \%state,
101         \%settings,
102         $story{'pass'},
103         $story{'state'},
104         0 # pause
105 );