AletaReleaser/build.sh

57 lines
1.2 KiB
Bash
Raw Permalink Normal View History

#!/bin/bash
docker ps &> /dev/null
if [ $? != 0 ]; then
docker() {
sudo $(which docker) "$@"
}
fi
2022-02-08 23:17:00 +01:00
build() {
cd -
if [ -e output ]; then
rm -rf output
fi
if update_aleta; then
mkdir output
docker build --no-cache -t aletareleaser:latest . --build-arg uid=$(getent passwd $(whoami) | awk -F: '{ print $3 }')
docker run -v $(realpath output):/var/lib/aleta/output --rm aletareleaser
else
return 1;
fi
}
update_aleta() {
if [ ! -e aleta ]; then
git clone https://gitea.sergiotarxz.freemyip.com/germedeb/aleta-postre aleta
return 0;
fi
2022-02-08 23:17:00 +01:00
cd aleta
git fetch
current_commit=$(git rev-parse HEAD)
if [ $current_commit == `git rev-parse @{u}` ]; then
echo 'Aleta is updated'
cd -
return 1
fi
git pull
cd -
return 0
2022-02-08 23:17:00 +01:00
}
source ~/.bashrc
2022-02-08 05:42:26 +01:00
cd $(dirname $0)
2022-02-08 21:26:24 +01:00
if [ -f aleta.lock ]; then
echo 'Deploy is running.';
2022-02-08 23:17:00 +01:00
exit 0;
2022-02-08 21:26:24 +01:00
fi
touch aleta.lock
2022-02-08 23:17:00 +01:00
build
exit_build=$?
2022-02-08 21:26:24 +01:00
rm aleta.lock
2022-02-08 23:17:00 +01:00
if [ $exit_build == 0 ]; then
if [ ! -e output/aleta.tar.gz ]; then
echo "aleta.tar.gz not exists." 1>&2
exit 1
fi
perl create_aleta_release.pl
fi