"Fossies" - the Fresh Open Source Software Archive

Member "glusterfs-8.2/extras/ganesha/scripts/create-export-ganesha.sh" (16 Sep 2020, 2587 Bytes) of package /linux/misc/glusterfs-8.2.tar.gz:


As a special service "Fossies" has tried to format the requested source page into HTML format using (guessed) Bash source code syntax highlighting (style: standard) with prefixed line numbers. Alternatively you can here view or download the uninterpreted source code file.

    1 #!/bin/bash
    2 
    3 #This script is called by glusterd when the user
    4 #tries to export a volume via NFS-Ganesha.
    5 #An export file specific to a volume
    6 #is created in GANESHA_DIR/exports.
    7 
    8 # Try loading the config from any of the distro
    9 # specific configuration locations
   10 if [ -f /etc/sysconfig/ganesha ]
   11         then
   12         . /etc/sysconfig/ganesha
   13 fi
   14 if [ -f /etc/conf.d/ganesha ]
   15         then
   16         . /etc/conf.d/ganesha
   17 fi
   18 if [ -f /etc/default/ganesha ]
   19         then
   20         . /etc/default/ganesha
   21 fi
   22 
   23 GANESHA_DIR=${1%/}
   24 OPTION=$2
   25 VOL=$3
   26 CONF=$GANESHA_DIR"/ganesha.conf"
   27 declare -i EXPORT_ID
   28 
   29 function check_cmd_status()
   30 {
   31         if [ "$1" != "0" ]
   32                  then
   33                  rm -rf $GANESHA_DIR/exports/export.$VOL.conf
   34                  sed -i /$VOL.conf/d $CONF
   35                  exit 1
   36         fi
   37 }
   38 
   39 
   40 if [ ! -d "$GANESHA_DIR/exports" ];
   41         then
   42         mkdir $GANESHA_DIR/exports
   43         check_cmd_status `echo $?`
   44 fi
   45 
   46 function write_conf()
   47 {
   48 echo -e "# WARNING : Using Gluster CLI will overwrite manual
   49 # changes made to this file. To avoid it, edit the
   50 # file and run ganesha-ha.sh --refresh-config."
   51 
   52 echo "EXPORT{"
   53 echo "      Export_Id = 2;"
   54 echo "      Path = \"/$VOL\";"
   55 echo "      FSAL {"
   56 echo "           name = "GLUSTER";"
   57 echo "           hostname=\"localhost\";"
   58 echo  "          volume=\"$VOL\";"
   59 echo "           }"
   60 echo "      Access_type = RW;"
   61 echo "      Disable_ACL = true;"
   62 echo '      Squash="No_root_squash";'
   63 echo "      Pseudo=\"/$VOL\";"
   64 echo '      Protocols = "3", "4" ;'
   65 echo '      Transports = "UDP","TCP";'
   66 echo '      SecType = "sys";'
   67 echo '      Security_Label = False;'
   68 echo "     }"
   69 }
   70 if [ "$OPTION" = "on" ];
   71 then
   72         if ! (cat $CONF | grep  $VOL.conf\"$ )
   73         then
   74                 write_conf $@ > $GANESHA_DIR/exports/export.$VOL.conf
   75                 echo "%include \"$GANESHA_DIR/exports/export.$VOL.conf\"" >> $CONF
   76                 count=`ls -l $GANESHA_DIR/exports/*.conf | wc -l`
   77                 if [ "$count" = "1" ] ; then
   78                         EXPORT_ID=2
   79                 else
   80                         EXPORT_ID=`cat $GANESHA_DIR/.export_added`
   81                         check_cmd_status `echo $?`
   82                         EXPORT_ID=EXPORT_ID+1
   83                         sed -i s/Export_Id.*/"Export_Id= $EXPORT_ID ;"/ \
   84                         $GANESHA_DIR/exports/export.$VOL.conf
   85                         check_cmd_status `echo $?`
   86                 fi
   87                 echo $EXPORT_ID > $GANESHA_DIR/.export_added
   88         fi
   89 else
   90         rm -rf $GANESHA_DIR/exports/export.$VOL.conf
   91         sed -i /$VOL.conf/d $CONF
   92 fi