Compare commits

...

2 Commits

Author SHA1 Message Date
9308d45255 fixes for docker updater
All checks were successful
Check scripts syntax / check-scripts-syntax (push) Successful in 37s
2025-05-02 22:02:01 -03:00
917fbd44fb add user prompt for file selection in download script 2025-02-20 18:51:12 -03:00
3 changed files with 39 additions and 9 deletions

View File

@ -6,11 +6,13 @@ They feature auto-updating, and some error handling.
## `scripts-download.sh` ## `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 ```bash
curl -sSL https://git.ivanch.me/ivanch/server-scripts/raw/branch/main/scripts-download.sh | 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` ### `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. This script is used to backup a directory to a remote server using `rsync`. It is intended to be run as a cron job.

View File

@ -56,7 +56,7 @@ fi
# Updating Docker containers # Updating Docker containers
for folder in */; do for folder in */; do
cd $folder cd $DOCKER_FOLDER/$folder
# if .ignore file exists, skip the folder # if .ignore file exists, skip the folder
if [ -f ".ignore" ]; then if [ -f ".ignore" ]; then
@ -65,6 +65,18 @@ for folder in */; do
continue continue
fi 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) DOCKER_RUNNING=$(docker compose ps -q)
if [ -n "$DOCKER_RUNNING" ]; then if [ -n "$DOCKER_RUNNING" ]; then

View File

@ -107,9 +107,24 @@ echo -e "${GREEN}[✓] Crontab is running.${NC}"
# Variables # Variables
FILES=("clean.sh" "backup.sh" "docker-updater.sh") FILES=("clean.sh" "backup.sh" "docker-updater.sh")
# Check connection with the server for all files # Prompt user to select files to download
echo -e "${GREY}[i] Checking connection with the server..." selected_files=()
echo -e "${GREY}[i] Select files to download and install on crontab:"${NC}"
for FILE in "${FILES[@]}"; do 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 curl -s --head "$FILES_URL/$FILE" | head -n 1 | grep -E "HTTP/[12] [23].." > /dev/null
if [ $? -ne 0 ]; then if [ $? -ne 0 ]; then
@ -122,8 +137,8 @@ echo -e "${GREEN}[✓] Connection with the server established.${NC}"
echo -e "${GREY}[i] Downloading scripts..." echo -e "${GREY}[i] Downloading scripts..."
# Download scripts # Download selected scripts
for FILE in "${FILES[@]}"; do for FILE in "${selected_files[@]}"; do
curl -s -o "./$FILE" "$FILES_URL/$FILE" curl -s -o "./$FILE" "$FILES_URL/$FILE"
done done
@ -134,17 +149,18 @@ CURRENT_WORKDIR=$(pwd)
# Setup permissions # Setup permissions
echo -e "${GREY}[i] Setting up 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" chmod +x "./$FILE"
done done
echo -e "${GREEN}[✓] Permissions set up.${NC}" echo -e "${GREEN}[✓] Permissions set up.${NC}"
# Setup crontab for files # Setup crontab for selected files
echo -e "${GREY}[i] Setting up crontab..." echo -e "${GREY}[i] Setting up crontab..."
# Add crontabs # Add crontabs
for FILE in "${FILES[@]}"; do for FILE in "${selected_files[@]}"; do
if crontab -l 2>/dev/null | grep -q $FILE; then if crontab -l 2>/dev/null | grep -q $FILE; then
echo -e "${LIGHT_BLUE}[i] [$FILE] Crontab already exists. Removing...${NC}" echo -e "${LIGHT_BLUE}[i] [$FILE] Crontab already exists. Removing...${NC}"
crontab -l | grep -v $FILE | crontab - crontab -l | grep -v $FILE | crontab -