Alternc  latest
Alternc logiel libre pour l'hébergement
hosting_massvhost.sh
Go to the documentation of this file.
1 #!/bin/bash
2 
3 ACTION=$1
4 # $2 is the type
5 DOMAIN=$3
6 TARGET=$4
7 
8 # Load some librairies
9 . /etc/alternc/local.sh
10 . /usr/lib/alternc/functions.sh
11 
12 # To not be case-sensitive
13 ACTION="`echo $ACTION|tr '[:upper:]' '[:lower:]'`"
14 DOMAIN="`echo $DOMAIN|tr '[:upper:]' '[:lower:]'`"
15 
16 if [ -z $ACTION ] || [ -z $DOMAIN ] ; then
17  echo "Need at least 2 parameters ( action - fqdn )"
18 fi
19 
20 YOP="$ALTERNC_LOC/dns/$(print_domain_letter $DOMAIN)/$DOMAIN"
21 
22 case $ACTION in
23 "disable"|"delete")
24  if [ ! -e "$YOP" ] ; then
25  echo "Link do not exist. Nothing done"
26  exit 15
27  fi
28  if [ ! -L "$YOP" ] ; then
29  echo "Seem not to be a link ($YOP). Abord"
30  exit 16
31  fi
32  rm -f "$YOP"
33  ;;
34 "enable"|"create")
35  if [ -z "$TARGET" ] ; then
36  echo "Parameters target $TARGET missing"
37  exit 13
38  fi
39  USER=$(get_account_by_domain "$DOMAIN")
40  if [ -z $USER ] ; then
41  echo "Unable to find account of $DOMAIN"
42  exit 17
43  fi
44  TARGET="$ALTERNC_LOC/html/$(print_user_letter $USER)/$USER/$TARGET"
45  if [ ! -d "$TARGET" ] ; then
46  echo "Directory $TARGET missing"
47  exit 14
48  fi
49  ln -snf "$TARGET" "$YOP"
50  ;;
51 *)
52  echo Error : $ACTION not an recognised action
53  exit 11
54  ;;
55 esac
56