dd3d8f4abe
Fixed #60 : Hash error when ReturnValue is a list of list Fixed #59 : Implement smart_get() Fixed #58 : SheerkaPromptCompleter: Cannot parse concept token Fixed #57 : SheerkaPrompt: Add concept autocompletion Fixed #56 : automatically backup command Fixed #54 : I can record execution status Fixed #53 : ConceptManager: modify_concept fails
61 lines
1.3 KiB
Bash
Executable File
61 lines
1.3 KiB
Bash
Executable File
#!/bin/bash
|
|
set -e
|
|
|
|
BASEDIR=$(dirname "$0")
|
|
|
|
list_available() {
|
|
available=$(find "$SHEERKA_BACKUP_FOLDER"/*.sb -type f -printf "%f\n" | sed 's/\.[^.]*$//') 2> /dev/null
|
|
|
|
if [ "$available" = "" ]; then
|
|
echo "Error. No available backup !" >&2
|
|
else
|
|
echo "Available backups are:"
|
|
for backup in ${available}; do
|
|
echo " ${backup}";
|
|
done
|
|
fi
|
|
|
|
}
|
|
|
|
usage() {
|
|
echo "Usage: $0 <backup>"
|
|
echo "Creates a fresh install of Sheerka, using the provided backup file."
|
|
list_available
|
|
exit 0
|
|
}
|
|
|
|
if [ "$#" -eq 0 ] || [ "$1" = "-h" ]; then
|
|
usage
|
|
fi
|
|
|
|
|
|
if [ -z "${SHEERKA_BACKUP_FOLDER+x}" ]; then
|
|
echo "SHEERKA_BACKUP_FOLDER is not set !"
|
|
exit 1
|
|
fi
|
|
|
|
|
|
backup_file="$SHEERKA_BACKUP_FOLDER"/"$1".sb
|
|
sheerka_root_folder="$HOME/.sheerka_$1"
|
|
|
|
if ! [ -e "$backup_file" ]; then
|
|
echo "$backup_file not found" >&2
|
|
list_available
|
|
exit 1
|
|
fi
|
|
|
|
echo "Rebuilding $1..."
|
|
|
|
# backup current sheerka
|
|
if [ -e ~/.sheerka ]; then
|
|
rm -rf ~/.sheerka.bak
|
|
mv ~/.sheerka ~/.sheerka.bak
|
|
fi
|
|
|
|
# re-install sheerka, using the requested backup file
|
|
python "$BASEDIR"/../main.py "sheerka.restore('$1')"
|
|
|
|
# create a copy of the freshly installed sheerka, for future reset
|
|
rm -rf "$sheerka_root_folder"
|
|
cp -R ~/.sheerka "$sheerka_root_folder"
|