Skip to content

Commit

Permalink
Add generate-unifi-network-application-init-mongo
Browse files Browse the repository at this point in the history
  • Loading branch information
dragonfire1119 committed Oct 29, 2023
1 parent ae4a864 commit 84c284c
Show file tree
Hide file tree
Showing 2 changed files with 35 additions and 0 deletions.
5 changes: 5 additions & 0 deletions generate-unifi-network-application-init-mongo/README.md
@@ -0,0 +1,5 @@
# Run command

```bash
bash -c "$(wget -qLO - https://raw.githubusercontent.com/bigbeartechworld/big-bear-scripts/master/generate-unifi-network-application-init-mongo/run.sh)"
```
30 changes: 30 additions & 0 deletions generate-unifi-network-application-init-mongo/run.sh
@@ -0,0 +1,30 @@
#!/bin/bash

# Ask the user for the desired config location
read -p "Enter the location to save the config (default: /DATA/AppData/unifi-network-application/db/init-mongo.js): " location

# If the user doesn't provide a location, default to the specified path
if [ -z "$location" ]; then
location="/DATA/AppData/unifi-network-application/db/init-mongo.js"
fi

# Check if the config file already exists
if [ -e "$location" ]; then
read -p "Warning: $location already exists. Do you want to replace it? (yes/no) " replace
if [[ "$replace" != "yes" ]]; then
echo "Operation cancelled."
exit 1
fi
fi

# Create the directory (and its parents) if it doesn't exist
mkdir -p "$(dirname "$location")"

# Download the file from the given URL and save it to the specified location
if ! curl -L "https://raw.githubusercontent.com/bigbeartechworld/big-bear-video-assets/main/how-to-install-unifi-network-application-on-portainer/init-mongo.js" -o "$location"; then
echo "Error downloading the file. Check your Internet connection or the URL."
exit 1
fi

# Confirm to the user
echo "Config saved to $location"

0 comments on commit 84c284c

Please sign in to comment.