fixed gitlab runner, added youtubedl

This commit is contained in:
Snogard 2023-07-10 16:20:57 +02:00
parent 86c96f28ff
commit 92a415fc68
3 changed files with 102 additions and 5 deletions

View File

@ -31,10 +31,11 @@ if [ $option == "register" ]; then
podman exec gitlab-runner \
gitlab-runner register -n \
--url https://gitlab.com/ \
--registration-toke $token \
--registration-token $token \
--executor docker \
--description "Snogard's $architecture server" \
--tag-list "docker,$architecture"
--tag-list "docker,$architecture" \
--docker-image alpine:latest
fi
systemctl --user enable --now $containerName

View File

@ -0,0 +1,65 @@
#!/bin/bash
source /opt/kaido/src/libs/bash/lib.sh
# docs https://github.com/Tzahi12345/YoutubeDL-Material
# setup
podName=youtubedl
containerName_youtubedl=${podName}_web
containerName_db=${podName}_mongodb
imageName_youtubedl=docker.io/tzahi12345/youtubedl-material:4.3.1
imageName_db=docker.io/library/mongo:4.4.22
containerName=youtubedl_material
dstBasePath=$CONTAINERS_FOLDER/$podName
dstAppDataPath=$dstBasePath/appdata
dstUsersPath=$dstBasePath/users
dstDBPath=$dstBasePath/db
# pre install
create_folder "$dstAppDataPath"
create_folder "$dstUsersPath"
create_folder "$dstDBPath"
stop_and_remove_pod $podName
#install
podman network create $podName
echo "Creating new $podName pod"
podman pod create \
--name $podName \
-p 10104:17442/tcp \
echo "Creating new $containerName_db container"
podman create \
--pod $podName \
--name $containerName_db \
-v $dstDBPath:/data/db \
$imageName_db
echo "Creating new $containerName_youtubedl container"
podman create \
--pod $podName \
--name $containerName_youtubedl \
--requires $containerName_db \
-v $dstAppDataPath:/app/appdata \
-v $dstUsersPath:/app/users \
-e ytdl_mongodb_connection_string="mongodb://$containerName_db:27017" \
-e ytdl_use_local_db=false \
-e write_ytdl_config=true \
-e ALLOW_CONFIG_MUTATIONS=true \
-e NODE_OPTIONS=' --max_old_space_size=2048' \
$imageName_youtubedl
# systemd
create_systemd_services $podName
systemctl --user enable --now $podName

View File

@ -11,12 +11,42 @@ function stop_and_remove_container()
fi
}
function create_folder(){
function stop_and_remove_pod()
{
local name=$1
if podman pod ps --all | grep -qi ${name}; then
echo "Stopping old container"
systemctl --user disable $name
systemctl --user stop $name
echo "Removing old container"
podman pod rm $name
fi
}
function create_systemd_services()
{
local name=$1
mkdir -p $HOME/.config/systemd/user
cd $HOME/.config/systemd/user
podman generate systemd --files --name \
--restart-policy always \
--restart-sec 60 \
--pod-prefix "" \
--container-prefix "" \
$name
}
function create_folder()
{
local path=$1
if [ ! -d "${path}" ]; then
echo "Creating folder path at ${path}"
mkdir -p $path
mkdir -p "$path"
chmod 777 "$path"
fi
}
@ -31,7 +61,8 @@ function symlink_folder()
fi
}
function ensure_file(){
function ensure_file()
{
local src=$1
local dst=$2