Skip to content
Snippets Groups Projects
Commit e500a0de authored by Bob Mottram's avatar Bob Mottram
Browse files

Remove mongodb when appropriate

parent 89b7087c
No related branches found
No related tags found
No related merge requests found
......@@ -256,6 +256,9 @@ function remove_smilodon {
function_check drop_database_mongodb
drop_database_mongodb smilodon
function_check remove_mongodb
remove_mongodb smilodon
remove_completion_param install_smilodon
sed -i '/smilodon_/d' $COMPLETION_FILE
}
......@@ -289,7 +292,7 @@ function install_smilodon {
useradd -c "Smilodon system account" -d $SMILODON_PATH -m -r -g smilodon smilodon
function_check install_mongodb
install_mongodb
install_mongodb smilodon
smilodon_create_database
......
......@@ -30,6 +30,7 @@
# Set this when calling backup and restore commands
USE_MONGODB=
MONGODB_APPS_FILE=/root/.mongodbapps
function store_original_mongodb_password {
if [ ! -f /root/.mongodboriginal ]; then
......@@ -49,6 +50,8 @@ function get_mongodb_password {
}
function install_mongodb {
app_name=$1
if [[ "$(uname -a)" == *"armv7"* ]]; then
echo $'mongodb package is not available for arm 7 architecture'
exit 7356272
......@@ -81,9 +84,41 @@ function install_mongodb {
exit 78352
fi
if [ $app_name ]; then
if ! grep -q "$app_name" $MONGODB_APPS_FILE; then
echo "$app_name" >> $MONGODB_APPS_FILE
fi
fi
mark_completed $FUNCNAME
}
function remove_mongodb {
app_name=$1
if [ ! $app_name ]; then
return
fi
removemongo=
if [ -f $MONGODB_APPS_FILE ]; then
sed -i "/$app_name/d" $MONGODB_APPS_FILE
mongoapps=$(cat $MONGODB_APPS_FILE)
if [ ${#mongoapps} -lt 3 ]; then
removemongo=1
fi
else
removemongo=1
fi
if [ $removemongo ]; then
apt-get -yq remove mongodb mongo-tools
if [ -d /var/lib/mongodb ]; then
rm -rf /var/lib/mongodb
fi
fi
}
function add_mongodb_user {
mongodb_username=$1
mongodb_password=$2
......
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment