AptlyOnDemand/aptly.boot

51 lines
1.1 KiB
Plaintext
Raw Normal View History

2018-05-03 14:48:10 +02:00
#!/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)
docker ps -q --no-trunc | grep -q ${container_id}
res=$?
if [ "${res}" -eq 0 ]
2018-05-03 14:48:10 +02:00
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