48 lines
1.0 KiB
Bash
Executable File
48 lines
1.0 KiB
Bash
Executable File
#!/bin/bash
|
|
|
|
COURSE=${LXC_NAME}
|
|
COURSECFG=$HOME/$COURSE
|
|
|
|
# import ssh key to both tt and root users
|
|
import_sshkey() {
|
|
|
|
cp $COURSECFG/ssh/id_ed25519* $LXC_ROOTFS_MOUNT/home/tt/.ssh/
|
|
|
|
chmod 600 $LXC_ROOTFS_MOUNT/home/tt/.ssh/id_ed25519
|
|
chmod 640 $LXC_ROOTFS_MOUNT/home/tt/.ssh/id_ed25519.pub
|
|
chown 1000:1000 $LXC_ROOTFS_MOUNT/home/tt/.ssh/id_ed25519*
|
|
|
|
cp $COURSECFG/ssh/id_ed25519* $LXC_ROOTFS_MOUNT/root/.ssh/
|
|
}
|
|
|
|
#
|
|
# config to be set before 1st boot
|
|
#
|
|
|
|
# act_runner config
|
|
ar_config() {
|
|
|
|
ARTOKEN=$(cat $COURSECFG/act_runner.token)
|
|
sed -i "s/token [^ ]*/token $ARTOKEN/g" $LXC_ROOTFS_MOUNT/etc/systemd/system/act_runner.service
|
|
sed -i "s/ARCOURSE/AR-$COURSE/g" $LXC_ROOTFS_MOUNT/etc/systemd/system/act_runner.service
|
|
|
|
}
|
|
|
|
git_config() {
|
|
sed -i "s/COURSE/$COURSE/" $LXC_ROOTFS_MOUNT/home/tt/.gitconfig
|
|
echo "Git setup completed"
|
|
}
|
|
|
|
grafana_config() {
|
|
sed -i "s/JOBNAME/${LXC_NAME}/" $LXC_ROOTFS_MOUNT/etc/promtail/config.yml
|
|
echo "Grafana setup completed"
|
|
}
|
|
|
|
import_sshkey
|
|
|
|
ar_config
|
|
git_config
|
|
grafana_config
|
|
|
|
exit 0
|