Megatest

unlock_db.sh at [8cb9718987]
Login

File utils/unlock_db.sh artifact c822e4d964 part of check-in 8cb9718987


#!/bin/bash

#  Copyright 2006-2017, Matthew Welland.
# 
# This file is part of Megatest.
# 
#     Megatest is free software: you can redistribute it and/or modify
#     it under the terms of the GNU General Public License as published by
#     the Free Software Foundation, either version 3 of the License, or
#     (at your option) any later version.
# 
#     Megatest is distributed in the hope that it will be useful,
#     but WITHOUT ANY WARRANTY; without even the implied warranty of
#     MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
#     GNU General Public License for more details.
# 
#     You should have received a copy of the GNU General Public License
#     along with Megatest.  If not, see <http://www.gnu.org/licenses/>.

## Enh :
# 1. if /tmp/repo exists, delte it or name it something else
# 2. compare the repo is successfully created

## Usage :
# unlock_db.sh <database-name/complete path>

function unlock_db () {
    repo=$1
    echo $repo
    ls -lrt $repo
    cp $repo /tmp/${USER}_repo.tmp
    ls -lrt /tmp/${USER}_repo.tmp
    ## Eventually compare the sizes of 2 repos
    cmd=$(rm -r $repo && sqlite3 /tmp/${USER}_repo.tmp .dump | sqlite3 $repo)
    echo $cmd
    ls -lrt $repo
    chmod g+w $repo
}

#======================================================================
# T H E   M A I N   H A N D L E R   A N D   P R O C E S S I N G 
#======================================================================

unlock_db $1