opsi.admintools/bin/opsi-bbsite.sh

163 lines
7.8 KiB
Bash
Executable File

#! /bin/bash
PUBLIC=/var/www/opsi/htdocs/public
RESTRICTED=/var/www/opsi/htdocs/restricted
name_list=`mktemp /tmp/opsi-bbsite.name-list.XXXXXXXXXXX`
name_list_sort=`mktemp /tmp/opsi-bbsite.name-list-sort.XXXXXXXXXXX`
file_list=`mktemp /tmp/opsi-bbsite.file-list.XXXXXXXXXXX`
file_sort_list=`mktemp /tmp/opsi-bbsite.file-sort-list.XXXXXXXXXXX`
file_sort_list_version=`mktemp /tmp/opsi-bbsite.file-sort-list-verison.XXXXXXXXXXX`
file_sort_list_release=`mktemp /tmp/opsi-bbsite.file-sort-list-relase.XXXXXXXXXXX`
file_sort_list_final=`mktemp /tmp/opsi-bbsite.file-sort-list-final.XXXXXXXXXXX`
pushd ${PUBLIC}
for pkg_root in release testing ; do
echo "[size=200][b]Public[/b][/size]" > ${PUBLIC}/${pkg_root}/.index.bb
echo "[size=150][b]${pkg_root}[/b][/size]" >> ${PUBLIC}/${pkg_root}/.index.bb
echo "[list]" >> ${PUBLIC}/${pkg_root}/.index.bb
# Find all revision files and sort them
for cfg_file in `find ${PUBLIC}/${pkg_root} -name "*.cfg" -print ` ; do
. ${cfg_file}
echo "$REV_PN" >> ${name_list}
done
sort ${name_list} | uniq > ${name_list_sort}
# first uniq sort all cfg based on version
for pkg_name in `cat ${name_list_sort}` ; do
cat /dev/null > ${file_list}
for cfg_file in `find ${PUBLIC}/${pkg_root} -name "${pkg_name}-*.cfg" -print ` ; do
. ${cfg_file}
echo $REV_VERSION >> ${file_list}
done
sort -V ${file_list} | uniq > ${file_sort_list_version}
# second uniq sort all versions based in release
cat /dev/null > ${file_sort_list_release}
for pkg_version in `cat ${file_sort_list_version}` ; do
for cfg_file_ver in ${PUBLIC}/${pkg_root}/${pkg_name}-${pkg_version}-*.cfg ; do
. ${cfg_file_ver}
echo ${pkg_version}-$REV_CREATOR_TAG$REV_RELEASE >> ${file_sort_list_release}
done
done
sort -V ${file_sort_list_release} | uniq > ${file_sort_list_final}
# third create versionrelease
cat /dev/null > ${file_sort_list}
for release_file_list in `cat ${file_sort_list_final}` ; do
. ${PUBLIC}/${pkg_root}/${pkg_name}-${release_file_list}.cfg
echo "${PUBLIC}/${pkg_root}/${pkg_name}-${release_file_list}.cfg" >> ${file_sort_list}
done
# Delete the oldest files
#for cfg_sort_file in `head -n-1 ${file_sort_list}` ; do
for cfg_sort_file in `tail -n 1 ${file_sort_list}` ; do
. ${cfg_file}
if [ -z "${REV_NAME}" ];then
NAME="${REV_PN}"
else
NAME="${REV_NAME}"
fi
DATE=`date -d @${REV_TIMESTAMP} "+%Y-%m-%d %T"`
echo "[*] $REV_PN $NAME $REV_VERSION ( Build: $REV_CREATOR_TAG$REV_RELEASE Erstellt: $DATE Changelog: [url=http://git.disconnected-by-peer.at/go-opsi/$REV_PN/]Link[/url] Vendor: $REV_VENDOR)" >> ${PUBLIC}/${pkg_root}/.index.bb
done
done
echo "[/list]" >> ${PUBLIC}/${pkg_root}/.index.bb
echo "" >> ${PUBLIC}/${pkg_root}/.index.bb
done
popd
pushd ${RESTRICTED}
for pkg_root in release testing ; do
echo "[size=200][b]Restricted[/b][/size]" > ${RESTRICTED}/${pkg_root}/.index.bb
echo "[size=150][b]${pkg_root}[/b][/size]" >> ${RESTRICTED}/${pkg_root}/.index.bb
echo "[list]" >> ${RESTRICTED}/${pkg_root}/.index.bb
# Find all revision files and sort them
for cfg_file in `find ${RESTRICTED}/${pkg_root} -name "*.cfg" -print ` ; do
. ${cfg_file}
echo "$REV_PN" >> ${name_list}
done
sort ${name_list} | uniq > ${name_list_sort}
# first uniq sort all cfg based on version
for pkg_name in `cat ${name_list_sort}` ; do
cat /dev/null > ${file_list}
for cfg_file in `find ${RESTRICTED}/${pkg_root} -name "${pkg_name}-*.cfg" -print ` ; do
. ${cfg_file}
echo $REV_VERSION >> ${file_list}
done
sort -V ${file_list} | uniq > ${file_sort_list_version}
# second uniq sort all versions based in release
cat /dev/null > ${file_sort_list_release}
for pkg_version in `cat ${file_sort_list_version}` ; do
for cfg_file_ver in ${RESTRICTED}/${pkg_root}/${pkg_name}-${pkg_version}-*.cfg ; do
. ${cfg_file_ver}
echo ${pkg_version}-$REV_CREATOR_TAG$REV_RELEASE >> ${file_sort_list_release}
done
done
sort -V ${file_sort_list_release} | uniq > ${file_sort_list_final}
# third create versionrelease
cat /dev/null > ${file_sort_list}
for release_file_list in `cat ${file_sort_list_final}` ; do
. ${RESTRICTED}/${pkg_root}/${pkg_name}-${release_file_list}.cfg
echo "${RESTRICTED}/${pkg_root}/${pkg_name}-${release_file_list}.cfg" >> ${file_sort_list}
done
# Delete the oldest files
#for cfg_sort_file in `head -n-1 ${file_sort_list}` ; do
for cfg_sort_file in `tail -n 1 ${file_sort_list}` ; do
. ${cfg_sort_file}
if [ -z "${REV_NAME}" ];then
NAME="${REV_PN}"
else
NAME="${REV_NAME}"
fi
DATE=`date -d @${REV_TIMESTAMP} "+%Y-%m-%d %T"`
echo "[*] $REV_PN $NAME $REV_VERSION ( Build: $REV_CREATOR_TAG$REV_RELEASE Erstellt: $DATE Changelog: [url=http://git.disconnected-by-peer.at/go-opsi/$REV_PN/]Link[/url] Vendor: $REV_VENDOR)" >> ${RESTRICTED}/${pkg_root}/.index.bb
done
done
echo "[/list]" >> ${RESTRICTED}/${pkg_root}/.index.bb
echo "" >> ${RESTRICTED}/${pkg_root}/.index.bb
done
popd
echo "Hallo Opsi User," > ${PUBLIC}/.header.bb
echo "" >> ${PUBLIC}/.header.bb
echo "Wir erstellen und warten seit einiger Zeit (06.2011) ein Opsi Paket Repository das gleich wie UIB's Repo in den opsi-product-updater integriert werden kann." >> ${PUBLIC}/.header.bb
echo "Das Repository wird in 2 Bereiche geteil [i]Public[/i] und [i]Restricted[/i] (Der Restricted zweig ist nicht oeffentlich zugaenglich)" >> ${PUBLIC}/.header.bb
echo "Ueber die Jahre hat sich eine grosse Anzahl von Paketen ins Repo \"verirrt\"." >> ${PUBLIC}/.header.bb
echo "" >> ${PUBLIC}/.header.bb
echo "Wie man dieses Repo zur Opsi Installation hinzufuegt erfahrt ihr [url=http://opsi.disconnected-by-peer.at/opsi/wiki/Install/Integrate]hier[/url]" >> ${PUBLIC}/.header.bb
echo "Probleme mit den Paketen meldet ihr bitte [url=http://opsi.disconnected-by-peer.at/opsi/newticket]hier[/url] unter Auswahl der richtigen Componenete (Registrierung erforderlich)" >> ${PUBLIC}/.header.bb
echo "" >> ${PUBLIC}/.header.bb
echo "Wer gerne mitmachen will kann sich auf der Entwickler Mailingliste anmelden [url=http://lists.disconnected-by-peer.at/cgi-bin/mailman/listinfo/goopsi-dev]GoOpsi Dev Liste[/url]" >> ${PUBLIC}/.header.bb
echo "oder sich via Jabber bei mir melden (geos_one@0nl1ne.at)" >> ${PUBLIC}/.header.bb
echo "" >> ${PUBLIC}/.header.bb
echo "Details zum Repo:" >> ${PUBLIC}/.header.bb
echo "Jeder Zweig ist in Relase Testing und Integration aufgeteilt." >> ${PUBLIC}/.header.bb
echo "[list]" >> ${PUBLIC}/.header.bb
echo "[*] Release: enthaelt Pakete die wie es sein soll sehr lange getestet wurden und dadurch immer etwas hinter der aktuellen Version hinterherhinken." >> ${PUBLIC}/.header.bb
echo "[*] Testing: enthaelt Pakete die den Test des Entwicklers bestanden haben und jetzt als Testversion fuer die Allgemeinheit da sind." >> ${PUBLIC}/.header.bb
echo "[*] Integration: Ist der \"Playground\" der Entwickler; jeder Commit im Git bewirkt ein Neubau des Pack's und dadurch koennen diese Packs's mit Fehlern bespickt sein." >> ${PUBLIC}/.header.bb
echo "[/list]" >> ${PUBLIC}/.header.bb
echo "" >> ${PUBLIC}/.header.bb
echo "So und jetzt zur aktuellen Liste der Packs im Repo:" >> ${PUBLIC}/.header.bb
echo "" >> ${PUBLIC}/.header.bb
echo "" > ${PUBLIC}/.footer.bb
echo "So das waren die paar Packs ;-)" >> ${PUBLIC}/.footer.bb
echo "Noch Fragen ?" >> ${PUBLIC}/.footer.bb
echo "" >> ${PUBLIC}/.footer.bb
echo "Das GeosOne Opsi Packaging Team" >> ${PUBLIC}/.footer.bb
cat ${PUBLIC}/.header.bb ${PUBLIC}/release/.index.bb ${PUBLIC}/.footer.bb > ${PUBLIC}/release.bb
cat ${PUBLIC}/testing/.index.bb ${PUBLIC}/.footer.bb > ${PUBLIC}/testing.bb
cat ${RESTRICTED}/release/.index.bb ${PUBLIC}/.footer.bb > ${RESTRICTED}/release.bb
cat ${RESTRICTED}/testing/.index.bb ${PUBLIC}/.footer.bb > ${RESTRICTED}/testing.bb