Implemented the "jargroup rename" command.

This commit is contained in:
Marcus Whybrow 2012-05-22 17:23:53 +01:00
parent 2340177ea3
commit 135ed48ba0

40
msm
View File

@ -164,13 +164,14 @@ server_delete() {
server_rename() { server_rename() {
if is_valid_name "$1"; then if is_valid_name "$1"; then
if [[ -e "$SERVER_STORAGE_PATH/$1" ]]; then if [[ -e "$SERVER_STORAGE_PATH/$1" ]]; then
# If the server name is valid, # If the server name is valid and exists
# and there is no other server with the name $1
# TODO: Check that the server is not running first, return if it is # TODO: Check that the server is not running first, return if it is
if is_valid_name "$2"; then if is_valid_name "$2"; then
# If the server name is valid
if [[ -e "$SERVER_STORAGE_PATH/$2" ]]; then if [[ -e "$SERVER_STORAGE_PATH/$2" ]]; then
# and there is not already a server with the name $2
echo "Could not be renamed, there is already a server with the name \"$2\"." echo "Could not be renamed, there is already a server with the name \"$2\"."
return 1 return 1
else else
@ -334,6 +335,36 @@ jargroup_delete() {
fi fi
} }
# Renames an existing jargroup
# $1: The name of the existing jargroup
# $2: The new name
jargroup_rename() {
if is_valid_name "$1"; then
if [[ -e "$JAR_STORAGE_PATH/$1" ]]; then
# If the jar group name is valid,
# and there is no other jar group with the name $1
if is_valid_name "$2"; then
if [[ -e "$JAR_STORAGE_PATH/$2" ]]; then
echo "Could not be renamed, there is already a jar group with the name \"$2\"."
return 1
else
# TODO: Update any symbolic links which point to a jar in this directory
as_user "mv '$JAR_STORAGE_PATH/$1' '$JAR_STORAGE_PATH/$2'"
echo "Renamed jar group \"$1\" to \"$2\"."
fi
else
return 1
fi
else
echo "There is no jar group with the name \"$1\"."
return 1
fi
else
return 1
fi
}
### Script Options ### Script Options
@ -408,6 +439,11 @@ case "$1" in
;; ;;
rename) rename)
if [ -z "$3" ] || [ -z "$4" ]; then
echo "Invalid command."
else
jargroup_rename $3 $4
fi
;; ;;
changetarget) changetarget)
if [ -z "$3" ] || [ -z "$4" ]; then if [ -z "$3" ] || [ -z "$4" ]; then