add code
This commit is contained in:
parent
89728c7ebb
commit
cdf4a0a3fa
2 changed files with 57 additions and 0 deletions
55
done-get.sh
Executable file
55
done-get.sh
Executable file
|
@ -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 <url> | remove <filename>}"
|
||||
exit 1
|
2
installer.sh
Executable file
2
installer.sh
Executable file
|
@ -0,0 +1,2 @@
|
|||
sudo cp "done-get.sh" "/usr/local/bin/done-get"
|
||||
sudo chmod +X /usr/local/bin/done-get
|
Loading…
Reference in a new issue