1
0
Fork 0
mirror of git://git.psyced.org/git/psyced synced 2024-08-15 03:25:10 +00:00

teach psyconf to generate the full config

This commit is contained in:
psyc://loupsycedyglgamf.onion/~lynX 2016-02-24 10:04:06 +01:00
parent 02d4e80119
commit 5739aacad6
4 changed files with 59 additions and 19 deletions

View file

@ -44,18 +44,36 @@ use File::Spec;
# }
#}
sub debug() { 0 }
# append something while testing
#my $test = "-NEW";
use Data::Dumper;
#use Data::Dumper;
sub say {
print join('', @_); # if $test;
}
sub sys {
print join(' ', @_), "\n" if debug;
if (system(@_)) {
if ($? == -1) {
print "\t{failed to execute: $!}\n";
} elsif ($? & 127) {
printf "\t{command died with sig %d, %s core dump}\n",
($? & 127), ($? & 128) ? 'with' : 'without';
} else {
printf "\t{command exited with value %d}\n", $? >> 8;
}
exit $? if $?;
exit $@ if $@;
}
}
### MAIN ###
# if you are manually compiling an ldmud, rename it or change here.
my $driver = 'psyclpc';
my $newbie = 0;
use Getopt::Std;
&getopt;
@ -166,8 +184,26 @@ X
$c{_basic_host_name} || 'psyced';
$chatname = 'psyced' if $chatname eq 'psyc';
# say "Generating control files in $c{_basic_path_base} ..\n\n";
my $t = "$base/local/ports.h$test";
my $t = "$base/local";
unless (-w $t) {
$newbie = 1;
say <<X;
Welcome new installer!
Copying (just this time) default configuration into $t ..
X
sys("/bin/cp", "-rp", "$base/config/blueprint", $t);
}
$t = "$base/data";
mkdir($t) unless -w $t;
$t = "$base/data/person";
mkdir($t) unless -w $t;
$t = "$base/data/place";
mkdir($t) unless -w $t;
$t = "$base/log";
mkdir($t) unless -w $t;
$t = "$base/local/ports.h$test";
say "Generating control file $t ..\n";
rename $t, "$t~";
open O, '>', $t or die "Cannot write to $t";
@ -549,6 +585,7 @@ X
print O "\t\$commandline\n";
} else {
say "The file $sandbox/log/psyced.out will contain the runtime output.\n";
say "The file $sandbox/log/psyced.err will contain error messages.\n";
print O <<X;
touch $sandbox/log/psyced.out $sandbox/log/psyced.err
$domv $sandbox/log/psyced.err $sandbox/log/psyced.err-old
@ -581,9 +618,9 @@ X
# PSYCED INIT.D SCRIPT
$t = "$base/etc";
mkdir($t);
mkdir($t) unless -w $t;
$t .= "/init.d";
mkdir($t);
mkdir($t) unless -w $t;
$t .= "/psyced$test";
say "Generating control file $t ..\n";
rename $t, "$t~";
@ -675,13 +712,13 @@ X
# TORRC
$t = "$base/etc/tor";
mkdir($t);
mkdir($t) unless -w $t;
$t = "$base/var";
mkdir($t);
mkdir($t) unless -w $t;
$t = "$base/var/tor";
mkdir($t);
mkdir($t) unless -w $t;
$t = "$base/etc/tor/torrc";
say "Generating Tor configuration $t ..\n";
say "Generating optional Tor configuration $t ..\n";
rename $t, "$t~";
open O, '>', $t or die "Cannot write to $t";
@ -822,7 +859,9 @@ X
## end of former archetype.pl
say "\nCaution: You may have to completely shut down and restart psyced\n";
say "to ensure the newly generated start-up scripts are actually used.\n";
unless ($newbie) {
say "\nCaution: You may have to completely shut down and restart psyced\n";
say "to ensure the newly generated start-up scripts are actually used.\n";
}
# vim:ts=8

View file

@ -1,64 +0,0 @@
#!/usr/bin/pike
// This is an experimental prototype program using parts of psyced from pike.
//
// But careful, you need to apply the pikelpc.patch for pike to even grok
// the LPC syntax.
int main(int argc, array(string) args) {
Stdio.Stat s;
string f;
string home = "/opt/psyced";
array(string) jacks = ({
"/local/psyconf.h", "/local/config.h", "/pike",
"/world/net/psyc",
});
//write("%O: %O\n", argc, args);
//GTK.setup_gtk();
//GTK.Alert("Hi!")->signal_connect("destroy", exit, 0);
if (argc > 1) home = args[1];
foreach (jacks;; f) {
if (! (s = file_stat(f = home + f))) {
write("%s does not exist.\n", f);
return 1;
}
}
add_module_path(home +"/pike");
//add_include_path(home +"/world"); // doesn't work?
add_include_path(home +"/world/net/include");
add_include_path(home +"/world/drivers/pike/include");
// wicked emulation of the LPC debug_message() efun
add_constant("debug_write", _static_modules.files()->_stderr->write);
// the only way to include pathes at runtime without ugly wrapper
// scripts is to delay the actual program compilation with a compile
// statement. what a hack to even get started using pike!! :D
//
program psyced = compile("void create() { net.psyced(4444); }");
//
// run, baby
psyced();
// and don't look back
return -1;
}
/* nifty stuff from http://pike.oav.net/7.0/tutorial_16.html#16
add_constant("sqr",lambda(mixed x) { return x * x; });
void add_program_path(string path);
mapping (string:mixed) all_constant();
array array_sscanf(string data, string format);
void atexit(function callback);
array(array) backtrace();
int errno();
int getpid();
int glob(string glob, string str); or
array(string) glob(string glob, array(string) arr);
int query_num_arg(); // for varargs
mapping replace(mapping a, mixed from, mixed to);
...search(mapping haystack, mixed needle, [ mixed start ]); // member()
*/ // vim:syntax=pike