Made configuration directory static

Moved header variables to new file
Started sanitizing variable references
This commit is contained in:
Jon-William Lewis
2015-06-10 00:23:33 -05:00
parent 21b457c38c
commit 9334f3ba45
8 changed files with 51 additions and 95 deletions

45
sns.sh
View File

@@ -1,43 +1,24 @@
#!/bin/bash
#==========================================================
# Simple Note System, v2.0a4
# $PROD_STR, $VER_STR
# Copyright 2014, Xenese Labs/Sicron-Perion XNF
#==========================================================
PROD_STR="Simple Note System"
VER_STR="v2.0a4"
VER_STR="v2.0a5"
ROOTDIR=$HOME/.config/sns
BASEDIR="$ROOTDIR"/notes
CONFIGURATION="$ROOTDIR/sns.conf"
# Section: Functions
function init_default_config() {
if [ -z "$ROOTDIR" ]; then
ROOTDIR=$HOME/.sns
fi
if [ -z "$BASEDIR" ]; then
BASEDIR=$ROOTDIR/notes
fi
if [ -z "$EXT" ]; then
EXT=note
fi
if [ -z "$EDITOR" ]; then
EDITOR=vim
fi
if [ -z "$ENC_KEY" ]; then
ENCRYPTION="FALSE"
else
ENCRYPTION="TRUE"
fi
}
function w_conf {
cat > $HOME/.sns/sns.conf << EOF
if [ ! -r "$ROOTDIR" ]; then mkdir -p $ROOTDIR; fi
cat > "$CONFIGURATION" << EOF
#==========================================================
# Simple Note System Config, v2.0a1
# Simple Note System Config, v2.0a5
# Copyright 2014, Xenese Labs/Sicron-Perion XNF
#==========================================================
#Directory where notes will be stored
ROOTDIR=$HOME/.sns
BASEDIR=$ROOTDIR/notes
#File extension to use (for listing notes)
EXT=note
@@ -52,7 +33,7 @@ ENCRYPTION="FALSE"
ENC_KEY=""
EOF
chmod 600 $ROOTDIR/sns.conf
chmod 600 "$CONFIGURATION"
}
function pause {
read -p " Press [Enter] to continue."
@@ -219,13 +200,15 @@ function list(){
fi
}
# End Section: Functions
#==============================================================================
# Section: Configuration
#==============================================================================
if [ -r $HOME/.sns/sns.conf ]; then
source $HOME/.sns/sns.conf
if [ -r "$CONFIGURATION" ]; then
source "$CONFIGURATION"
else
init_default_config
w_conf
source "$CONFIGURATION"
fi
if [ "$ENCRYPTION" == "TRUE" ]; then