-
Notifications
You must be signed in to change notification settings - Fork 976
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
1 parent
1d3f975
commit ddc603e
Showing
10 changed files
with
131 additions
and
2 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
File renamed without changes.
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 |
---|---|---|
@@ -0,0 +1,13 @@ | ||
#!/bin/bash | ||
DIR="$( cd "$( dirname "${BASH_SOURCE[0]}" )" && pwd )" | ||
DATE=$(date +%Y-%m-%d:%H:%M:%S) | ||
VERSION="$(basename "${DIR}")" | ||
|
||
countly stop | ||
if [ -f "$DIR/upgrade_fs.sh" ]; then | ||
bash "$DIR/upgrade_fs.sh" combined 2>&1 | tee -a "$DIR/../../../log/countly-upgrade-fs-$VERSION-$DATE.log" | ||
fi | ||
if [ -f "$DIR/upgrade_db.sh" ]; then | ||
bash "$DIR/upgrade_db.sh" combined 2>&1 | tee -a "$DIR/../../../log/countly-upgrade-db-$VERSION-$DATE.log" | ||
fi | ||
countly upgrade |
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 |
---|---|---|
@@ -0,0 +1,39 @@ | ||
#!/bin/bash | ||
|
||
VER="20.11.1" | ||
|
||
CONTINUE="$(countly check before upgrade db "$VER")" | ||
|
||
if [ "$CONTINUE" != "1" ] && [ "$1" != "combined" ] | ||
then | ||
echo "Database is already up to date with $VER" | ||
read -r -p "Are you sure you want to run this script? [y/N] " response | ||
if [[ "$response" =~ ^([yY][eE][sS]|[yY])$ ]] | ||
then | ||
CONTINUE=1 | ||
fi | ||
fi | ||
|
||
if [ "$CONTINUE" == "1" ] | ||
then | ||
echo "Running database modifications" | ||
DIR="$( cd "$( dirname "${BASH_SOURCE[0]}" )/../.." && pwd )" | ||
CUR="$( cd "$( dirname "${BASH_SOURCE[0]}" )" && pwd )" | ||
|
||
#upgrade plugins | ||
countly plugin upgrade concurrent_users | ||
|
||
#run upgrade scripts | ||
nodejs "$CUR/scripts/cleanup_concurrent.js" | ||
|
||
#call after check | ||
countly check after upgrade db "$VER" | ||
elif [ "$CONTINUE" == "0" ] | ||
then | ||
echo "Database is already upgraded to $VER" | ||
elif [ "$CONTINUE" == "-1" ] | ||
then | ||
echo "Database is upgraded to higher version" | ||
else | ||
echo "Unknown ugprade state: $CONTINUE" | ||
fi |
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 |
---|---|---|
@@ -0,0 +1,7 @@ | ||
#!/bin/bash | ||
|
||
echo "Running filesystem modifications" | ||
|
||
VER="20.11.1" | ||
|
||
countly check after upgrade fs "$VER" |
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 |
---|---|---|
@@ -0,0 +1,62 @@ | ||
var pluginManager = require("../../../../plugins/pluginManager.js"), | ||
async = require('async'); | ||
|
||
console.log("Cleaning up old settings and collections of concurrent_users plugins"); | ||
pluginManager.dbConnection().then((db) => { | ||
|
||
function dropOldCols() { | ||
db.collection('apps').find({}).toArray(function (err, apps) { | ||
if (err) { | ||
console.log("App list couldn't be fetched for concurrent cleanup.", err); | ||
cleanupSettings(); | ||
return; | ||
} | ||
var collectionsToBeDropped = []; | ||
apps.forEach(function(app) { | ||
collectionsToBeDropped.push('concurrent_users' + app._id); | ||
collectionsToBeDropped.push('concurrent_users_new' + app._id); | ||
}); | ||
function dropCol(collection, done){ | ||
db.collection(collection).drop(function(err, resp){ | ||
if (err) { | ||
console.log("Collection (" + collection + ") couldn't be dropped.", err); | ||
} | ||
if (resp === true){ | ||
console.log("Dropped collection '" + collection + "'."); | ||
} | ||
done(); | ||
}); | ||
} | ||
async.forEach(collectionsToBeDropped, dropCol, function(){ | ||
console.log("Collections were dropped."); | ||
cleanupSettings(); | ||
}); | ||
}); | ||
} | ||
|
||
function cleanupSettings() { | ||
db.collection("plugins").updateOne( | ||
{_id: "plugins"}, | ||
{ | ||
$unset: { | ||
"concurrent_users.flush_interval": "", | ||
"concurrent_users.extend_on_session": "", | ||
"concurrent_users.shared_process": "" | ||
} | ||
}, | ||
function(pluginConfigErr) { | ||
if (pluginConfigErr) { | ||
console.log(pluginConfigErr.message); | ||
} | ||
else { | ||
console.log("Settings were cleaned up."); | ||
} | ||
|
||
db.close(); | ||
} | ||
); | ||
} | ||
|
||
dropOldCols(); | ||
|
||
}); |
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
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