Sample Script - Overland Storage SnapServer Administrator's Manual

Hide thumbs Also See for SnapServer:
Table of Contents

Advertisement

SnapServer 7.0 Administrator's Guide

Sample Script

Following is an example script that can be used to create and remove users, groups, and
shares:
#!/bin/sh
##########################################################
# Copyright 2003-2007 Overland Storage, Inc. All rights reserved. #
# Permission is granted to use this code provided that it #
# retains the above copyright notice.
##########################################################
CLI=/bin/cli
USER=myuser
PASSWORD=myuserpass
GROUP=mygroup
SHARE=myshare
VOLUME=VOL0
# usage: 'mkuser <user_name> <password>'
mkuser()
{
Create a User
# if the user does not exist then create it
if ! $CLI user get user-name="$1" > /dev/null 2>&1; then
echo "Creating user '$1' ..."
$CLI user create user-name="$1" password="$2" > /dev/null 2>&1
if [ $? -ne 0 ]; then
echo "Creation of user '$1' failed."
return 1
fi
else
echo "User '$1' already exists."
fi
return 0
}
# usage: 'mgroup <group_name>'
mkgroup()
{
Create a Group
# if the group does not exist then create it
if ! $CLI group get group-name="$1" > /dev/null 2>&1; then
return 1
else
echo "Group '$1' already exists."
fi
return 0
}
# usage: 'adduser2group <user_name> <group_name>'
adduser2group()
{
Add the User to the Group
# if both the user and the group exist add the user as a member of this group
if $CLI user get user-name="$1" > /dev/null 2>&1; then
if $CLI group get group-name="$2" > /dev/null 2>&1; then
10400317-001 10/2011
echo "Creating group '$1' ..."
$CLI group create group-name="$1" > /dev/null 2>&1
if [ $? -ne 0 ]; then
echo "Creation of group '$1' failed."
fi
©2010-11 Overland Storage, Inc.
E – Command Line Interface
##
E-13

Hide quick links:

Advertisement

Table of Contents
loading

Table of Contents