Made configuration directory static
Moved header variables to new file Started sanitizing variable references
This commit is contained in:
49
build.sh
49
build.sh
@@ -1,37 +1,20 @@
|
|||||||
S=sns.sh
|
S=sns.sh
|
||||||
|
|
||||||
PROD_STR="Simple Note System"
|
cat header.sh > "$S"
|
||||||
VER_STR=v2.0a5
|
echo -e "\n# Section: Functions" >> "$S"
|
||||||
|
cat ./src/includes/w_conf.sns.sh >> "$S"
|
||||||
cat > $S << EOF
|
cat ./src/includes/pause.sns.sh >> "$S"
|
||||||
#!/bin/bash
|
cat ./src/includes/help.sns.sh >> "$S"
|
||||||
#==========================================================
|
cat ./src/includes/p_header.sh >> "$S"
|
||||||
# $PROD_STR, $VER_STR
|
cat ./src/includes/libencryption.sh >> "$S"
|
||||||
# Copyright 2014, Xenese Labs/Sicron-Perion XNF
|
cat ./src/includes/create.sns.sh >> "$S"
|
||||||
#==========================================================
|
cat ./src/includes/delete.sns.sh >> "$S"
|
||||||
|
cat ./src/includes/edit.sns.sh >> "$S"
|
||||||
PROD_STR="$PROD_STR"
|
cat ./src/includes/print.sns.sh >> "$S"
|
||||||
VER_STR="$VER_STR"
|
cat ./src/includes/list.sns.sh >> "$S"
|
||||||
|
echo -e "# End Section: Functions\n" >> "$S"
|
||||||
EOF
|
cat ./src/main/stage1.sns.sh >> "$S"
|
||||||
|
cat ./src/main/stage2.sns.sh >> "$S"
|
||||||
echo "# Section: Functions" >> $S
|
cat ./src/main/stage3.sns.sh >> "$S"
|
||||||
cat ./src/includes/defaults.sh >> $S
|
|
||||||
cat ./src/includes/w_conf.sns.sh >> $S
|
|
||||||
cat ./src/includes/pause.sns.sh >> $S
|
|
||||||
cat ./src/includes/help.sns.sh >> $S
|
|
||||||
cat ./src/includes/p_header.sh >> $S
|
|
||||||
cat ./src/includes/libencryption.sh >> $S
|
|
||||||
cat ./src/includes/create.sns.sh >> $S
|
|
||||||
cat ./src/includes/delete.sns.sh >> $S
|
|
||||||
cat ./src/includes/edit.sns.sh >> $S
|
|
||||||
cat ./src/includes/print.sns.sh >> $S
|
|
||||||
cat ./src/includes/list.sns.sh >> $S
|
|
||||||
echo "# End Section: Functions" >> $S
|
|
||||||
cat ./src/main/stage1.sns.sh >> $S
|
|
||||||
cat ./src/main/stage2.sns.sh >> $S
|
|
||||||
cat ./src/main/stage3.sns.sh >> $S
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
exit
|
exit
|
||||||
|
|||||||
11
header.sh
Normal file
11
header.sh
Normal file
@@ -0,0 +1,11 @@
|
|||||||
|
#!/bin/bash
|
||||||
|
#==========================================================
|
||||||
|
# $PROD_STR, $VER_STR
|
||||||
|
# Copyright 2014, Xenese Labs/Sicron-Perion XNF
|
||||||
|
#==========================================================
|
||||||
|
|
||||||
|
PROD_STR="Simple Note System"
|
||||||
|
VER_STR="v2.0a5"
|
||||||
|
ROOTDIR=$HOME/.config/sns
|
||||||
|
BASEDIR="$ROOTDIR"/notes
|
||||||
|
CONFIGURATION="$ROOTDIR/sns.conf"
|
||||||
45
sns.sh
45
sns.sh
@@ -1,43 +1,24 @@
|
|||||||
#!/bin/bash
|
#!/bin/bash
|
||||||
#==========================================================
|
#==========================================================
|
||||||
# Simple Note System, v2.0a4
|
# $PROD_STR, $VER_STR
|
||||||
# Copyright 2014, Xenese Labs/Sicron-Perion XNF
|
# Copyright 2014, Xenese Labs/Sicron-Perion XNF
|
||||||
#==========================================================
|
#==========================================================
|
||||||
|
|
||||||
PROD_STR="Simple Note System"
|
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
|
# 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 {
|
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
|
# 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)
|
#File extension to use (for listing notes)
|
||||||
EXT=note
|
EXT=note
|
||||||
|
|
||||||
@@ -52,7 +33,7 @@ ENCRYPTION="FALSE"
|
|||||||
ENC_KEY=""
|
ENC_KEY=""
|
||||||
EOF
|
EOF
|
||||||
|
|
||||||
chmod 600 $ROOTDIR/sns.conf
|
chmod 600 "$CONFIGURATION"
|
||||||
}
|
}
|
||||||
function pause {
|
function pause {
|
||||||
read -p " Press [Enter] to continue."
|
read -p " Press [Enter] to continue."
|
||||||
@@ -219,13 +200,15 @@ function list(){
|
|||||||
fi
|
fi
|
||||||
}
|
}
|
||||||
# End Section: Functions
|
# End Section: Functions
|
||||||
|
|
||||||
#==============================================================================
|
#==============================================================================
|
||||||
# Section: Configuration
|
# Section: Configuration
|
||||||
#==============================================================================
|
#==============================================================================
|
||||||
if [ -r $HOME/.sns/sns.conf ]; then
|
if [ -r "$CONFIGURATION" ]; then
|
||||||
source $HOME/.sns/sns.conf
|
source "$CONFIGURATION"
|
||||||
else
|
else
|
||||||
init_default_config
|
w_conf
|
||||||
|
source "$CONFIGURATION"
|
||||||
fi
|
fi
|
||||||
|
|
||||||
if [ "$ENCRYPTION" == "TRUE" ]; then
|
if [ "$ENCRYPTION" == "TRUE" ]; then
|
||||||
|
|||||||
@@ -11,7 +11,6 @@
|
|||||||
5D22D6A31AFC4F5A0036DC52 /* delete.sns.sh */ = {isa = PBXFileReference; lastKnownFileType = text.script.sh; path = delete.sns.sh; sourceTree = "<group>"; };
|
5D22D6A31AFC4F5A0036DC52 /* delete.sns.sh */ = {isa = PBXFileReference; lastKnownFileType = text.script.sh; path = delete.sns.sh; sourceTree = "<group>"; };
|
||||||
5D22D6A41AFC4F5A0036DC52 /* edit.sns.sh */ = {isa = PBXFileReference; lastKnownFileType = text.script.sh; path = edit.sns.sh; sourceTree = "<group>"; };
|
5D22D6A41AFC4F5A0036DC52 /* edit.sns.sh */ = {isa = PBXFileReference; lastKnownFileType = text.script.sh; path = edit.sns.sh; sourceTree = "<group>"; };
|
||||||
5D22D6A51AFC4F5A0036DC52 /* help.sns.sh */ = {isa = PBXFileReference; lastKnownFileType = text.script.sh; path = help.sns.sh; sourceTree = "<group>"; };
|
5D22D6A51AFC4F5A0036DC52 /* help.sns.sh */ = {isa = PBXFileReference; lastKnownFileType = text.script.sh; path = help.sns.sh; sourceTree = "<group>"; };
|
||||||
5D22D6A61AFC4F5A0036DC52 /* defaults.sh */ = {isa = PBXFileReference; lastKnownFileType = text.script.sh; path = defaults.sh; sourceTree = "<group>"; };
|
|
||||||
5D22D6A71AFC4F5A0036DC52 /* list.sns.sh */ = {isa = PBXFileReference; lastKnownFileType = text.script.sh; path = list.sns.sh; sourceTree = "<group>"; };
|
5D22D6A71AFC4F5A0036DC52 /* list.sns.sh */ = {isa = PBXFileReference; lastKnownFileType = text.script.sh; path = list.sns.sh; sourceTree = "<group>"; };
|
||||||
5D22D6A81AFC4F5A0036DC52 /* p_header.sh */ = {isa = PBXFileReference; lastKnownFileType = text.script.sh; path = p_header.sh; sourceTree = "<group>"; };
|
5D22D6A81AFC4F5A0036DC52 /* p_header.sh */ = {isa = PBXFileReference; lastKnownFileType = text.script.sh; path = p_header.sh; sourceTree = "<group>"; };
|
||||||
5D22D6A91AFC4F5A0036DC52 /* pause.sns.sh */ = {isa = PBXFileReference; lastKnownFileType = text.script.sh; path = pause.sns.sh; sourceTree = "<group>"; };
|
5D22D6A91AFC4F5A0036DC52 /* pause.sns.sh */ = {isa = PBXFileReference; lastKnownFileType = text.script.sh; path = pause.sns.sh; sourceTree = "<group>"; };
|
||||||
@@ -22,6 +21,7 @@
|
|||||||
5D22D6AF1AFC4F5A0036DC52 /* stage3.sns.sh */ = {isa = PBXFileReference; lastKnownFileType = text.script.sh; path = stage3.sns.sh; sourceTree = "<group>"; };
|
5D22D6AF1AFC4F5A0036DC52 /* stage3.sns.sh */ = {isa = PBXFileReference; lastKnownFileType = text.script.sh; path = stage3.sns.sh; sourceTree = "<group>"; };
|
||||||
5D22D6B01AFC5B100036DC52 /* libencryption.sh */ = {isa = PBXFileReference; lastKnownFileType = text.script.sh; path = libencryption.sh; sourceTree = "<group>"; };
|
5D22D6B01AFC5B100036DC52 /* libencryption.sh */ = {isa = PBXFileReference; lastKnownFileType = text.script.sh; path = libencryption.sh; sourceTree = "<group>"; };
|
||||||
5D7E611F1AB74D33001D49B9 /* build.sh */ = {isa = PBXFileReference; lastKnownFileType = text.script.sh; path = build.sh; sourceTree = "<group>"; };
|
5D7E611F1AB74D33001D49B9 /* build.sh */ = {isa = PBXFileReference; lastKnownFileType = text.script.sh; path = build.sh; sourceTree = "<group>"; };
|
||||||
|
5D7E91FB1B27FB620030B30D /* header.sh */ = {isa = PBXFileReference; lastKnownFileType = text.script.sh; path = header.sh; sourceTree = "<group>"; };
|
||||||
5DE839831AB9DACE006CB4F6 /* sns.sh */ = {isa = PBXFileReference; lastKnownFileType = text.script.sh; path = sns.sh; sourceTree = "<group>"; };
|
5DE839831AB9DACE006CB4F6 /* sns.sh */ = {isa = PBXFileReference; lastKnownFileType = text.script.sh; path = sns.sh; sourceTree = "<group>"; };
|
||||||
5DE839881ABA04DD006CB4F6 /* errors.ref */ = {isa = PBXFileReference; lastKnownFileType = text; path = errors.ref; sourceTree = "<group>"; };
|
5DE839881ABA04DD006CB4F6 /* errors.ref */ = {isa = PBXFileReference; lastKnownFileType = text; path = errors.ref; sourceTree = "<group>"; };
|
||||||
/* End PBXFileReference section */
|
/* End PBXFileReference section */
|
||||||
@@ -43,7 +43,6 @@
|
|||||||
5D22D6A31AFC4F5A0036DC52 /* delete.sns.sh */,
|
5D22D6A31AFC4F5A0036DC52 /* delete.sns.sh */,
|
||||||
5D22D6A41AFC4F5A0036DC52 /* edit.sns.sh */,
|
5D22D6A41AFC4F5A0036DC52 /* edit.sns.sh */,
|
||||||
5D22D6A51AFC4F5A0036DC52 /* help.sns.sh */,
|
5D22D6A51AFC4F5A0036DC52 /* help.sns.sh */,
|
||||||
5D22D6A61AFC4F5A0036DC52 /* defaults.sh */,
|
|
||||||
5D22D6A71AFC4F5A0036DC52 /* list.sns.sh */,
|
5D22D6A71AFC4F5A0036DC52 /* list.sns.sh */,
|
||||||
5D22D6A81AFC4F5A0036DC52 /* p_header.sh */,
|
5D22D6A81AFC4F5A0036DC52 /* p_header.sh */,
|
||||||
5D22D6A91AFC4F5A0036DC52 /* pause.sns.sh */,
|
5D22D6A91AFC4F5A0036DC52 /* pause.sns.sh */,
|
||||||
@@ -71,6 +70,7 @@
|
|||||||
5DE839881ABA04DD006CB4F6 /* errors.ref */,
|
5DE839881ABA04DD006CB4F6 /* errors.ref */,
|
||||||
5DE839831AB9DACE006CB4F6 /* sns.sh */,
|
5DE839831AB9DACE006CB4F6 /* sns.sh */,
|
||||||
5D7E611F1AB74D33001D49B9 /* build.sh */,
|
5D7E611F1AB74D33001D49B9 /* build.sh */,
|
||||||
|
5D7E91FB1B27FB620030B30D /* header.sh */,
|
||||||
);
|
);
|
||||||
sourceTree = "<group>";
|
sourceTree = "<group>";
|
||||||
};
|
};
|
||||||
|
|||||||
@@ -1,19 +0,0 @@
|
|||||||
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
|
|
||||||
}
|
|
||||||
@@ -13,6 +13,6 @@ function help {
|
|||||||
echo " -h | --help : Display this message"
|
echo " -h | --help : Display this message"
|
||||||
echo " -p | --print : Print note to console"
|
echo " -p | --print : Print note to console"
|
||||||
echo " -l | --list : List all notes in NOTEBOOK"
|
echo " -l | --list : List all notes in NOTEBOOK"
|
||||||
echo " -w | --wconf : Write default configuration to ~/.sns (useful for Encryption)"
|
echo " -w | --wconf : Rewrite default configuration"
|
||||||
echo ""
|
echo ""
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -1,14 +1,11 @@
|
|||||||
function w_conf {
|
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.0a5
|
# Simple Note System Config, v2.0a5
|
||||||
# Copyright 2014, Xenese Labs/Sicron-Perion XNF
|
# 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)
|
#File extension to use (for listing notes)
|
||||||
EXT=note
|
EXT=note
|
||||||
|
|
||||||
@@ -23,5 +20,5 @@ ENCRYPTION="FALSE"
|
|||||||
ENC_KEY=""
|
ENC_KEY=""
|
||||||
EOF
|
EOF
|
||||||
|
|
||||||
chmod 600 $ROOTDIR/sns.conf
|
chmod 600 "$CONFIGURATION"
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -1,10 +1,11 @@
|
|||||||
#==============================================================================
|
#==============================================================================
|
||||||
# Section: Configuration
|
# Section: Configuration
|
||||||
#==============================================================================
|
#==============================================================================
|
||||||
if [ -r $HOME/.sns/sns.conf ]; then
|
if [ -r "$CONFIGURATION" ]; then
|
||||||
source $HOME/.sns/sns.conf
|
source "$CONFIGURATION"
|
||||||
else
|
else
|
||||||
init_default_config
|
w_conf
|
||||||
|
source "$CONFIGURATION"
|
||||||
fi
|
fi
|
||||||
|
|
||||||
if [ "$ENCRYPTION" == "TRUE" ]; then
|
if [ "$ENCRYPTION" == "TRUE" ]; then
|
||||||
|
|||||||
Reference in New Issue
Block a user