Compare commits
No commits in common. "9308d452555c4726ccf057870e998d037061d58a" and "8902c038c28a64c22dfee10acca4243e210777bc" have entirely different histories.
9308d45255
...
8902c038c2
@ -6,13 +6,11 @@ They feature auto-updating, and some error handling.
|
|||||||
|
|
||||||
## `scripts-download.sh`
|
## `scripts-download.sh`
|
||||||
|
|
||||||
This script is used to download selected scripts in this repository to a specified directory and install them as cron jobs.
|
This script is used to download all the scripts in this repository to a specified directory.
|
||||||
```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.
|
||||||
|
@ -56,7 +56,7 @@ fi
|
|||||||
# Updating Docker containers
|
# Updating Docker containers
|
||||||
|
|
||||||
for folder in */; do
|
for folder in */; do
|
||||||
cd $DOCKER_FOLDER/$folder
|
cd $folder
|
||||||
|
|
||||||
# if .ignore file exists, skip the folder
|
# if .ignore file exists, skip the folder
|
||||||
if [ -f ".ignore" ]; then
|
if [ -f ".ignore" ]; then
|
||||||
@ -65,18 +65,6 @@ 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
|
||||||
|
@ -107,24 +107,9 @@ 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")
|
||||||
|
|
||||||
# Prompt user to select files to download
|
# Check connection with the server for all files
|
||||||
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..."
|
echo -e "${GREY}[i] Checking connection with the server..."
|
||||||
for FILE in "${selected_files[@]}"; do
|
for FILE in "${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
|
||||||
@ -137,8 +122,8 @@ echo -e "${GREEN}[✓] Connection with the server established.${NC}"
|
|||||||
|
|
||||||
echo -e "${GREY}[i] Downloading scripts..."
|
echo -e "${GREY}[i] Downloading scripts..."
|
||||||
|
|
||||||
# Download selected scripts
|
# Download scripts
|
||||||
for FILE in "${selected_files[@]}"; do
|
for FILE in "${FILES[@]}"; do
|
||||||
curl -s -o "./$FILE" "$FILES_URL/$FILE"
|
curl -s -o "./$FILE" "$FILES_URL/$FILE"
|
||||||
done
|
done
|
||||||
|
|
||||||
@ -149,18 +134,17 @@ CURRENT_WORKDIR=$(pwd)
|
|||||||
# Setup permissions
|
# Setup permissions
|
||||||
echo -e "${GREY}[i] Setting up permissions..."
|
echo -e "${GREY}[i] Setting up permissions..."
|
||||||
|
|
||||||
# Setup permissions for selected files
|
for FILE in "${FILES[@]}"; do
|
||||||
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 selected files
|
# Setup crontab for files
|
||||||
echo -e "${GREY}[i] Setting up crontab..."
|
echo -e "${GREY}[i] Setting up crontab..."
|
||||||
|
|
||||||
# Add crontabs
|
# Add crontabs
|
||||||
for FILE in "${selected_files[@]}"; do
|
for FILE in "${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 -
|
||||||
|
Loading…
x
Reference in New Issue
Block a user