diff --git a/done-get.sh b/done-get.sh new file mode 100755 index 0000000..590a792 --- /dev/null +++ b/done-get.sh @@ -0,0 +1,55 @@ +#!/bin/bash + +# Check if the first argument is 'install' +if [[ "$1" == "install" && -n "$2" ]]; then + MODULE_URL="$2" + MODULE_NAME=$(basename "$MODULE_URL") + DONE_DIR="done_modules" + + # Create the done_modules directory if it doesn't exist + mkdir -p "$DONE_DIR" + + # Download the file + wget -q "$MODULE_URL" -O "$DONE_DIR/$MODULE_NAME" + + # Check the file type and handle accordingly + if [[ "$MODULE_NAME" == *.zip ]]; then + unzip -q "$DONE_DIR/$MODULE_NAME" -d "$DONE_DIR" + rm "$DONE_DIR/$MODULE_NAME" + elif [[ "$MODULE_NAME" == *.tar.gz ]]; then + tar -xzf "$DONE_DIR/$MODULE_NAME" -C "$DONE_DIR" + rm "$DONE_DIR/$MODULE_NAME" + elif [[ "$MODULE_NAME" == *.js ]]; then + # Keep .js file as is + echo "Module '$MODULE_NAME' installed." + else + # If it's not a .zip, .tar.gz, or .js, it's not a valid module + rm "$DONE_DIR/$MODULE_NAME" + echo "Not a valid module!" + exit 2 + fi + exit 0 +fi + +# Check if the first argument is 'remove' +if [[ "$1" == "remove" && -n "$2" ]]; then + MODULE_NAME="$2" + + # Check if the module is a directory within the current folder + if [[ -d "$MODULE_NAME" && "$MODULE_NAME" == */* ]]; then + rm -rf "$MODULE_NAME" + echo "Directory '$MODULE_NAME' removed." + # Otherwise check if it's a .js file + elif [[ -f "$MODULE_NAME" && "$MODULE_NAME" == *.js ]]; then + rm "$MODULE_NAME" + echo "File '$MODULE_NAME' removed." + else + echo "Module filename not found." + exit 1 + fi + exit 0 +fi + +# If no valid action is found +echo "Usage: $0 {install | remove }" +exit 1 diff --git a/installer.sh b/installer.sh new file mode 100755 index 0000000..eb27fad --- /dev/null +++ b/installer.sh @@ -0,0 +1,2 @@ +sudo cp "done-get.sh" "/usr/local/bin/done-get" +sudo chmod +X /usr/local/bin/done-get \ No newline at end of file