Commit 9f8f53a6 authored by Jan-Tarek Butt's avatar Jan-Tarek Butt

firmware-bot.sh:

* add checksum function
* add manifest symlink function
* add git checkout function
parent b505e0f8
#!/bin/bash
Logfile="/home/stefan/bot2.log"
d=`date +%Y-%m-%d-%H-%M`
function setSymlink {
unlink stable
lastFW=`ls -ltr | grep '^d' | tail -1| awk '{print $NF}'`
echo "$d - set stable symlink" >> $Logfile
ln -s $lastFW stable
}
function generateChecksum {
find "$PWD" -type d | sort | while read dir;
do
cd "${dir}";
ls | grep -v "*/*" | egrep gluon- | egrep -v "(*md5|*sha1|*sha2)" | sort | while read file;
do
echo "$d - Creating MD5 checksum for" $file "..." >> $Logfile
md5sum $file > "$file.md5"
echo "$d - Creating SHA1 checksum for" $file "..." >> $Logfile
sha1sum $file > "$file.sha1"
echo "$d - Creating SHA2 checksum for" $file "..." >> $Logfile
sha512sum $file > "$file.sha2"
done
done
}
generateChecksum
setSymlink
#!/bin/sh
# -- config --
# Part for PID file
PID_PART="/var/run/geolocator.pid"
# Root dir of the firmware images
FIRMWARE_DIR="/home/tata/firmware"
# Gluon reposetory for singe script
GLUON_GIT="https://github.com/freifunk-gluon/gluon.git"
#Gluon branch
GLUON_BRANCH="v2016.1.x"
#Siteconf reposetory for public keys
SITECONF_GIT="https://git.nordwest.freifunk.net/ffnw-firmware/siteconf.git"
# -- config end --
if [ -f $PID_PART ]; then
echo "Firmware-Bot is still running"
exit 1
else
touch $PID_PART
fi
clean_pid() {
[ -f $PID_PART ] && rm $PID_PART
exit "$1"
}
# -- init end --
#Generating md5, sha1 and sha2 checksum
generate_checksum() {
find "$1" -type d | sort | while read -r dir; do
cd "${dir}" || clean_pid 1
find . -type f | egrep gluon- | egrep -v "(*md5|*sha1|*sha2)" | sort | while read -r file; do
if ! [ -f "$file.md5" ]; then
echo "$(date +%Y-%m-%d-%H-%M) - Creating MD5 checksum for $file ..."
md5sum "$file" > "$file.md5"
fi
if ! [ -f "$file.sha1" ]; then
echo "$(date +%Y-%m-%d-%H-%M) - Creating SHA1 checksum for $file ..."
sha1sum "$file" > "$file.sha1"
fi
if ! [ -f "$file.sha2" ]; then
echo "$(date +%Y-%m-%d-%H-%M) - Creating SHA2 checksum for $file ..."
sha512sum "$file" > "$file.sha2"
fi
done
done
}
# check code into directory out. If it already exists fetch code up to commit ID
checkout_git() {
MYGIT="git -C $1/$2"
echo "checking out $3 to ${1:?}/$2 in version $4"
if [ -d "${1:?}/$2" ]; then
if $MYGIT remote -v | grep -q "$3" ; then
echo "Right remote detected"
if ! $MYGIT checkout "$4" ; then
echo "commitid not found trying to fetch new commits"
$MYGIT pull && $MYGIT checkout "$4"
fi
else
echo "wrong remote or not an git repo at all -> deleting whole directory"
/bin/rm -rf "${1:?}/$2"
##needs to be without -C!!!
git clone "$3" "${1:?}/$2"
$MYGIT checkout "$4"
fi
else
echo "We need to do a fresh checkout"
##needs to be without -C!!!
git clone "$3" "${1:?}/$2"
$MYGIT checkout "$4"
fi
unset MYGIT
}
#check if manifest symlink exsist
check_manifest_symlink() {
if [ -f "$1" ] && [ -f "$2" ]; then
find "$3" -type d | sort | while read -r dir; do
cd "${dir}" || clean_pid 1
find . -type f | egrep ./*.manifest | while read -r manifest; do
if ! [ -f manifest ]; then
ln -s $manifest manifest
fi
done
done
else
clean_pid 1
fi
}
generate_checksum $FIRMWARE_DIR
# checkout gluon git
checkout_git "/tmp" "gluon" $GLUON_GIT $GLUON_BRANCH
# checkout siteconf git
checkout_git "/tmp" "siteconf" $SITECONF_GIT "master"
check_manifest_symlink "/tmp/gluon/contrib/sigtest.sh" "/tmp/siteconf/site.conf" $FIRMWARE_DIR
clean_pid 0
# signatur checker
# symlink creator
# static html generate
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment