Made configuration directory static
Moved header variables to new file Started sanitizing variable references
This commit is contained in:
45
sns.sh
45
sns.sh
@@ -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
|
||||
|
||||
Reference in New Issue
Block a user