From b5f39b1ca65eae786f5d95c6f8cdc3035f7fdcbc Mon Sep 17 00:00:00 2001 From: Benjamin Bohard Date: Thu, 3 May 2018 14:48:10 +0200 Subject: [PATCH] Helper to start aptly container --- aptly.boot | 47 +++++++++++++++++++++++++++++++++++++++++++++++ 1 file changed, 47 insertions(+) create mode 100755 aptly.boot diff --git a/aptly.boot b/aptly.boot new file mode 100755 index 0000000..0aa4930 --- /dev/null +++ b/aptly.boot @@ -0,0 +1,47 @@ +#!/bin/bash +function usage { +echo "usage:" +echo "aptly.boot " +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