Initial commit
This commit is contained in:
35
bin/create.sh
Executable file
35
bin/create.sh
Executable file
@ -0,0 +1,35 @@
|
||||
#!/bin/bash
|
||||
# 2022-08-05 Hyperling
|
||||
# Create new container template.
|
||||
# usage: create.sh PROJECT_NAME
|
||||
|
||||
source /opt/Docker/source.env
|
||||
|
||||
## Validation ##
|
||||
|
||||
[[ -z $1 ]] && {
|
||||
echo "ERROR: A project name must be specified."
|
||||
exit 1
|
||||
}
|
||||
|
||||
[[ ! -z $2 ]] && {
|
||||
echo "ERROR: Program does not accept a 2nd parameter. Please quote project names with spaces if you insist on using them."
|
||||
exit 2
|
||||
}
|
||||
|
||||
## Variables ##
|
||||
|
||||
dir="$1"
|
||||
file="$dir/docker-compose.yml"
|
||||
|
||||
## Main ##
|
||||
|
||||
cd $DOCKER_HOME
|
||||
mkdir -pv "$dir"
|
||||
[[ ! -f "$file" ]] && echo -e "# Comment.\nservices:\n" >> "$file" ||
|
||||
echo "File already exists, leaving contents alone."
|
||||
echo "${file}:"
|
||||
cat "$file"
|
||||
|
||||
exit 0
|
||||
|
23
bin/get_logs.sh
Executable file
23
bin/get_logs.sh
Executable file
@ -0,0 +1,23 @@
|
||||
#!/bin/bash
|
||||
# 2022-08-05 Hyperling
|
||||
# Put active logs into files for analysis.
|
||||
# usage: get_logs.sh
|
||||
|
||||
source /opt/Docker/source.env
|
||||
|
||||
dir=logs
|
||||
date_format="+%Y%m%d-%H%M%S"
|
||||
|
||||
cd $DOCKER_HOME
|
||||
mkdir -p $dir
|
||||
docker ps | while read container_id image_name other; do
|
||||
image_name=${image_name##*/}
|
||||
echo $container_id $image_name
|
||||
docker inspect $container_id 1>/dev/null 2>&1 &&
|
||||
docker logs $container_id 1>${dir}/${image_name}.log.`date $date_format` 2>&1
|
||||
done
|
||||
|
||||
chmod -R 755 $dir
|
||||
|
||||
exit 0
|
||||
|
22
bin/install.sh
Executable file
22
bin/install.sh
Executable file
@ -0,0 +1,22 @@
|
||||
#!/bin/bash
|
||||
# 2022-08-05 Hyperling
|
||||
# Install docker from official repository. Currently only supports apt.
|
||||
# Original comands came from here: https://docs.docker.com/engine/install/debian/
|
||||
# usage: install.sh
|
||||
|
||||
apt purge docker docker-engine docker.io containerd runc
|
||||
|
||||
apt update &&
|
||||
apt install -y ca-certificates curl gnupg lsb-release &&
|
||||
mkdir -p /etc/apt/keyrings &&
|
||||
curl -fsSL https://download.docker.com/linux/debian/gpg | sudo gpg --dearmor -o /etc/apt/keyrings/docker.gpg &&
|
||||
echo \
|
||||
"deb [arch=$(dpkg --print-architecture) signed-by=/etc/apt/keyrings/docker.gpg] https://download.docker.com/linux/debian \
|
||||
$(lsb_release -cs) stable" | sudo tee /etc/apt/sources.list.d/docker.list > /dev/null &&
|
||||
apt update &&
|
||||
apt install -y docker-ce docker-ce-cli containerd.io docker-compose-plugin &&
|
||||
exit 0
|
||||
|
||||
echo "ERROR: Installation failed!"
|
||||
exit 1
|
||||
|
17
bin/start.sh
Executable file
17
bin/start.sh
Executable file
@ -0,0 +1,17 @@
|
||||
#!/bin/bash
|
||||
# 2022-08-05 Hyperling
|
||||
# Start all containers.
|
||||
# usage: start.sh
|
||||
|
||||
source /opt/Docker/source.env
|
||||
|
||||
cd $DOCKER_HOME/Config
|
||||
for dir in `ls`; do
|
||||
[ -d $dir ] && cd $dir || continue
|
||||
pwd
|
||||
[ -e docker-compose.yml ] && docker compose up -d
|
||||
cd ..
|
||||
done
|
||||
|
||||
exit 0
|
||||
|
17
bin/stop.sh
Executable file
17
bin/stop.sh
Executable file
@ -0,0 +1,17 @@
|
||||
#!/bin/bash
|
||||
# 2022-08-05 Hyperling
|
||||
# Stop all containers.
|
||||
# usage: stop.sh
|
||||
|
||||
source /opt/Docker/source.env
|
||||
|
||||
cd $DOCKER_HOME/Config
|
||||
for dir in `ls`; do
|
||||
[ -d $dir ] && cd $dir || continue
|
||||
pwd
|
||||
[ -e docker-compose.yml ] && docker compose down
|
||||
cd ..
|
||||
done
|
||||
|
||||
exit 0
|
||||
|
12
bin/uninstall.sh
Executable file
12
bin/uninstall.sh
Executable file
@ -0,0 +1,12 @@
|
||||
#!/bin/bash
|
||||
# 2022-08-05 Hyperling
|
||||
# Remove docker and official repository. Currently only supports apt.
|
||||
# usage: uninstall.sh
|
||||
|
||||
apt purge -y docker-ce docker-ce-cli containerd.io docker-compose-plugin &&
|
||||
rm -v /etc/apt/keyrings/docker.gpg &&
|
||||
rm -v /etc/apt/sources.list.d/docker.list &&
|
||||
rm -rfv /var/lib/docker
|
||||
|
||||
exit 0
|
||||
|
Reference in New Issue
Block a user