Variable name reworking; laid foundation for GPG encryption (instead of OpenSSL)

This commit is contained in:
Jon-William Lewis
2016-01-25 17:20:05 -06:00
parent 908b93242c
commit 6a21731082
12 changed files with 180 additions and 102 deletions

View File

@@ -1,20 +1,29 @@
S=sns.sh S=sns.sh
bash header.sh > "$S" bash header.sh > "$S"
echo -e "\n# Section: Functions" >> "$S" echo -e "\n# Section: Functions" >> "$S"
cat ./src/includes/w_conf.sns.sh >> "$S" cat ./src/includes/create_sns_root.sns.sh >> "$S"
cat ./src/includes/pause.sns.sh >> "$S" cat ./src/includes/pause.sns.sh >> "$S"
cat ./src/includes/help.sns.sh >> "$S" cat ./src/includes/help.sns.sh >> "$S"
cat ./src/includes/p_header.sh >> "$S" cat ./src/includes/p_header.sh >> "$S"
cat ./src/includes/libencryption.sh >> "$S" cat ./src/includes/libencryption.sh >> "$S"
cat ./src/includes/create.sns.sh >> "$S" cat ./src/includes/create.sns.sh >> "$S"
cat ./src/includes/delete.sns.sh >> "$S" cat ./src/includes/delete.sns.sh >> "$S"
cat ./src/includes/edit.sns.sh >> "$S" cat ./src/includes/edit.sns.sh >> "$S"
cat ./src/includes/print.sns.sh >> "$S" cat ./src/includes/print.sns.sh >> "$S"
cat ./src/includes/list.sns.sh >> "$S" cat ./src/includes/list.sns.sh >> "$S"
echo -e "# End Section: Functions\n" >> "$S" printf "%s\n\n\n\n" "# End Section: Functions" >> "$S"
cat ./src/main/stage1.sns.sh >> "$S"
cat ./src/main/stage2.sns.sh >> "$S" printf "\n" >> "$S"
cat ./src/main/stage3.sns.sh >> "$S" printf "%s\n" "###############################################################################" >> "$S"
printf "%s\n" "#==============================================================================" >> "$S"
printf "%s\n" "# Begin Main Program" >> "$S"
printf "%s\n" "#==============================================================================" >> "$S"
printf "%s\n" "###############################################################################" >> "$S"
printf "\n" >> "$S"
cat ./src/main/stage1.sns.sh >> "$S"
cat ./src/main/stage2.sns.sh >> "$S"
cat ./src/main/stage3.sns.sh >> "$S"
exit exit

View File

@@ -13,9 +13,10 @@ cat << EOF
if [ -z "\$HOME" ]; then HOME=/home/"\$(whoami)"; fi if [ -z "\$HOME" ]; then HOME=/home/"\$(whoami)"; fi
PROD_STR="$PROD_STR" PROD_STR="$PROD_STR"
VER_STR="$VER_STR" readonly VER_STR="$VER_STR"
ROOTDIR="\$HOME"/.config/sns readonly ROOT_DIR="\$HOME"/.config/xenlabs/sns
BASEDIR="\$ROOTDIR"/notes readonly BASE_DIR="\$ROOT_DIR"/notes
CONFIGURATION="\$ROOTDIR/sns.conf" readonly TMP_DIR="\$ROOT_DIR"/tmp
readonly CONFIG_FILE="\$ROOT_DIR/sns.conf"
EOF EOF

125
sns.sh
View File

@@ -4,19 +4,24 @@
# Copyright 2014, Xenese Labs/Sicron-Perion XNF # Copyright 2014, Xenese Labs/Sicron-Perion XNF
#========================================================== #==========================================================
if [ -z "/Users/xilmwa" ]; then HOME=/home/"$(whoami)"; fi if [ -z "$HOME" ]; then HOME=/home/"$(whoami)"; fi
PROD_STR="Simple Note System" PROD_STR="Simple Note System"
VER_STR="v2.0a5" readonly VER_STR="v2.0a5"
ROOTDIR="$HOME"/.config/sns readonly ROOT_DIR="$HOME"/.config/xenlabs/sns
BASEDIR="$ROOTDIR"/notes readonly BASE_DIR="$ROOT_DIR"/notes
CONFIGURATION="$ROOTDIR/sns.conf" readonly TMP_DIR="$ROOT_DIR"/tmp
readonly CONFIG_FILE="$ROOT_DIR/sns.conf"
# Section: Functions # Section: Functions
function w_conf { function w_conf {
if [ ! -r "$ROOTDIR" ]; then mkdir -p "$ROOTDIR"; fi
cat > "$CONFIGURATION" << EOF if [ ! -r "$ROOT_DIR" ]; then mkdir -p "$ROOT_DIR"; fi
if [ ! -d "$TMP_DIR" ]; then mkdir -p "$TMP_DIR" ; fi
cat > "$CONFIG_FILE" << 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
@@ -27,19 +32,22 @@ EXT=note
#Preferred Editor #Preferred Editor
if [ -z "$EDITOR" ]; then if [ -z "$EDITOR" ]; then
EDITOR=vim echo EDITOR=vim
fi fi
#Encryption #Encryption
#WARNING: ANY PREVIOUSLY UNENCRYPTED NOTES WILL BE LOST #WARNING: ANY PREVIOUSLY UNENCRYPTED NOTES WILL BE LOST
#ENCRYPTION="TRUE"
ENCRYPTION="FALSE" ENCRYPTION="FALSE"
ENC_KEY=""
PUBKEY=""
EOF EOF
chmod 600 "$CONFIGURATION" chmod 600 "$CONFIG_FILE"
} }
function pause { function pause {
read -p " Press [Enter] to continue." read -rp " Press [Enter] to continue."
echo "" echo ""
} }
function help { function help {
@@ -64,19 +72,29 @@ function p_header(){
printf "TITLE: %s\nDATE: %s\n" "$NAME" "$(date)" printf "TITLE: %s\nDATE: %s\n" "$NAME" "$(date)"
} }
function encrypt(){ function encrypt(){
openssl enc -aes-256-cbc -salt -in "$TARGET" -out "$NOTE" -pass pass:"$ENC_KEY" # This function, given a recipient, $PUBKEY; a file to encrypt, $TARGET; and an
# output file, "$NOTE", will encrypt $TARGET to $NOTE against $PUBKEY's private
# GPG key.
gpg -r "$PUBKEY" --encrypt-files "$TARGET" --output "$NOTE"
} }
function decrypt(){ function decrypt(){
TARGET="$ROOTDIR"/tmp/"$RANDOM" # This function, given a recipient, $PUBKEY; a file to decrypt, $TARGET; and an
openssl enc -d -aes-256-cbc -in "$NOTE" -pass pass:"$ENC_KEY" > "$TARGET" # output file, "$NOTE", will decrpyt $TARGET to $NOTE against $PUBKEY's private
# GPG key.
if [ ! -d "$ROOT_DIR"/tmp ]; then mkdir "$ROOT_DIR"/tmp; fi
TARGET="$TMP_DIR/$RANDOM"
gpg -d "$NOTE" > "$TARGET"
} }
function create(){ function create(){
if [ -e "$NOTE" ]; then if [ -e "$NOTE" ]; then
printf "\nERROR: Note already exists\nHint: use -e to edit the note.\n" printf "\nERROR: Note already exists\nHint: use -e to edit the note.\n"
exit exit
else else
mkdir -p "$NOTEDIR" mkdir -p "$NOTE_DIR"
fi fi
if [ -z "$ENCRYPTION" ]; then if [ -z "$ENCRYPTION" ]; then
@@ -119,7 +137,7 @@ else TARGET="$NOTE"; fi
if [ -z "$CREATE" ]; then printf "\nEDIT %s" "$(date)" >> "$TARGET"; fi if [ -z "$CREATE" ]; then printf "\nEDIT %s" "$(date)" >> "$TARGET"; fi
"$EDITOR" "$TARGET" echo "$EDITOR" "$TARGET"
if [ "$ENCRYPTION" == "TRUE" ]; then encrypt; fi if [ "$ENCRYPTION" == "TRUE" ]; then encrypt; fi
@@ -146,13 +164,17 @@ function print(){
fi fi
} }
function list(){ function list(){
if [ -d "$BASEDIR"/"$NOTEBOOK" ]; then if [ -d "$BASE_DIR"/"$NOTEBOOK" ]; then
printf "\nNotes in %s:\n" "$(basename "$NOTEBOOK")" printf "\nNotes in %s:\n" "$(basename "$NOTEBOOK")"
NOTES=( $(find "$BASEDIR"/"$NOTEBOOK" -name "*.$EXT" -print0 | sed s:"$BASEDIR"/"$NOTEBOOK"/: " " :g | sed -e s:".$EXT"::g | tr "/" " ") ) NOTES=(
$(find "$BASE_DIR"/"$NOTEBOOK" -name "*.$EXT" -print0 |\
sed s:"$BASE_DIR"/"$NOTEBOOK"/: " " :g |\
sed -e s:".$EXT"::g | tr "/" " ")
)
let i=0 let i=0
for NOTE in "${NOTES[@]}"; do for NOTE in "${NOTES[@]}"; do
if [ -d "$BASEDIR"/"$NOTEBOOK"/"$NOTE" ]; then if [ -d "$BASE_DIR"/"$NOTEBOOK"/"$NOTE" ]; then
if [ "$LAST_SECTION" != "$NOTE" ]; then if [ "$LAST_SECTION" != "$NOTE" ]; then
printf " Section: %s\n" "$NOTE" printf " Section: %s\n" "$NOTE"
fi fi
@@ -174,33 +196,45 @@ function list(){
} }
# End Section: Functions # End Section: Functions
###############################################################################
#============================================================================== #==============================================================================
# Section: Configuration # Begin Main Program
#============================================================================== #==============================================================================
if [ -r "$CONFIGURATION" ]; then ###############################################################################
source "$CONFIGURATION"
#==============================================================================
# Section: Configuration / Stage 1
#==============================================================================
if [ -r "$CONFIG_FILE" ]; then
source "$CONFIG_FILE"
else else
w_conf create_sns_root
source "$CONFIGURATION" source "$CONFIG_FILE"
fi fi
if [ "$ENCRYPTION" == "TRUE" ]; then if [ "$ENCRYPTION" == "TRUE" ]; then
if [ -z "$ENC_KEY" ]; then if [ -z "$PUBKEY" ]; then
ERR_NO_KEY="TRUE" ERR_NO_KEY="TRUE"
ENCRYPTION="FALSE" ENCRYPTION="FALSE"
fi fi
command -v openssl >/dev/null 2>&1 || { ERR_NO_SSL="TRUE"; ENCRYPTION="FALSE"; }
command -v openssl >/dev/null 2>&1 ||\
{ ERR_NO_SSL="TRUE"; ENCRYPTION="FALSE"; }
fi fi
if [ "$ENCRYPTION" == "TRUE" ]; then if [ "$ENCRYPTION" == "TRUE" ]; then
PROD_STR="Simple Note System (Encryption Enabled)" PROD_STR="Simple Note System (Encryption Enabled)"
EXT="$EXT" EXT="$EXT".gpg
if [ ! -d "$BASEDIR"/tmp ]; then if [ ! -d "$BASE_DIR"/tmp ]; then
mkdir -p "$BASEDIR"/tmp mkdir -p "$BASE_DIR"/tmp
fi fi
fi fi
echo "$PROD_STR, $VER_STR" echo "$PROD_STR, $VER_STR"
if [ -n "$ERR_NO_SSL" ]; then if [ -n "$ERR_NO_SSL" ]; then
echo >&2 " Warning: OpenSSL not installed. Encryption disabled." echo >&2 " Warning: OpenSSL not installed. Encryption disabled."
fi fi
@@ -213,10 +247,10 @@ pause
fi fi
#============================================================================== #==============================================================================
# End Section: Configuration # End Section: Configuration / Stage 1
#============================================================================== #==============================================================================
#============================================================================== #==============================================================================
# Section: Argument Parsing # Section: Argument Parsing / Stage 2
#============================================================================== #==============================================================================
NAME="" NAME=""
@@ -233,7 +267,7 @@ else
elif [ "$ARG" = "-p" ] || [ "$ARG" = "--print" ]; then PRINT="TRUE" elif [ "$ARG" = "-p" ] || [ "$ARG" = "--print" ]; then PRINT="TRUE"
elif [ "$ARG" = "-l" ] || [ "$ARG" = "--list" ]; then LIST="TRUE" elif [ "$ARG" = "-l" ] || [ "$ARG" = "--list" ]; then LIST="TRUE"
elif [ "$ARG" = "-h" ] || [ "$ARG" == "--help" ]; then help; exit 0 elif [ "$ARG" = "-h" ] || [ "$ARG" == "--help" ]; then help; exit 0
elif [ "$ARG" = "-w" ] || [ "$ARG" == "--wconf" ]; then w_conf; exit 0 elif [ "$ARG" = "-w" ] || [ "$ARG" == "--wconf" ]; then create_sns_root; exit 0
else else
if [ -z "$NAME" ] && [ -n "$ARG" ]; then NAME="$ARG" if [ -z "$NAME" ] && [ -n "$ARG" ]; then NAME="$ARG"
elif [ -z "$NOTEBOOK" ] && [ -n "$ARG" ]; then NOTEBOOK="$ARG" elif [ -z "$NOTEBOOK" ] && [ -n "$ARG" ]; then NOTEBOOK="$ARG"
@@ -254,11 +288,11 @@ fi
# that can work without any arguments. # that can work without any arguments.
#============================================================================== #==============================================================================
# End Section: Argument Parsing # End Section: Argument Parsing / Stage 2
#==============================================================================
#==============================================================================
# Section: Actions / Stage 3
#============================================================================== #==============================================================================
# Help requires no arguments, and is exclusive.
if [ -n "$HELP" ]; then help; exit 0; fi
# List only requires a notebook, and is exclusive. # List only requires a notebook, and is exclusive.
if [ -z "$NOTEBOOK" ]; then if [ -z "$NOTEBOOK" ]; then
echo " ERROR: Insufficient arguments:" echo " ERROR: Insufficient arguments:"
@@ -279,11 +313,16 @@ if [ -z "$NAME" ]; then
exit 30 exit 30
fi fi
NOTEDIR="$BASEDIR"/"$NOTEBOOK"/"$SECTION"/ SESSION_ID="$RANDOM"
NOTE="$NOTEDIR""$NAME"."$EXT" NOTE_DIR="$BASE_DIR"/"$NOTEBOOK"/"$SECTION"/
NOTE="$NOTE_DIR""$NAME"."$EXT"
if [ "$ENCRYPTION" == "TRUE" ]; then NOTE="$NOTE".enc; fi if [ "$ENCRYPTION" == "TRUE" ]; then NOTE="$NOTE".enc; fi
if [ "$PRINT" == "TRUE" ]; then print; exit 0; fi if [ "$PRINT" == "TRUE" ]; then print; exit 0; fi
if [ "$DELETE" == "TRUE" ]; then delete; exit 0; fi if [ "$DELETE" == "TRUE" ]; then delete; exit 0; fi
if [ "$CREATE" == "TRUE" ]; then create; fi if [ "$CREATE" == "TRUE" ]; then create; fi
if [ "$EDIT" == "TRUE" ]; then edit; fi if [ "$EDIT" == "TRUE" ]; then edit; fi
#==============================================================================
# End Section: Actions / Stage 3
#==============================================================================

View File

@@ -15,7 +15,7 @@
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>"; };
5D22D6AA1AFC4F5A0036DC52 /* print.sns.sh */ = {isa = PBXFileReference; lastKnownFileType = text.script.sh; path = print.sns.sh; sourceTree = "<group>"; }; 5D22D6AA1AFC4F5A0036DC52 /* print.sns.sh */ = {isa = PBXFileReference; lastKnownFileType = text.script.sh; path = print.sns.sh; sourceTree = "<group>"; };
5D22D6AB1AFC4F5A0036DC52 /* w_conf.sns.sh */ = {isa = PBXFileReference; lastKnownFileType = text.script.sh; path = w_conf.sns.sh; sourceTree = "<group>"; }; 5D22D6AB1AFC4F5A0036DC52 /* create_sns_root.sns.sh */ = {isa = PBXFileReference; lastKnownFileType = text.script.sh; path = create_sns_root.sns.sh; sourceTree = "<group>"; };
5D22D6AD1AFC4F5A0036DC52 /* stage1.sns.sh */ = {isa = PBXFileReference; lastKnownFileType = text.script.sh; path = stage1.sns.sh; sourceTree = "<group>"; }; 5D22D6AD1AFC4F5A0036DC52 /* stage1.sns.sh */ = {isa = PBXFileReference; lastKnownFileType = text.script.sh; path = stage1.sns.sh; sourceTree = "<group>"; };
5D22D6AE1AFC4F5A0036DC52 /* stage2.sns.sh */ = {isa = PBXFileReference; lastKnownFileType = text.script.sh; path = stage2.sns.sh; sourceTree = "<group>"; }; 5D22D6AE1AFC4F5A0036DC52 /* stage2.sns.sh */ = {isa = PBXFileReference; lastKnownFileType = text.script.sh; path = stage2.sns.sh; sourceTree = "<group>"; };
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>"; };
@@ -47,7 +47,7 @@
5D22D6A81AFC4F5A0036DC52 /* p_header.sh */, 5D22D6A81AFC4F5A0036DC52 /* p_header.sh */,
5D22D6A91AFC4F5A0036DC52 /* pause.sns.sh */, 5D22D6A91AFC4F5A0036DC52 /* pause.sns.sh */,
5D22D6AA1AFC4F5A0036DC52 /* print.sns.sh */, 5D22D6AA1AFC4F5A0036DC52 /* print.sns.sh */,
5D22D6AB1AFC4F5A0036DC52 /* w_conf.sns.sh */, 5D22D6AB1AFC4F5A0036DC52 /* create_sns_root.sns.sh */,
5D22D6B01AFC5B100036DC52 /* libencryption.sh */, 5D22D6B01AFC5B100036DC52 /* libencryption.sh */,
); );
path = includes; path = includes;

View File

@@ -3,7 +3,7 @@ function create(){
printf "\nERROR: Note already exists\nHint: use -e to edit the note.\n" printf "\nERROR: Note already exists\nHint: use -e to edit the note.\n"
exit exit
else else
mkdir -p "$NOTEDIR" mkdir -p "$NOTE_DIR"
fi fi
if [ -z "$ENCRYPTION" ]; then if [ -z "$ENCRYPTION" ]; then

View File

@@ -1,6 +1,10 @@
function w_conf { function w_conf {
if [ ! -r "$ROOTDIR" ]; then mkdir -p "$ROOTDIR"; fi
cat > "$CONFIGURATION" << EOF if [ ! -r "$ROOT_DIR" ]; then mkdir -p "$ROOT_DIR"; fi
if [ ! -d "$TMP_DIR" ]; then mkdir -p "$TMP_DIR" ; fi
cat > "$CONFIG_FILE" << 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
@@ -16,9 +20,12 @@ fi
#Encryption #Encryption
#WARNING: ANY PREVIOUSLY UNENCRYPTED NOTES WILL BE LOST #WARNING: ANY PREVIOUSLY UNENCRYPTED NOTES WILL BE LOST
#ENCRYPTION="TRUE"
ENCRYPTION="FALSE" ENCRYPTION="FALSE"
ENC_KEY=""
PUBKEY=""
EOF EOF
chmod 600 "$CONFIGURATION" chmod 600 "$CONFIG_FILE"
} }

View File

@@ -1,8 +1,18 @@
function encrypt(){ function encrypt(){
openssl enc -aes-256-cbc -salt -in "$TARGET" -out "$NOTE" -pass pass:"$ENC_KEY" # This function, given a recipient, $PUBKEY; a file to encrypt, $TARGET; and an
# output file, "$NOTE", will encrypt $TARGET to $NOTE against $PUBKEY's private
# GPG key.
gpg -r "$PUBKEY" --encrypt-files "$TARGET" --output "$NOTE"
} }
function decrypt(){ function decrypt(){
TARGET="$ROOTDIR"/tmp/"$RANDOM" # This function, given a recipient, $PUBKEY; a file to decrypt, $TARGET; and an
openssl enc -d -aes-256-cbc -in "$NOTE" -pass pass:"$ENC_KEY" > "$TARGET" # output file, "$NOTE", will decrpyt $TARGET to $NOTE against $PUBKEY's private
# GPG key.
if [ ! -d "$ROOT_DIR"/tmp ]; then mkdir "$ROOT_DIR"/tmp; fi
TARGET="$TMP_DIR/$RANDOM"
gpg -d "$NOTE" > "$TARGET"
} }

View File

@@ -1,11 +1,15 @@
function list(){ function list(){
if [ -d "$BASEDIR"/"$NOTEBOOK" ]; then if [ -d "$BASE_DIR"/"$NOTEBOOK" ]; then
printf "\nNotes in %s:\n" "$(basename "$NOTEBOOK")" printf "\nNotes in %s:\n" "$(basename "$NOTEBOOK")"
NOTES=( $(find "$BASEDIR"/"$NOTEBOOK" -name "*.$EXT" -print0 | sed s:"$BASEDIR"/"$NOTEBOOK"/: " " :g | sed -e s:".$EXT"::g | tr "/" " ") ) NOTES=(
$(find "$BASE_DIR"/"$NOTEBOOK" -name "*.$EXT" -print0 |\
sed s:"$BASE_DIR"/"$NOTEBOOK"/: " " :g |\
sed -e s:".$EXT"::g | tr "/" " ")
)
let i=0 let i=0
for NOTE in "${NOTES[@]}"; do for NOTE in "${NOTES[@]}"; do
if [ -d "$BASEDIR"/"$NOTEBOOK"/"$NOTE" ]; then if [ -d "$BASE_DIR"/"$NOTEBOOK"/"$NOTE" ]; then
if [ "$LAST_SECTION" != "$NOTE" ]; then if [ "$LAST_SECTION" != "$NOTE" ]; then
printf " Section: %s\n" "$NOTE" printf " Section: %s\n" "$NOTE"
fi fi

View File

@@ -1,4 +1,4 @@
function pause { function pause {
read -p " Press [Enter] to continue." read -rp " Press [Enter] to continue."
echo "" echo ""
} }

View File

@@ -1,30 +1,33 @@
#============================================================================== #==============================================================================
# Section: Configuration # Section: Configuration / Stage 1
#============================================================================== #==============================================================================
if [ -r "$CONFIGURATION" ]; then if [ -r "$CONFIG_FILE" ]; then
source "$CONFIGURATION" source "$CONFIG_FILE"
else else
w_conf create_sns_root
source "$CONFIGURATION" source "$CONFIG_FILE"
fi fi
if [ "$ENCRYPTION" == "TRUE" ]; then if [ "$ENCRYPTION" == "TRUE" ]; then
if [ -z "$ENC_KEY" ]; then if [ -z "$PUBKEY" ]; then
ERR_NO_KEY="TRUE" ERR_NO_KEY="TRUE"
ENCRYPTION="FALSE" ENCRYPTION="FALSE"
fi fi
command -v openssl >/dev/null 2>&1 || { ERR_NO_SSL="TRUE"; ENCRYPTION="FALSE"; }
command -v openssl >/dev/null 2>&1 ||\
{ ERR_NO_SSL="TRUE"; ENCRYPTION="FALSE"; }
fi fi
if [ "$ENCRYPTION" == "TRUE" ]; then if [ "$ENCRYPTION" == "TRUE" ]; then
PROD_STR="Simple Note System (Encryption Enabled)" PROD_STR="Simple Note System (Encryption Enabled)"
EXT="$EXT" EXT="$EXT".gpg
if [ ! -d "$BASEDIR"/tmp ]; then if [ ! -d "$BASE_DIR"/tmp ]; then
mkdir -p "$BASEDIR"/tmp mkdir -p "$BASE_DIR"/tmp
fi fi
fi fi
echo "$PROD_STR, $VER_STR" echo "$PROD_STR, $VER_STR"
if [ -n "$ERR_NO_SSL" ]; then if [ -n "$ERR_NO_SSL" ]; then
echo >&2 " Warning: OpenSSL not installed. Encryption disabled." echo >&2 " Warning: OpenSSL not installed. Encryption disabled."
fi fi
@@ -37,5 +40,5 @@ pause
fi fi
#============================================================================== #==============================================================================
# End Section: Configuration # End Section: Configuration / Stage 1
#============================================================================== #==============================================================================

View File

@@ -1,5 +1,5 @@
#============================================================================== #==============================================================================
# Section: Argument Parsing # Section: Argument Parsing / Stage 2
#============================================================================== #==============================================================================
NAME="" NAME=""
@@ -16,7 +16,7 @@ else
elif [ "$ARG" = "-p" ] || [ "$ARG" = "--print" ]; then PRINT="TRUE" elif [ "$ARG" = "-p" ] || [ "$ARG" = "--print" ]; then PRINT="TRUE"
elif [ "$ARG" = "-l" ] || [ "$ARG" = "--list" ]; then LIST="TRUE" elif [ "$ARG" = "-l" ] || [ "$ARG" = "--list" ]; then LIST="TRUE"
elif [ "$ARG" = "-h" ] || [ "$ARG" == "--help" ]; then help; exit 0 elif [ "$ARG" = "-h" ] || [ "$ARG" == "--help" ]; then help; exit 0
elif [ "$ARG" = "-w" ] || [ "$ARG" == "--wconf" ]; then w_conf; exit 0 elif [ "$ARG" = "-w" ] || [ "$ARG" == "--wconf" ]; then create_sns_root; exit 0
else else
if [ -z "$NAME" ] && [ -n "$ARG" ]; then NAME="$ARG" if [ -z "$NAME" ] && [ -n "$ARG" ]; then NAME="$ARG"
elif [ -z "$NOTEBOOK" ] && [ -n "$ARG" ]; then NOTEBOOK="$ARG" elif [ -z "$NOTEBOOK" ] && [ -n "$ARG" ]; then NOTEBOOK="$ARG"
@@ -37,5 +37,5 @@ fi
# that can work without any arguments. # that can work without any arguments.
#============================================================================== #==============================================================================
# End Section: Argument Parsing # End Section: Argument Parsing / Stage 2
#============================================================================== #==============================================================================

View File

@@ -1,6 +1,6 @@
# Help requires no arguments, and is exclusive. #==============================================================================
if [ -n "$HELP" ]; then help; exit 0; fi # Section: Actions / Stage 3
#==============================================================================
# List only requires a notebook, and is exclusive. # List only requires a notebook, and is exclusive.
if [ -z "$NOTEBOOK" ]; then if [ -z "$NOTEBOOK" ]; then
echo " ERROR: Insufficient arguments:" echo " ERROR: Insufficient arguments:"
@@ -21,11 +21,16 @@ if [ -z "$NAME" ]; then
exit 30 exit 30
fi fi
NOTEDIR="$BASEDIR"/"$NOTEBOOK"/"$SECTION"/ SESSION_ID="$RANDOM"
NOTE="$NOTEDIR""$NAME"."$EXT" NOTE_DIR="$BASE_DIR"/"$NOTEBOOK"/"$SECTION"/
NOTE="$NOTE_DIR""$NAME"."$EXT"
if [ "$ENCRYPTION" == "TRUE" ]; then NOTE="$NOTE".enc; fi if [ "$ENCRYPTION" == "TRUE" ]; then NOTE="$NOTE".enc; fi
if [ "$PRINT" == "TRUE" ]; then print; exit 0; fi if [ "$PRINT" == "TRUE" ]; then print; exit 0; fi
if [ "$DELETE" == "TRUE" ]; then delete; exit 0; fi if [ "$DELETE" == "TRUE" ]; then delete; exit 0; fi
if [ "$CREATE" == "TRUE" ]; then create; fi if [ "$CREATE" == "TRUE" ]; then create; fi
if [ "$EDIT" == "TRUE" ]; then edit; fi if [ "$EDIT" == "TRUE" ]; then edit; fi
#==============================================================================
# End Section: Actions / Stage 3
#==============================================================================