diff options
author | Carlo Landmeter <clandmeter@gmail.com> | 2015-10-06 14:59:40 +0200 |
---|---|---|
committer | Carlo Landmeter <clandmeter@gmail.com> | 2015-10-06 14:59:46 +0200 |
commit | 395aa88ab45ba950e67bf840310ef9e59e552f9c (patch) | |
tree | 94b8f74004e66fed7b8e94c2da286adc4ee6208f /testing/emby/emby-migrate | |
parent | c91fded86805deca34a587adfc0766729537ad5c (diff) | |
download | aports-395aa88ab45ba950e67bf840310ef9e59e552f9c.tar.bz2 aports-395aa88ab45ba950e67bf840310ef9e59e552f9c.tar.xz |
testing/emby: new aport
Diffstat (limited to 'testing/emby/emby-migrate')
-rw-r--r-- | testing/emby/emby-migrate | 56 |
1 files changed, 56 insertions, 0 deletions
diff --git a/testing/emby/emby-migrate b/testing/emby/emby-migrate new file mode 100644 index 0000000000..a74429f23e --- /dev/null +++ b/testing/emby/emby-migrate @@ -0,0 +1,56 @@ +#!/bin/sh + +USER='emby' +GROUP='emby' + +usage() { + echo 'Usage: emby-migrate-database {-u user} {-g group} old_path_full new_path_full' + echo 'Default user: emby' + echo 'Default group: emby' +} + +migrate() { + if [[ $1 && $2 ]]; then + if [[ -f $1/data/library.db ]]; then + if [[ ! -e $2 ]]; then + mkdir -p $2 + fi + if [[ -d $2 ]]; then + if [[ -z $(ls $2) ]]; then + cp -r $1/* $2/ + sqlite3 $2/data/library.db "UPDATE TypedBaseItems SET data = CAST(REPLACE(CAST(data AS TEXT), '$1', '$2') AS BLOB);" + chown $USER:$GROUP -R $2 + echo "Migration complete. You can now delete $1." + else + echo "$2 is not empty. Aborting." + fi + else + echo "$2 is not a directory. Aborting." + fi + else + echo "$1 does not contain an emby database. Aborting." + fi + else + usage + fi +} + +if [[ $1 == '--help' ]]; then + usage +else + while getopts 'u:g:' opt; do + case $opt in + u) + USER=$OPTARG + ;; + g) + GROUP=$OPTARG + ;; + \?) + usage + ;; + esac + done + shift $((OPTIND-1)) + migrate +fi |