Last active
August 29, 2015 14:00
-
-
Save regis-leray/041d21afa8ffd897a0f1 to your computer and use it in GitHub Desktop.
cron + create deb repository
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
crontab -l | |
@reboot inoticoming --logfile /var/www/depot/logs/inoticoming-snapshot.log /var/www/depot/snapshot/binary --stderr-to-log --stdout-to-log --suffix '.changes' /usr/local/bin/update-apt-upload.sh /var/www/depot/snapshot \; | |
@reboot inoticoming --logfile /var/www/depot/logs/inoticoming-release.log /var/www/depot/release/binary --stderr-to-log --stdout-to-log --suffix '.changes' /usr/local/bin/update-apt-upload.sh /var/www/depot/release \; | |
cat /usr/local/bin/update-apt-upload.sh | |
#!/bin/sh | |
REPO_DIR=$1 | |
if [ ! -d "$REPO_DIR" ]; then | |
echo "[ERROR] the directory doesnt exist : $REPO_DIR"; | |
exit 1 | |
fi | |
cd $REPO_DIR | |
dpkg-scanpackages -m binary /dev/null | gzip -9c > binary/Packages.gz | |
touch $REPO_DIR/binary/Packages.gz.done | |
chmod 664 $REPO_DIR/binary/Packages.gz.done | |
cat /etc/cron.hourly/apt-oldest | |
#!/bin/sh | |
/usr/local/bin/delete_oldest_files.sh /var/www/depot/snapshot/binary +9 | |
cat /usr/local/bin/delete_oldest_files.sh | |
#!/bin/bash | |
### Delete old releases (.changes, .deb files) | |
# Default directory is /var/www/depot/snapshot/binary | |
DIRECTORY=${1:-"/var/www/depot/snapshot/binary"} | |
# Default value is keep 4 releases (.changes + .deb) | |
NB_KEEP_RELEASE=${2:-"+9"} | |
#find all debian name package | |
for F in $(find $DIRECTORY -name '*.deb' -type f -printf '%f\n' | sed 's/_..*//' | uniq | sort) | |
do | |
echo $F | |
# list all files by modification date / filter by name / remove the first entries from the result / delete old files | |
find $DIRECTORY -name "$F*" | sort -nr | tail -n $NB_KEEP_RELEASE | xargs rm -rf | |
done | |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment