diff --git a/src/functions.sh b/src/functions.sh index 0e244030..d000ee3b 100755 --- a/src/functions.sh +++ b/src/functions.sh @@ -52,7 +52,8 @@ print_domain_letter() { get_html_path_by_name() { local name="$1" if [[ ! "$name" =~ ^([a-z0-9]+)$ ]] ; then - echo "Account name is incorrect." + # Error on error flux + echo "Account name is incorrect." >&2 exit 2 fi echo "$ALTERNC_HTML/${name:0:1}/$name" diff --git a/src/mem_del b/src/mem_del index 1e19d5aa..484b79a8 100755 --- a/src/mem_del +++ b/src/mem_del @@ -1,31 +1,27 @@ -#!/usr/bin/perl +#!/bin/bash -use strict; +if [ $# -ne 2 ] ; then + echo "Usage: mem_del " + echo " Delete the AlternC account " + exit 1 +fi -my ($name) = @ARGV; +name="$1" -if (!$name) { - print "Usage: mem_del \n"; - print " Delete the AlternC account \n"; - exit(1); -} +if [[ ! "$name" =~ ^([a-z0-9]+)$ ]] ; then + echo "Account name is incorrect." + exit 2 +fi -$ENV{PATH} = ""; -delete @ENV{'IFS', 'CDPATH', 'ENV', 'BASH_ENV'}; -if (!($name =~ /^([a-z0-9]+)$/)) { - die "Account name is incorrect."; -} -$name=$1; +if [[ ! "$(id -u)" == "0" ]] ; then + echo "please launch mem_add as root (or using sudo)" + exit 4 +fi -if ( $< != 0 ) { - die "please launch mem_del as root (or using sudo)"; -} -#$< = $>; -#$( = $); +# Get the vars and some functions +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;