portable-services/alpine/gitea/build.sh

39 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
2019-07-09 18:30:30 +02:00
[ -z $ROOTFS ] && ROOTFS=/tmp/gitea
[ -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
2019-07-26 17:26:59 +02:00
[ -f $ROOTFS.raw ] && rm $ROOTFS.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
2019-07-26 17:26:59 +02:00
(sudo systemctl stop gitea.service && sudo portablectl detach gitea) || echo "Image not attached."
mkdir -p $ROOTFS
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/gitea \
$ROOTFS/var/lib/gitea \
2019-07-26 17:26:59 +02:00
$ROOTFS/run/gitea \
2019-07-09 18:30:30 +02:00
$ROOTFS/root/.ssh
2019-07-26 17:26:59 +02:00
touch $ROOTFS/etc/machine-id $ROOTFS/etc/resolv.conf
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
2019-07-26 17:26:59 +02:00
cp systemd/* $ROOTFS/etc/systemd/system/
2019-07-09 18:30:30 +02:00
2019-07-26 17:26:59 +02:00
rm -f $ROOTFS.raw
mksquashfs $ROOTFS/ $ROOTFS.raw -all-root -noappend
2019-07-09 18:30:30 +02:00
sudo portablectl attach $ROOTFS.raw