-
Notifications
You must be signed in to change notification settings - Fork 7
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Fix resources cleanup and env variables passing cron jobs (#12)
- Loading branch information
Showing
6 changed files
with
83 additions
and
90 deletions.
There are no files selected for viewing
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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,27 +1,23 @@ | ||
#!/bin/bash | ||
|
||
NUMBER_OF_LATEST_VERSIONS="$1" | ||
|
||
if [ $NUMBER_OF_LATEST_VERSIONS -gt 0 ]; then | ||
echo "deleting prebid files older than last $NUMBER_OF_LATEST_VERSIONS versions" | ||
else | ||
NUMBER_OF_LATEST_VERSIONS=20 | ||
echo "deleting prebid files older than last $NUMBER_OF_LATEST_VERSIONS versions" | ||
if [[ "$1" -gt 0 ]]; then | ||
NUMBER_OF_PREVIOUS_VERSIONS="$1" | ||
elif [[ ! "$NUMBER_OF_PREVIOUS_VERSIONS" -gt 0 ]]; then | ||
NUMBER_OF_PREVIOUS_VERSIONS=2 | ||
fi | ||
|
||
cd prebid.js | ||
echo "=====> Deleting old versions, number of versions to keep is $NUMBER_OF_PREVIOUS_VERSIONS" | ||
|
||
VERSION_DIRECTORIES="$(ls -d prebid_* | sort -r)" | ||
VERSION_DIRECTORIES="$(ls -d prebid.js/prebid_* | sort -rV)" | ||
|
||
ITERATION=0 | ||
for DIR in $VERSION_DIRECTORIES; | ||
do | ||
if [ $ITERATION -lt $NUMBER_OF_LATEST_VERSIONS ]; then | ||
ITERATION=$[ITERATION+1] | ||
continue | ||
fi | ||
echo "deleting directory $DIR" | ||
rm -rf $DIR | ||
done | ||
for DIR in $VERSION_DIRECTORIES; do | ||
if [[ "$ITERATION" -lt "$NUMBER_OF_PREVIOUS_VERSIONS" ]]; then | ||
ITERATION=$((ITERATION + 1)) | ||
continue | ||
fi | ||
echo "Deleting directory $DIR" | ||
rm -rf "$DIR" | ||
done | ||
|
||
echo "Versions clean up complete" | ||
echo "=====> Old versions clean up complete" |
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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,28 +1,36 @@ | ||
#!/bin/bash | ||
|
||
BUNDLE_LIFE_PERIOD="$1" | ||
shopt -s nullglob | ||
|
||
if [ $BUNDLE_LIFE_PERIOD -gt 0 ]; then | ||
echo "deleting bundles older than $BUNDLE_LIFE_PERIOD seconds" | ||
else | ||
BUNDLE_LIFE_PERIOD=300 | ||
echo "deleting bundles older than $BUNDLE_LIFE_PERIOD seconds" | ||
if [[ "$1" -gt 0 ]]; then | ||
CLEANUP_BUNDLES_OLDER_THAN_SECONDS="$1" | ||
elif [[ ! "CLEANUP_BUNDLES_OLDER_THAN_SECONDS" -gt 0 ]]; then | ||
CLEANUP_BUNDLES_OLDER_THAN_SECONDS=2 | ||
fi | ||
|
||
echo "=====> Deleting bundles older than $CLEANUP_BUNDLES_OLDER_THAN_SECONDS seconds" | ||
|
||
CURRENT_TIME=$(date +%s) | ||
|
||
for DIR in prebid.js/prebid_*; | ||
do | ||
echo "checking $DIR" | ||
BUNDLE_DIR="${DIR}/build/dist/prebid.*.js" | ||
for FILE in $BUNDLE_DIR; | ||
do | ||
FILE_LAST_MODIFIED=$(stat -c%Y $FILE) | ||
if [ "$(($CURRENT_TIME-$FILE_LAST_MODIFIED))" -gt $BUNDLE_LIFE_PERIOD ]; then | ||
echo "deleting file $FILE" | ||
rm -f $FILE | ||
fi | ||
done | ||
done | ||
|
||
echo "Bundles clean up complete" | ||
for DIR in prebid.js/prebid_*; do | ||
BUNDLE_DIR="$DIR/build/dist" | ||
|
||
echo "Checking $BUNDLE_DIR" | ||
|
||
if [[ ! -d "$BUNDLE_DIR" ]]; then | ||
echo "$BUNDLE_DIR does not exist, skipping" | ||
continue | ||
fi | ||
|
||
for FILE in "$BUNDLE_DIR"/prebid.*.js; do | ||
FILE_LAST_MODIFIED=$(stat -c%Y "$FILE") | ||
FILE_AGE=$((CURRENT_TIME - FILE_LAST_MODIFIED)) | ||
|
||
if [[ "$FILE_AGE" -gt $CLEANUP_BUNDLES_OLDER_THAN_SECONDS ]]; then | ||
echo "Deleting file $FILE" | ||
rm -f "$FILE" | ||
fi | ||
done | ||
done | ||
|
||
echo "=====> Bundles clean up complete" |
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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,47 +1,41 @@ | ||
#!/bin/bash | ||
|
||
NUMBER_OF_PREVIOUS_VERSIONS="$1" | ||
|
||
if [ $NUMBER_OF_PREVIOUS_VERSIONS -gt 0 ]; then | ||
echo "checking out $NUMBER_OF_PREVIOUS_VERSIONS previous versions of prebid.js" | ||
else | ||
if [[ "$1" -gt 0 ]]; then | ||
NUMBER_OF_PREVIOUS_VERSIONS="$1" | ||
elif [[ ! "$NUMBER_OF_PREVIOUS_VERSIONS" -gt 0 ]]; then | ||
NUMBER_OF_PREVIOUS_VERSIONS=2 | ||
echo "checking out $NUMBER_OF_PREVIOUS_VERSIONS previous versions of prebid.js" | ||
fi | ||
|
||
echo "=====> Checking out $NUMBER_OF_PREVIOUS_VERSIONS previous versions of prebid.js" | ||
|
||
PREBID_DIR="prebid.js" | ||
if [ ! -d "$PREBID_DIR" ] | ||
then | ||
mkdir $PREBID_DIR | ||
cd $PREBID_DIR | ||
else | ||
cd $PREBID_DIR | ||
if [[ ! -d "$PREBID_DIR" ]]; then | ||
mkdir "$PREBID_DIR" | ||
fi | ||
|
||
if [ ! -d working_master ] | ||
then | ||
git clone https://github.com/prebid/Prebid.js.git working_master | ||
cd working_master | ||
else | ||
cd working_master | ||
cd "$PREBID_DIR" | ||
|
||
if [[ ! -d working_master ]]; then | ||
git clone https://github.com/prebid/Prebid.js.git working_master | ||
fi | ||
|
||
cd working_master | ||
|
||
git pull | ||
|
||
for TAG in `git tag --sort=-creatordate | head -n $NUMBER_OF_PREVIOUS_VERSIONS` | ||
do | ||
DIR_NAME="../prebid_${TAG}" | ||
if [ -d "$DIR_NAME" ] | ||
then | ||
echo "$DIR_NAME already installed" | ||
else | ||
echo "Copying working_master to $DIR_NAME" | ||
cp -R ../working_master $DIR_NAME | ||
cd $DIR_NAME | ||
git checkout ${TAG} | ||
npm install | ||
gulp build | ||
echo "$DIR_NAME installed" | ||
fi | ||
done | ||
echo "update complete" | ||
for TAG in $(git tag --sort=-creatordate | head -n "$NUMBER_OF_PREVIOUS_VERSIONS"); do | ||
DIR_NAME="../prebid_${TAG}" | ||
if [[ -d "$DIR_NAME" ]]; then | ||
echo "$DIR_NAME already installed" | ||
else | ||
echo "Copying working_master to $DIR_NAME" | ||
cp -R ../working_master "$DIR_NAME" | ||
cd "$DIR_NAME" | ||
git checkout "${TAG}" | ||
npm install | ||
gulp build | ||
echo "$DIR_NAME installed" | ||
fi | ||
done | ||
|
||
echo "=====> Update complete" |
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
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
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