portable-services/alpine/gitea/build.sh

40 lines
1.1 KiB
Bash
Raw Normal View History

2019-07-09 18:30:30 +02:00
#!/bin/sh
2019-07-26 17:26:59 +02:00
set -e
NAME=gitea
IMAGE=/tmp/$NAME.raw
[ -z $ROOTFS ] && ROOTFS=$(mktemp -d $NAME.XXX -t)
2019-07-09 18:30:30 +02:00
[ -z $ALPINE_VERSION ] && ALPINE_VERSION=3.10
[ -z $ALPINE_RELEASE ] && ALPINE_RELEASE=0
ALPINE_TARBALL=alpine-minirootfs-$ALPINE_VERSION.$ALPINE_RELEASE-x86_64.tar.gz
[ -f $IMAGE.raw ] && rm $IMAGE.raw
2019-07-09 18:30:30 +02:00
[ -f $ALPINE_TARBALL ] || wget http://dl-cdn.alpinelinux.org/alpine/v$ALPINE_VERSION/releases/x86_64/$ALPINE_TARBALL
(sudo systemctl stop $NAME.service && sudo portablectl detach $NAME) || echo "Image not attached."
2019-07-26 17:26:59 +02:00
tar xf $ALPINE_TARBALL -C $ROOTFS/
2019-07-09 18:30:30 +02:00
2019-07-26 17:26:59 +02:00
chmod 755 $ROOTFS
2019-07-09 18:30:30 +02:00
2019-07-26 17:26:59 +02:00
mkdir -p \
2019-07-09 18:30:30 +02:00
$ROOTFS/etc/systemd/system \
$ROOTFS/etc/$NAME \
$ROOTFS/var/lib/$NAME \
$ROOTFS/run/$NAME \
2019-07-09 18:30:30 +02:00
$ROOTFS/root/.ssh
touch $ROOTFS/etc/machine-id $ROOTFS/etc/resolv.conf
cp systemd/* $ROOTFS/etc/systemd/system/
2019-07-09 18:30:30 +02:00
sudo systemd-nspawn --directory $ROOTFS/ /sbin/apk update
sudo systemd-nspawn --directory $ROOTFS/ /sbin/apk add --no-cache gitea openssh-keygen
2019-07-26 17:26:59 +02:00
sudo systemd-nspawn --directory $ROOTFS/ /bin/rm -rf /etc/apk/* /var/cache/*
2019-07-09 18:30:30 +02:00
mksquashfs $ROOTFS/ $IMAGE -all-root -noappend
sudo portablectl attach $IMAGE
sudo systemctl restart $NAME.service