Compare commits
2 Commits
8902c038c2
...
9308d45255
Author | SHA1 | Date | |
---|---|---|---|
9308d45255 | |||
917fbd44fb |
@ -6,11 +6,13 @@ They feature auto-updating, and some error handling.
|
||||
|
||||
## `scripts-download.sh`
|
||||
|
||||
This script is used to download all the scripts in this repository to a specified directory.
|
||||
This script is used to download selected scripts in this repository to a specified directory and install them as cron jobs.
|
||||
```bash
|
||||
curl -sSL https://git.ivanch.me/ivanch/server-scripts/raw/branch/main/scripts-download.sh | bash
|
||||
```
|
||||
|
||||
When you run the script, you will be prompted to select which scripts you want to download and install.
|
||||
|
||||
### `backup.sh`
|
||||
|
||||
This script is used to backup a directory to a remote server using `rsync`. It is intended to be run as a cron job.
|
||||
|
@ -56,7 +56,7 @@ fi
|
||||
# Updating Docker containers
|
||||
|
||||
for folder in */; do
|
||||
cd $folder
|
||||
cd $DOCKER_FOLDER/$folder
|
||||
|
||||
# if .ignore file exists, skip the folder
|
||||
if [ -f ".ignore" ]; then
|
||||
@ -65,6 +65,18 @@ for folder in */; do
|
||||
continue
|
||||
fi
|
||||
|
||||
# Check if docker-compose.yml or compose.yaml exists and remove the version attribute if it exists
|
||||
if [ -f "docker-compose.yml" ]; then
|
||||
echo -e "${LIGHT_BLUE}[$folder] Checking docker-compose.yml for obsolete version attribute"
|
||||
sed -i '/^version:/d' docker-compose.yml
|
||||
elif [ -f "compose.yaml" ]; then
|
||||
echo -e "${LIGHT_BLUE}[$folder] Checking compose.yaml for obsolete version attribute"
|
||||
sed -i '/^version:/d' compose.yaml
|
||||
elif [ -f "compose.yml" ]; then
|
||||
echo -e "${LIGHT_BLUE}[$folder] Checking compose.yml for obsolete version attribute"
|
||||
sed -i '/^version:/d' compose.yml
|
||||
fi
|
||||
|
||||
DOCKER_RUNNING=$(docker compose ps -q)
|
||||
|
||||
if [ -n "$DOCKER_RUNNING" ]; then
|
||||
|
@ -107,9 +107,24 @@ echo -e "${GREEN}[✓] Crontab is running.${NC}"
|
||||
# Variables
|
||||
FILES=("clean.sh" "backup.sh" "docker-updater.sh")
|
||||
|
||||
# Check connection with the server for all files
|
||||
echo -e "${GREY}[i] Checking connection with the server..."
|
||||
# Prompt user to select files to download
|
||||
selected_files=()
|
||||
echo -e "${GREY}[i] Select files to download and install on crontab:"${NC}"
|
||||
for FILE in "${FILES[@]}"; do
|
||||
read -p "Do you want to download and install $FILE? (y/n): " choice
|
||||
if [[ "$choice" == "y" || "$choice" == "Y" ]]; then
|
||||
selected_files+=("$FILE")
|
||||
fi
|
||||
done
|
||||
|
||||
if [ ${#selected_files[@]} -eq 0 ]; then
|
||||
echo -e "${RED}[x] No files selected. Exiting...${NC}"
|
||||
exit 1
|
||||
fi
|
||||
|
||||
# Check connection with the server for selected files
|
||||
echo -e "${GREY}[i] Checking connection with the server..."
|
||||
for FILE in "${selected_files[@]}"; do
|
||||
curl -s --head "$FILES_URL/$FILE" | head -n 1 | grep -E "HTTP/[12] [23].." > /dev/null
|
||||
|
||||
if [ $? -ne 0 ]; then
|
||||
@ -122,8 +137,8 @@ echo -e "${GREEN}[✓] Connection with the server established.${NC}"
|
||||
|
||||
echo -e "${GREY}[i] Downloading scripts..."
|
||||
|
||||
# Download scripts
|
||||
for FILE in "${FILES[@]}"; do
|
||||
# Download selected scripts
|
||||
for FILE in "${selected_files[@]}"; do
|
||||
curl -s -o "./$FILE" "$FILES_URL/$FILE"
|
||||
done
|
||||
|
||||
@ -134,17 +149,18 @@ CURRENT_WORKDIR=$(pwd)
|
||||
# Setup permissions
|
||||
echo -e "${GREY}[i] Setting up permissions..."
|
||||
|
||||
for FILE in "${FILES[@]}"; do
|
||||
# Setup permissions for selected files
|
||||
for FILE in "${selected_files[@]}"; do
|
||||
chmod +x "./$FILE"
|
||||
done
|
||||
|
||||
echo -e "${GREEN}[✓] Permissions set up.${NC}"
|
||||
|
||||
# Setup crontab for files
|
||||
# Setup crontab for selected files
|
||||
echo -e "${GREY}[i] Setting up crontab..."
|
||||
|
||||
# Add crontabs
|
||||
for FILE in "${FILES[@]}"; do
|
||||
for FILE in "${selected_files[@]}"; do
|
||||
if crontab -l 2>/dev/null | grep -q $FILE; then
|
||||
echo -e "${LIGHT_BLUE}[i] [$FILE] Crontab already exists. Removing...${NC}"
|
||||
crontab -l | grep -v $FILE | crontab -
|
||||
|
Loading…
x
Reference in New Issue
Block a user