first commit

This commit is contained in:
Mabe
2026-05-07 20:53:10 +02:00
commit 7ddff5ac9b
16 changed files with 1359 additions and 0 deletions
+24
View File
@@ -0,0 +1,24 @@
## Installation
```ini
git clone https://github.com/mabe1489/compose-autostart.git
cd compose-autostart/
```
## Configuration
### Flags
`-p` Path to the docker-compose.yml
`-c` Compose Project name
### Preconfiguration
After that installing a cronjob with:
```crontab
crontab -e
*/10 * * * * bash YourFolder/autostart.sh -p -c
```
### Update Docker Compose projects
Use
```file
compose-autostart/update_container.sh
```
with the the flags above.
+25
View File
@@ -0,0 +1,25 @@
#!/bin/bash
# Environment variables with flags
DOCKER_PATH="${DOCKER_PATH:-/}"
PROJECT_NAME="${PROJECT_NAME:-npm}"
while getopts ":p:c:" opt; do
case $opt in
p) DOCKER_PATH="$OPTARG";;
c) PROJECT_NAME="$OPTARG";;
\?)
echo "Invalid option: -$OPTARG" >&2
exit 1
;;
:)
echo "Option -$OPTARG requires an argument." >&2
exit 1
;;
esac
done
shift $((OPTIND - 1))
cd "$DOCKER_PATH"
docker compose -p "$PROJECT_NAME" up -d
+17
View File
@@ -0,0 +1,17 @@
#!/bin/bash
cat > /etc/docker/daemon.json <<'EOF'
{
"hosts": ["tcp://0.0.0.0:2375", "unix:///var/run/docker.sock"]
}
EOF
mkdir -p /etc/systemd/system/docker.service.d
cat > /etc/systemd/system/docker.service.d/override.conf <<'EOF'
[Service]
ExecStart=
ExecStart=/usr/bin/dockerd
EOF
systemctl daemon-reload
systemctl restart docker.service
+27
View File
@@ -0,0 +1,27 @@
#!/bin/bash
# Environment variables with flags
DOCKER_PATH="${DOCKER_PATH:-}"
PROJECT_NAME="${PROJECT_NAME:-npm}"
while getopts ":p:c:" opt; do
case $opt in
p) DOCKER_PATH="$OPTARG";;
c) PROJECT_NAME="$OPTARG";;
\?)
echo "Invalid option: -$OPTARG" >&2
exit 1
;;
:)
echo "Option -$OPTARG requires an argument." >&2
exit 1
;;
esac
done
shift $((OPTIND - 1))
cd "$DOCKER_PATH"
docker compose -p "$PROJECT_NAME" pull
docker compose -p "$PROJECT_NAME" up --force-recreate --build -d
docker image prune -f