Skip to content

Commit

Permalink
Implement msm jargroup changeurl command
Browse files Browse the repository at this point in the history
  • Loading branch information
Marcus Whybrow committed Nov 3, 2012
1 parent 0ebf054 commit 58c9205
Showing 1 changed file with 26 additions and 4 deletions.
30 changes: 26 additions & 4 deletions init/msm
Original file line number Diff line number Diff line change
Expand Up @@ -959,14 +959,15 @@ jargroup_list() {

# Creates a new jargroup
# $1: The name for the jargroup
# $2: The URL target for the jargroup
jargroup_create() {
if is_valid_name "$1"; then
manager_property JAR_STORAGE_PATH
manager_property USERNAME
manager_property JARGROUP_TARGET

if [[ ! -d "$SETTINGS_JAR_STORAGE_PATH/$1" ]]; then
printf "Creating jar group... "
echo -n "Creating jar group... "

local error="$(as_user_stderr "$SETTINGS_USERNAME" "mkdir -p \"$SETTINGS_JAR_STORAGE_PATH/$1\"")"
if [[ "$error" != "" ]]; then
Expand All @@ -987,6 +988,27 @@ jargroup_create() {
fi
}

# Changes an existing jargroups target URL
# $1: The jargroup name to change the url of
# $2: The new target URL to set
jargroup_changeurl() {
manager_property JAR_STORAGE_PATH
manager_property USERNAME
manager_property JARGROUP_TARGET

echo -n "Changing target URL... "

local target="$SETTINGS_JAR_STORAGE_PATH/$1/$SETTINGS_JARGROUP_TARGET"

if [ -e "${target}" ]; then
as_user "$SETTINGS_USERNAME" "echo \"$2\" > \"${target}\""
echo "Done."
else
echo "Failed."
error_exit FILE_NOT_FOUND "Could not find URL target file \"${target}\""
fi
}

# Downloads the latest version for a jargroup, using the target URL for that
# group. Saves the download with the date and time encoded in the start of the
# file name, in the jar group directory in question. Removes the file if there
Expand Down Expand Up @@ -2347,8 +2369,8 @@ command_jargroup_rename() {
# Changes a jar group's target url for automatic downloads
# $1: The jar group name
# $2: The new URL to use
command_jargroup_changetarget() {
jargroup_settarget "$1" "$2"
command_jargroup_changeurl() {
jargroup_changeurl "$1" "$2"
}

# Downloads the latest jar for a jar group
Expand Down Expand Up @@ -3549,7 +3571,7 @@ register_commands() {
register_command "jargroup create <name> <string>" "command_jargroup_create"
register_command "jargroup delete <name>" "command_jargroup_delete"
register_command "jargroup rename <name> <name>" "command_jargroup_rename"
register_command "jargroup changetarget <name> <string>" "command_jargroup_changetarget"
register_command "jargroup changeurl <name> <string>" "command_jargroup_changeurl"
register_command "jargroup getlatest <name>" "command_jargroup_getlatest"

register_command "help" "command_help"
Expand Down

0 comments on commit 58c9205

Please sign in to comment.