#!/bin/bash XPRT=/srv TEST_XPRT=$XPRT/test SCRATCH_XPRT=$XPRT/scratch #TEST_XPRT=/test #SCRATCH_XPRT=/scratch echo -n "What is the IP address of the vsim? " read VSIM ssh_vsim () { ssh -q admin@$VSIM "$*" | grep -v "Last login time" | sed '/^[[:space:]]*$/d' } echo "Enabling public key access for ssh" KEY=`cat ~/.ssh/id_rsa.pub` sed -i "/$VSIM/d" ~/.ssh/known_hosts ssh_vsim "security login create -user-or-group-name admin -application ssh -authentication-method publickey; security login publickey create -username admin -index 0 -publickey \"$KEY\"" sleep 1 echo -e "\nAssigning disks and increasing root volume size" NODE=`ssh_vsim "system node show" | grep "\-01" | awk '{print $1}'` AGGR=`ssh_vsim "storage aggregate show" | grep $NODE | awk '{print $1}'` ssh_vsim disk assign -all true -node $NODE ssh_vsim storage aggregate add-disks -aggregate $AGGR -diskcount 1 sleep 1 SIZE=`ssh_vsim storage aggregate show -fields availsize | grep $AGGR | awk '{print $2}' | sed 's/\.[[:digit:]]*//'` ssh_vsim volume modify -vserver $NODE -volume vol0 -size +$SIZE BASE=`echo $NODE | awk -F- '{print $1}'` AGGR="$BASE"_aggr VSERVER=$BASE-nfs COUNT=`ssh_vsim disk show | grep spare | cat -b | tail -n 1 | awk '{print $1}'` echo -e "\nCreating vserver: $VSERVER" ssh_vsim storage aggregate create -aggregate $AGGR -diskcount $COUNT ssh_vsim vserver create -vserver $VSERVER -subtype default -rootvolume "$BASE"_nfs_root -rootvolume-security-style unix -language C.UTF-8 -snapshot-policy none -data-services data-iscsi,data-nfs,data-cifs,data-flexcache -foreground true -aggregate $AGGR echo -e "\nSetting up volumes for export ($XPRT, $TEST_XPRT, $SCRATCH_XPRT)" AVAILSIZE=`ssh_vsim "storage aggregate show -aggr $AGGR -fields size" | grep $AGGR | awk '{print $2}'` AGGRSIZE=`echo $AVAILSIZE | awk -F. '{print $1}'` UNIT=`echo $AVAILSIZE | sed 's/[[:digit:]]*\.[[:digit:]]*//'` let XPRTSIZE=(AGGRSIZE/10)*5 XPRTSIZE="$XPRTSIZE$UNIT" ssh_vsim volume create -vserver $VSERVER -volume "$BASE"_srv -aggregate $AGGR -size 1$UNIT -state online -unix-permissions ---rwxrwxrwx -type RW -snapshot-policy none -foreground true -tiering-policy none -junction-path $XPRT ssh_vsim volume create -vserver $VSERVER -volume "$BASE"_test -aggregate $AGGR -size $XPRTSIZE -state online -unix-permissions ---rwxrwxrwx -type RW -snapshot-policy none -foreground true -tiering-policy none -junction-path $TEST_XPRT ssh_vsim volume create -vserver $VSERVER -volume "$BASE"_scratch -aggregate $AGGR -size $XPRTSIZE -state online -unix-permissions ---rwxrwxrwx -type RW -snapshot-policy none -foreground true -tiering-policy none -junction-path $SCRATCH_XPRT NFS_IP=`echo $VSIM | awk -F"." '{printf "%d.%d.%d.%d", $1, $2, $3, $4 - 1}'` PNFS_IP=`echo $VSIM | awk -F"." '{printf "%d.%d.%d.%d", $1, $2, $3, $4 + 1}'` NFS_LIF="$BASE"_nfs PNFS_LIF="$BASE"_pnfs echo -e "\nSetting up network interfaces ($NFS_IP, $PNFS_IP)" ssh_vsim "network interface create -vserver $VSERVER -lif $NFS_LIF -service-policy default-data-files -address $NFS_IP -netmask 255.255.255.0 -home-node $NODE -home-port e0b -status-admin up -failover-policy system-defined -firewall-policy data -auto-revert false -failover-group Default -is-dns-update-enabled true" ssh_vsim "network interface create -vserver $VSERVER -lif $PNFS_LIF -service-policy default-data-files -address $PNFS_IP -netmask 255.255.255.0 -home-node $NODE -home-port e0d -status-admin up -failover-policy system-defined -firewall-policy data -auto-revert false -failover-group Default -is-dns-update-enabled true" echo -e "\nConfiguring NFS" DOMAIN=`hostname -d` ssh_vsim "license add GMJWPDBBVAAAAAAAAAAAAAAAAAAA" ssh_vsim "vserver export-policy rule create -vserver $VSERVER -policyname default -clientmatch 0.0.0.0/0 -rorule any -rwrule any -allow-suid true -allow-dev true -ruleindex 1 -protocol any -superuser any" ssh_vsim "set -privilege diagnostic; export-policy rule modify -policyname default -ruleindex 1 -chown-mode unrestricted" ssh_vsim "nfs create -vserver $VSERVER -access true -v3 enabled -v4.0 enabled -tcp enabled -v4.0-acl enabled -v4.0-read-delegation enabled -v4.0-write-delegation enabled -v4-id-domain $DOMAIN -v4-grace-seconds 45 -v4-acl-preserve enabled -v4.1 enabled -rquota disabled -v4.1-acl enabled -vstorage disabled -v4-numeric-ids enabled -v4.1-read-delegation enabled -v4.1-write-delegation enabled -mount-rootonly enabled -nfs-rootonly disabled -permitted-enc-types des,des3,aes-128,aes-256 -showmount enabled -name-service-lookup-protocol udp -idle-connection-timeout 360 -allow-idle-connection disabled -v3-hide-snapshot disabled -showmount-rootonly disabled -v4.1-pnfs enabled" echo -e "\nCreating users and groups" USER=`whoami` USERID=`id -u $USER` GROUPID=`id -g $USER` for U in $USER fsgqa fsgqa2 nfs host; do ssh_vsim "unix-group create -name $U -id $GROUPID" ssh_vsim "unix-user create -user $U -id $USERID -primary-gid $GROUPID" let USERID=USERID+1 let GROUPID=GROUPID+1 done echo -e "\nSetting time zone" ssh_vsim "cluster time-service ntp server create -server pool.ntp.org" ssh_vsim "timezone -timezone US/Eastern" echo ssh_vsim date echo ssh_vsim volume show -vserver $VSERVER -fields vserver,volume,size,available,junction-path | grep -v "entries were displayed" echo ssh_vsim network interface show -vserver $VSERVER -fields vserver,lif,status-admin,address,home-node,data-protocol| grep -v "entries were displayed"