initial commit of file from CVS for smeserver-manager on Fri Mar 22 14:54:28 AEDT 2024

This commit is contained in:
Trevor Batley
2024-03-22 14:54:28 +11:00
parent eed507434f
commit db139626ba
242 changed files with 25308 additions and 2 deletions

View File

@@ -0,0 +1,25 @@
#! /bin/bash
#> unshift secrets values
#> refresh Routes base
#> refresh Navigation menu bases
### refresh Rest password base
#> expand smanager.conf et reload service
### smanager activity test
SMANAGER_DIR='/usr/share/smanager'
# unshift secrets value
$SMANAGER_DIR/script/secrets.pl
# refresh routes database
$SMANAGER_DIR/script/routes.pl
# refresh Navigation menu database
#$SMANAGER_DIR/script/navigation.pl
# smanager config files and databases
/sbin/e-smith/expand-template $SMANAGER_DIR/conf/srvmngr.conf
/sbin/e-smith/signal-event smanager-refresh
exit 0

View File

@@ -0,0 +1,34 @@
#! /usr/bin/perl -w
# purge Routes database (uninstalled contribs)
use strict;
use warnings;
use esmith::ConfigDB;
use constant WEBFUNCTIONS => '/usr/share/smanager/lib/SrvMngr/Controller/';
my $rtdb = esmith::ConfigDB->open('routes') or
die "Couldn't access Routes database\n";
my @routes = $rtdb->get_all_by_prop( type => 'route' );
exit 0 unless @routes;
my ($sv_contrib, $sv_exist, $file) = '';
for (@routes) {
my ( $contrib, $name ) = split ( /\+/, $_->key);
if ( $contrib ne $sv_contrib) {
$sv_contrib = $contrib;
$file = WEBFUNCTIONS . ucfirst($contrib) .'.pm';
$sv_exist = ( -f $file ) ? 1 : 0;
}
# print("$contrib $file deleted \n") unless $sv_exist;
$rtdb->get($_->key)->delete() unless $sv_exist;
}
exit 0;

View File

@@ -0,0 +1,53 @@
#! /bin/env perl
# unshift secrets values
# 3 secrets values (first one for encrypt, all 3 for decrypt)
# new value added each day as first one
use strict;
use warnings;
use esmith::ConfigDB;
sub gen_pwd {
use MIME::Base64 qw(encode_base64);
my $p = "not set due to error";
if ( open( RANDOM, "/dev/urandom" ) ){
my $buf;
# 57 bytes is a full line of Base64 coding, and contains
# 456 bits of randomness - given a perfectly random /dev/random
if ( read( RANDOM, $buf, 57 ) != 57 ){
warn("Short read from /dev/random: $!");
} else {
$p = encode_base64($buf);
chomp $p;
}
close RANDOM;
} else {
warn "Could not open /dev/urandom: $!";
}
return $p;
}
my $cdb = esmith::ConfigDB->open() || die "Couldn't open config db";
my $pwds = $cdb->get_prop('smanager','Secrets');
if ( $pwds ){
my @secrets = split /,/, $pwds;
my $newpwd = gen_pwd();
if ( $newpwd ) {
$secrets[2] = $secrets[1] if ( $secrets[1] );
$secrets[1] = $secrets[0];
$secrets[0] = $newpwd;
my $secret = join ',', @secrets;
$cdb->get('smanager')->set_prop('Secrets', $secret);
#print("Secret values unshifted\n");
} else {
print("Secret generation error\n");
}
} else {
print("Error while unshifting secrets values\n");
}
exit 0

View File

@@ -0,0 +1,33 @@
#! /usr/bin/perl -wT
# mojo-app server-manager v3 mab974 2020
use strict;
use warnings;
use esmith::util;
BEGIN
{
$0 =~ /^(.+)$/ms; $0 = $1; # Untaint script name
$ENV{'PATH'} = '/bin:/usr/bin:/usr/local/bin';
$ENV{'SHELL'} = '/bin/bash';
$ENV{'HOME'} = '/usr/share/smanager';
delete $ENV{'ENV'};
esmith::util::setRealToEffective();
}
use FindBin;
#use lib "$FindBin::Bin/lib";
use lib "$FindBin::Bin/../lib";
#BEGIN { unshift @INC, "$FindBin::Bin/../lib" }
#Application
$ENV{MOJO_APP} ||= 'SrvMngr';
$ENV{MOJO_REVERSE_PROXY} ||= '/smanager';
$ENV{MOJO_SMANAGER_DEBUG} ||= 0;
$ENV{SRVMNGR_HOME} ||= "$FindBin::Bin/..";
# Start command
require Mojolicious::Commands;
Mojolicious::Commands->start_app('SrvMngr');