• The message base moving script

    From Va7aqd@VERT/VA7AQDS to mortifis on Tuesday, May 21, 2019 23:03:32
    Hey Mortifis,

    Here's what the message base moving script came down to:

    -----

    #!/bin/bash

    # Move message base files after their internal prefix and/or suffix changes
    # Version 0.1

    # ie: When moving from group A to group B you may have files in
    # data/subs/ that begin with groupA-sub and have file extensions of
    # .ini, .sch, .sda, .sdt, .sha, .shd, .sid, .hash, .list.sub, .list.ptr, .smm
    # and you may need them to all wind up as
    # groupB-sub.sda, groupB-sub.sdt, etc.
    #
    # So, since scfg doesn't manage this when you move bases, this script exists.
    #
    # Usage: myscripts/mv-msgbase.sh path1/prefix+suffix1 path2/prefix+suffix2
    #
    # Do this without file extensions after suffix1 and 2

    # If fewer than 2 arguments, echo syntax and die.

    if [ $# -ne 2 ]; then
    echo "2 arguments required. Run this script as:"
    echo "myscripts/mv-msgbase.sh path1/prefix+suffix1 path2/prefix+suffix2"
    exit 1
    fi

    # First, test that none of the destination filenames exist - if one does, abort.
    for EXT in ini sch sda sdt sha shd sid hash list.sub list.ptr smm
    do
    if [ -f $2.$EXT ]; then
    echo $2"."$EXT" exists already - aborting!"
    exit 2
    fi
    done

    # Well, that passed, so let's actually move them files after backing them up. number=$RANDOM

    for EXT in ini sch sda sdt sha shd sid hash list.sub list.ptr smm
    do
    if [ -f $1.$EXT ]; then
    tar rf /tmp/msgmv-backup-$number.tar $1.$EXT
    mv $1.$EXT $2.$EXT
    fi
    done

    echo "Backup file is: /tmp/msgmv-backup-$number.tar"

    --------

    HTH!

    ---
    þ Synchronet þ VA7AQD's Tavern - bbs.isurf.ca