Mem del passe de perl à bash
This commit is contained in:
parent
1fe0e4594e
commit
9ec9177350
|
@ -52,7 +52,8 @@ print_domain_letter() {
|
||||||
get_html_path_by_name() {
|
get_html_path_by_name() {
|
||||||
local name="$1"
|
local name="$1"
|
||||||
if [[ ! "$name" =~ ^([a-z0-9]+)$ ]] ; then
|
if [[ ! "$name" =~ ^([a-z0-9]+)$ ]] ; then
|
||||||
echo "Account name is incorrect."
|
# Error on error flux
|
||||||
|
echo "Account name is incorrect." >&2
|
||||||
exit 2
|
exit 2
|
||||||
fi
|
fi
|
||||||
echo "$ALTERNC_HTML/${name:0:1}/$name"
|
echo "$ALTERNC_HTML/${name:0:1}/$name"
|
||||||
|
|
42
src/mem_del
42
src/mem_del
|
@ -1,31 +1,27 @@
|
||||||
#!/usr/bin/perl
|
#!/bin/bash
|
||||||
|
|
||||||
use strict;
|
if [ $# -ne 2 ] ; then
|
||||||
|
echo "Usage: mem_del <name>"
|
||||||
|
echo " Delete the AlternC account <name>"
|
||||||
|
exit 1
|
||||||
|
fi
|
||||||
|
|
||||||
my ($name) = @ARGV;
|
name="$1"
|
||||||
|
|
||||||
if (!$name) {
|
if [[ ! "$name" =~ ^([a-z0-9]+)$ ]] ; then
|
||||||
print "Usage: mem_del <name>\n";
|
echo "Account name is incorrect."
|
||||||
print " Delete the AlternC account <name>\n";
|
exit 2
|
||||||
exit(1);
|
fi
|
||||||
}
|
|
||||||
|
|
||||||
$ENV{PATH} = "";
|
|
||||||
delete @ENV{'IFS', 'CDPATH', 'ENV', 'BASH_ENV'};
|
|
||||||
|
|
||||||
if (!($name =~ /^([a-z0-9]+)$/)) {
|
if [[ ! "$(id -u)" == "0" ]] ; then
|
||||||
die "Account name is incorrect.";
|
echo "please launch mem_add as root (or using sudo)"
|
||||||
}
|
exit 4
|
||||||
$name=$1;
|
fi
|
||||||
|
|
||||||
if ( $< != 0 ) {
|
# Get the vars and some functions
|
||||||
die "please launch mem_del as root (or using sudo)";
|
source /usr/lib/alternc/functions.sh
|
||||||
}
|
target="$(get_html_path_by_name "$name")"
|
||||||
#$< = $>;
|
|
||||||
#$( = $);
|
|
||||||
|
|
||||||
my $PTH="/var/alternc/html/".substr($name,0,1)."/".$name;
|
test -d "$target" && rm -rf "$target"
|
||||||
|
|
||||||
system("/bin/rm -rf '$PTH'");
|
|
||||||
|
|
||||||
0;
|
|
||||||
|
|
Loading…
Reference in New Issue