Add day_4
This commit is contained in:
parent
2fb860dcb0
commit
132cf5b58c
4 changed files with 109 additions and 0 deletions
17
day_4/compile_tmate.sh
Executable file
17
day_4/compile_tmate.sh
Executable file
|
@ -0,0 +1,17 @@
|
|||
#!/usr/bin/env bash
|
||||
|
||||
# Sync repositories
|
||||
apt update
|
||||
# Install required packages
|
||||
apt install -y git-core build-essential pkg-config libtool libevent-dev libncurses-dev zlib1g-dev automake libssh-dev libmsgpack-dev
|
||||
|
||||
# Follow instructions from the Tmate website to compile
|
||||
git clone https://github.com/tmate-io/tmate.git
|
||||
cd tmate
|
||||
./autogen.sh
|
||||
./configure
|
||||
make
|
||||
make install
|
||||
|
||||
# Move output binary to "output volume"
|
||||
mv tmate /volumes/bin
|
21
day_4/compile_tmate_container.sh
Executable file
21
day_4/compile_tmate_container.sh
Executable file
|
@ -0,0 +1,21 @@
|
|||
#!/usr/bin/env bash
|
||||
|
||||
# Check if script exists that will run in the container
|
||||
if [ ! -f scripts/compile_tmate.sh ]
|
||||
then
|
||||
echo "Script scripts/compile_tmate.sh not found!"
|
||||
exit 1
|
||||
fi
|
||||
|
||||
# Make sure that the script is executable
|
||||
chmod u+x scripts/compile_tmate.sh
|
||||
|
||||
# Make sure that the "output directory" exists
|
||||
mkdir -p bin
|
||||
|
||||
# Run container
|
||||
podman run -it --rm --tz local -v ./scripts:/volumes/scripts:Z,ro -v ./bin:/volumes/bin:Z ubuntu:latest /volumes/scripts/compile_tmate.sh
|
||||
|
||||
echo "DONE!"
|
||||
|
||||
echo "The output binary can be found at bin/tmate"
|
43
day_4/nextcloud.sh
Executable file
43
day_4/nextcloud.sh
Executable file
|
@ -0,0 +1,43 @@
|
|||
#!/usr/bin/env bash
|
||||
|
||||
# In this solution, 0 is used instead of N
|
||||
|
||||
# Create directories for volumes
|
||||
mkdir -p ~/nextcloud0
|
||||
mkdir -p ~/nextcloud0-db
|
||||
|
||||
# Create database container
|
||||
podman create \
|
||||
--name nextcloud0-db \
|
||||
--network traefik \
|
||||
-v ~/nextcloud0-db:/var/lib/postgresql/data:Z \
|
||||
-e POSTGRES_DB=nextcloud \
|
||||
-e POSTGRES_USER=nextcloud \
|
||||
-e POSTGRES_PASSWORD=test \
|
||||
--tz local \
|
||||
--label "io.containers.autoupdate=registry" \
|
||||
docker.io/library/postgres:alpine
|
||||
|
||||
# Create Nextcloud container
|
||||
podman create \
|
||||
--name nextcloud0 \
|
||||
--network traefik \
|
||||
-v ~/nextcloud0:/var/www/html:Z \
|
||||
-e POSTGRES_DB=nextcloud \
|
||||
-e POSTGRES_USER=nextcloud \
|
||||
-e POSTGRES_PASSWORD=test \
|
||||
-e POSTGRES_HOST=nextcloud0-db \
|
||||
--tz local \
|
||||
--label "io.containers.autoupdate=registry" \
|
||||
docker.io/library/nextcloud:24-apache
|
||||
|
||||
|
||||
# Change current directory to not have to move the systemd service files afterwards
|
||||
cd ~/.config/systemd/user
|
||||
# Generate systemd service files
|
||||
podman generate systemd --new --files --name nextcloud0-db
|
||||
podman generate systemd --new --files --name nextcloud0
|
||||
|
||||
# Enable and start the containers
|
||||
systemctl --user enable --now container-nextcloud0-db
|
||||
systemctl --user enable --now container-nextcloud0
|
28
day_4/nginx.sh
Executable file
28
day_4/nginx.sh
Executable file
|
@ -0,0 +1,28 @@
|
|||
#!/usr/bin/env bash
|
||||
|
||||
# In this solution, 0 is used instead of N
|
||||
|
||||
# Check if required directory exists
|
||||
if [ ! -d ~/nginx0 ]
|
||||
then
|
||||
echo "~/nginx0 missing!"
|
||||
exit 1
|
||||
fi
|
||||
|
||||
# Create container
|
||||
podman create \
|
||||
--name nginx0 \
|
||||
--network traefik \
|
||||
-v ~/nginx0/website:/volumes/website:Z,ro \
|
||||
-v ~/nginx0/conf:/etc/nginx/conf.d:Z,ro \
|
||||
--tz local \
|
||||
--label "io.containers.autoupdate=registry" \
|
||||
docker.io/library/nginx:alpine
|
||||
|
||||
# Change current directory to not have to move the systemd service file afterwards
|
||||
cd ~/.config/systemd/user
|
||||
# Generate the systemd service file
|
||||
podman generate systemd --new --files --name nginx0
|
||||
|
||||
# Enable and start the container
|
||||
systemctl --user enable --now container-nginx0
|
Loading…
Reference in a new issue