Helper to start aptly container
This commit is contained in:
parent
5f3f27f2ea
commit
b5f39b1ca6
|
@ -0,0 +1,47 @@
|
||||||
|
#!/bin/bash
|
||||||
|
function usage {
|
||||||
|
echo "usage:"
|
||||||
|
echo "aptly.boot <port> <packages_folder> <gpg_folder>"
|
||||||
|
echo
|
||||||
|
echo "port: tcp port to publish repository"
|
||||||
|
echo "packages_folder: folder to mount containing packages"
|
||||||
|
echo "gpg_folder: folder where to write repository public key"
|
||||||
|
echo
|
||||||
|
exit 0
|
||||||
|
}
|
||||||
|
|
||||||
|
if [ $# -ne 3 ]
|
||||||
|
then
|
||||||
|
usage
|
||||||
|
fi
|
||||||
|
|
||||||
|
PORT=$1
|
||||||
|
PACKAGES_FOLDER="$(realpath $2)"
|
||||||
|
GPG_FOLDER="$(realpath ./gpg)"
|
||||||
|
|
||||||
|
if [ ! -e "${PACKAGES_FOLDER}" ]
|
||||||
|
then
|
||||||
|
mkdir "${PACKAGES_FOLDER}"
|
||||||
|
echo "${PACKAGES_FOLDER} est vide"
|
||||||
|
fi
|
||||||
|
|
||||||
|
if [ ! -e "${GPG_FOLDER}" ]
|
||||||
|
then
|
||||||
|
mkdir "${GPG_FOLDER}"
|
||||||
|
fi
|
||||||
|
|
||||||
|
container_id=$(docker run -d -v ${PACKAGES_FOLDER}:/packages -v ${GPG_FOLDER}:/signing-key -p $PORT:8080 cadoles/aptly:dev)
|
||||||
|
|
||||||
|
if [ $(docker ps -q --no-trunc | grep -q $container_id) ]
|
||||||
|
then
|
||||||
|
echo "container with id $container_id started"
|
||||||
|
|
||||||
|
echo "Send ${GPG_FOLDER}/dev.pubkey to remote host, load it in gpg ring with apt-key"
|
||||||
|
|
||||||
|
echo "and add repo to apt source list"
|
||||||
|
|
||||||
|
echo "echo \"deb [arch=amd64] http://$(ip -f inet address show dev enp5s0 | grep -Po 'inet \K[\d.]+'):${PORT}/ ubuntu main\" > /etc/apt/sources.list.d/add.list"
|
||||||
|
else
|
||||||
|
echo "container not started"
|
||||||
|
fi
|
||||||
|
exit 0
|
Loading…
Reference in New Issue