Make variables in config.sh readonly

pull/58/head
Dan Puttick 2017-08-09 17:29:09 -04:00
parent b6564d7298
commit 9dd6b2c460
4 changed files with 24 additions and 26 deletions

View File

@ -1,29 +1,30 @@
USERNAME="kitten" #!/bin/bash
ID=`/usr/bin/id -u`
set -eu
readonly USERNAME="kitten"
readonly ID=$(/usr/bin/id -u)
# Paths used in multiple scripts # Paths used in multiple scripts
SRC="src" readonly SRC="src"
DEV_SRC="/dev/source_key" readonly DEV_SRC="/dev/source_key"
SRC_MNT="/media/src" readonly SRC_MNT="/media/src"
DST="dst" readonly DST="dst"
DEV_DST="/dev/dest_key" readonly DEV_DST="/dev/dest_key"
DST_MNT="/media/dst" readonly DST_MNT="/media/dst"
TEMP="${DST_MNT}/temp"
ZIPTEMP="${DST_MNT}/ziptemp"
LOGS="${DST_MNT}/logs"
DEBUG_LOG="/tmp/groomer_debug_log.txt"
MUSIC="/opt/midi/"
readonly TEMP="${DST_MNT}/temp"
readonly LOGS_DIR="${DST_MNT}/logs"
readonly DEBUG_LOG="/tmp/groomer_debug_log.txt"
readonly MUSIC_DIR="/opt/midi/"
# Commands # Commands
SYNC="/bin/sync" readonly SYNC="/bin/sync"
TIMIDITY="/usr/bin/timidity" readonly TIMIDITY="/usr/bin/timidity"
MOUNT="/bin/mount" readonly MOUNT="/bin/mount"
PMOUNT="/usr/bin/pmount -A -s" readonly PMOUNT="/usr/bin/pmount -A -s"
PUMOUNT="/usr/bin/pumount" readonly PUMOUNT="/usr/bin/pumount"
# Config flags # Config flags
DEBUG=false readonly DEBUG=false

View File

@ -22,7 +22,6 @@ clean(){
# Remove temporary files from destination key # Remove temporary files from destination key
rm -rf ${TEMP} rm -rf ${TEMP}
rm -rf ${ZIPTEMP}
} }
trap clean EXIT TERM INT trap clean EXIT TERM INT
@ -57,12 +56,12 @@ do
echo "GROOMER: ${partition} mounted at /media/${SRC}" echo "GROOMER: ${partition} mounted at /media/${SRC}"
# Put the filenames from the current partition in a logfile # Put the filenames from the current partition in a logfile
find "/media/${SRC}" -fls "${LOGS}/contents_partition_${PARTCOUNT}.txt" find "/media/${SRC}" -fls "${LOGS_DIR}/contents_partition_${PARTCOUNT}.txt"
# Create a directory on ${DST} named PARTION_$PARTCOUNT # Create a directory on ${DST} named PARTION_$PARTCOUNT
target_dir="/media/${DST}/FROM_PARTITION_${PARTCOUNT}" target_dir="/media/${DST}/FROM_PARTITION_${PARTCOUNT}"
mkdir -p "${target_dir}" mkdir -p "${target_dir}"
LOGFILE="${LOGS}/processing_log.txt" LOGFILE="${LOGS_DIR}/processing_log.txt"
# Run the current partition through filecheck.py # Run the current partition through filecheck.py
echo "==== Starting processing of /media/${SRC} to ${target_dir}. ====" >> ${LOGFILE} echo "==== Starting processing of /media/${SRC} to ${target_dir}. ====" >> ${LOGFILE}

View File

@ -69,10 +69,8 @@ else
# Prepare temp dirs and make sure they're empty if they already exist # Prepare temp dirs and make sure they're empty if they already exist
mkdir -p "${TEMP}" mkdir -p "${TEMP}"
mkdir -p "${ZIPTEMP}"
mkdir -p "${LOGS}" mkdir -p "${LOGS}"
rm -rf "${TEMP}/"* rm -rf "${TEMP}/"*
rm -rf "${ZIPTEMP}/"*
rm -rf "${LOGS}/"* rm -rf "${LOGS}/"*
fi fi

View File

@ -14,7 +14,7 @@ trap killed EXIT TERM INT
# Force output on analog # Force output on analog
amixer cset numid=3 1 amixer cset numid=3 1
files=(${MUSIC}*) files=(${MUSIC_DIR}*)
while true; do while true; do
# -id flags set interface to "dumb" and -qq silences most/all terminal output # -id flags set interface to "dumb" and -qq silences most/all terminal output