From 45717e33b523e7c180b73e504f577b3a107754dd Mon Sep 17 00:00:00 2001 From: Jon-William Lewis Date: Wed, 18 Mar 2015 12:52:00 -0500 Subject: [PATCH] Simple Note System v2.0a2 Changes: Split script into several different files for easier editting Added build.sh to compile Simple Note System from tree Changed config file to config folder; $HOME/.sns now contains configuration and notes Testing: Script runs and produces help screen; no further testing done. --- build.sh | 34 ++++ functions/create.sns.sh | 33 ++++ functions/delete.sns.sh | 20 ++ functions/edit.sns.sh | 30 +++ functions/help.sns.sh | 20 ++ functions/list.sns.sh | 39 ++++ functions/print.sns.sh | 22 +++ functions/wconf.sns.sh | 35 ++++ init/stage1.sns.sh | 43 +++++ init/stage2.sns.sh | 40 ++++ init/stage3.sns.sh | 22 +++ sns.sh | 333 ++++++++++++++++------------------ sns.xcodeproj/project.pbxproj | 42 ++++- 13 files changed, 538 insertions(+), 175 deletions(-) create mode 100644 build.sh create mode 100644 functions/create.sns.sh create mode 100644 functions/delete.sns.sh create mode 100644 functions/edit.sns.sh create mode 100644 functions/help.sns.sh create mode 100644 functions/list.sns.sh create mode 100644 functions/print.sns.sh create mode 100644 functions/wconf.sns.sh create mode 100644 init/stage1.sns.sh create mode 100644 init/stage2.sns.sh create mode 100644 init/stage3.sns.sh diff --git a/build.sh b/build.sh new file mode 100644 index 0000000..f9f3000 --- /dev/null +++ b/build.sh @@ -0,0 +1,34 @@ +S=sns.sh + +PROD_STR="Simple Note System" +VER_STR=v2.0a2 + +cat > $S << EOF +#!/bin/bash +#========================================================== +# Simple Note System, v2.0a1 +# Copyright 2014, Xenese Labs/Sicron-Perion XNF +#========================================================== + +PROD_STR=$PROD_STR +VER_STR=$VER_STR + +EOF + +cat functions/wconf.sns.sh >> $S +cat functions/help.sns.sh >> $S +cat ./init/stage1.sns.sh >> $S +cat ./init/stage2.sns.sh >> $S +cat ./init/stage3.sns.sh >> $S + +cat ./functions/create.sns.sh >> $S +cat ./functions/delete.sns.sh >> $S +cat ./functions/edit.sns.sh >> $S +cat ./functions/print.sns.sh >> $S +cat ./functions/list.sns.sh >> $S + + + + + +exit diff --git a/functions/create.sns.sh b/functions/create.sns.sh new file mode 100644 index 0000000..30d094a --- /dev/null +++ b/functions/create.sns.sh @@ -0,0 +1,33 @@ +#========================================================================== +# Subection: Create +#========================================================================== +if [ -z "$CREATE" -a -z "$EDIT" -a -z "$PRINT" ]; then #If no action specified, print help and exit +help +exit +else + + +if [ "$CREATE" == "TRUE" ]; then +if [ -e $NOTE -o -e ${NOTE%.*} ]; then + +echo "" +echo "ERROR: Note already exists" +echo "Hint: use -e to edit the note." +echo "" +exit +else +#Create any necessary folders +mkdir -p $NOTEDIR + +#Fill in title +echo "TITLE: $NAME" > $NOTE +#Fill the second line with the date +echo "DATE: $(date)" >> $NOTE + +if [ "$ENCRYPTION" == "TRUE" ]; then +if [ $EDIT == "FALSE" ]; then +openssl enc -aes-256-cbc -salt -in $NOTE -out ${NOTE%.*} -pass pass:$ENC_KEY +fi +fi +fi +fi diff --git a/functions/delete.sns.sh b/functions/delete.sns.sh new file mode 100644 index 0000000..b59189e --- /dev/null +++ b/functions/delete.sns.sh @@ -0,0 +1,20 @@ +# delete.sns.sh + +if [ "$DELETE" == "TRUE" ]; then +if [ -e $NOTE -o -e ${NOTE%.*} ]; then +if [ "$ENCRYPTION" == "TRUE" ]; then +rm ${NOTE%.*} +else +rm $NOTE +fi + +echo "" +echo "Deleted note: $NOTEBOOK/$SECTION$NAME." +exit +else + +echo "" +echo "ERROR: Note $NOTEBOOK/$SECTION$NAME does not exist." +exit +fi +fi diff --git a/functions/edit.sns.sh b/functions/edit.sns.sh new file mode 100644 index 0000000..9603706 --- /dev/null +++ b/functions/edit.sns.sh @@ -0,0 +1,30 @@ +#========================================================================== +# Subection: Edit +#========================================================================== +if [ "$EDIT" == "TRUE" ]; then +if [ -r "$NOTE" -o -r ${NOTE%.*} ]; then +if [ -z "$CREATE" ]; then +if [ "$ENCRYPTION" == "TRUE" ]; then +TMP_NAME=$ROOTDIR/tmp/$RANDOM +openssl enc -d -aes-256-cbc -in ${NOTE%.*} -pass pass:$ENC_KEY > $TMP_NAME +echo "" >> $TMP_NAME +echo "EDIT $(date)" >> $TMP_NAME +else +echo "" >> $NOTE +echo "EDIT $(date)" >> $NOTE +fi +fi +$EDITOR $NOTE +if [ "$ENCRYPTION" == "TRUE" ]; then +openssl enc -aes-256-cbc -salt -in $NOTE -out ${NOTE%.*} -pass pass:$ENC_KEY +rm $NOTE +fi + +else +echo "" +echo "ERROR: Note cannot be opened for editting." +echo "" +fi +fi + +fi diff --git a/functions/help.sns.sh b/functions/help.sns.sh new file mode 100644 index 0000000..b926b9e --- /dev/null +++ b/functions/help.sns.sh @@ -0,0 +1,20 @@ +function help { +echo "" +echo "usage: sns [-ce] NAME NOTEBOOK SECTION" +echo " sns [-d ] NAME NOTEBOOK SECTION" +echo " sns [-l ] NOTEBOOK" +echo " sns [-w ]" + +echo "" +echo " -c | --create : Create note" +echo " -d | --delete : Delete note" +echo " -e | --edit : Open note for editing" +echo " -p | --print : Print note to console" +echo " -l | --list : List all notes in NOTEBOOK" +echo " -w | --wconf : Write default configuration to ~/.sns (useful for Encryption)" +echo "" +} + +#============================================================================== +# End Section: Helper Functions +#============================================================================== diff --git a/functions/list.sns.sh b/functions/list.sns.sh new file mode 100644 index 0000000..628539a --- /dev/null +++ b/functions/list.sns.sh @@ -0,0 +1,39 @@ +# list.sns.sh + +if [ -n "$LIST" ]; then +NOTEBOOK="$NAME" #In case of a list command, arg parsing fails. +if [ -z "$NOTEBOOK" ]; then +echo " ERROR: Insufficient arguments" +help +exit +else +if [ -d "$BASEDIR"/"$NOTEBOOK" ]; then + +echo "" +printf "Notes in $(basename $NOTEBOOK):" +echo "" +NOTES=( $(find $BASEDIR/$NOTEBOOK -name "*.$EXT" -print0 | sed s:$BASEDIR/$NOTEBOOK/:" ":g | sed -e s:".$EXT"::g | tr "/" " ") ) +let i=0 +for NOTE in ${NOTES[@]}; do +if [ -d $BASEDIR/$NOTEBOOK/$NOTE ]; then +if [ "$LAST_SECTION" != "$NOTE" ]; then +printf " Section: $NOTE\n" +fi +LAST_SECTION=$NOTE +else +#if [ $(($i % 1)) -eq 0 ]; then +# printf "\n " +#fi +printf " $NOTE\n" +fi +let i++ +done +printf "\n" +else +echo "" +echo "ERROR: Notebook $NOTEBOOK does not exist." +echo "" +fi +fi +exit +fi diff --git a/functions/print.sns.sh b/functions/print.sns.sh new file mode 100644 index 0000000..1c057c5 --- /dev/null +++ b/functions/print.sns.sh @@ -0,0 +1,22 @@ +#========================================================================== +# Subection: Print +#========================================================================== +if [ "$PRINT" == "TRUE" ]; then +if [ -r "$NOTE" -o -r ${NOTE%.*} ]; then +if [ -z "$CREATE" ]; then +if [ "$ENCRYPTION" == "TRUE" ]; then +openssl enc -d -aes-256-cbc -in ${NOTE%.*} -pass pass:$ENC_KEY +else +cat $NOTE +echo "" >> $NOTE +fi +else + +echo "" +echo "ERROR: Note cannot be found." +echo "" + +fi +fi + +fi diff --git a/functions/wconf.sns.sh b/functions/wconf.sns.sh new file mode 100644 index 0000000..b0d524f --- /dev/null +++ b/functions/wconf.sns.sh @@ -0,0 +1,35 @@ +#============================================================================== +# Section: Helper Functions +#============================================================================== +function writeconf { +cat > $HOME/.sns/sns.conf << EOF +#========================================================== +# Simple Note System Config, v2.0a1 +# 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 + +#Preferred Editor +EDITOR=vim + +#Encryption +#WARNING: ANY PREVIOUSLY UNENCRYPTED NOTES WILL BE LOST +ENCRYPTION="FALSE" +ENC_KEY="" +EOF + +chmod 600 $ROOTDIR/sns.conf +} + + +function pause { +read -p " Press [Enter] to continue." +echo "" +} + diff --git a/init/stage1.sns.sh b/init/stage1.sns.sh new file mode 100644 index 0000000..c949e19 --- /dev/null +++ b/init/stage1.sns.sh @@ -0,0 +1,43 @@ +#============================================================================== +# Section: Configuration +#============================================================================== +if [ -r $HOME/.sns/sns.conf ]; then +source $HOME/.sns/sns.conf +else +ROOTDIR=$HOME/.sns +BASEDIR=$ROOTDIR/notes +EDITOR=vim +EXT=note +fi + +if [ "$ENCRYPTION" == "TRUE" ]; then +if [ -z "$ENC_KEY" ]; then +ERR_NO_KEY="TRUE" +ENCRYPTION="FALSE" +fi +command -v openssl >/dev/null 2>&1 || { ERR_NO_SSL="TRUE"; ENCRYPTION="FALSE"; } +fi + +if [ "$ENCRYPTION" == "TRUE" ]; then +PROD_STR="Simple Note System (Encryption Enabled)" +EXT="$EXT.enc" +if [ ! -d ~/.sns/tmp ]; then +mkdir -p ~/.sns/tmp +fi +fi + +echo "$PROD_STR, $VER_STR" +if [ -n "$ERR_NO_SSL" ]; then +echo >&2 " Warning: OpenSSL not installed. Encryption disabled." +fi +if [ -n "$ERR_NO_KEY" ]; then +echo " Warning: No encryption key was provided. Encryption disabled." +fi + +if [ -n "$ERR_NO_SSL" -o -n "$ERR_NO_KEY" ]; then +pause +fi + +#============================================================================== +# End Section: Read Configuration +#============================================================================== diff --git a/init/stage2.sns.sh b/init/stage2.sns.sh new file mode 100644 index 0000000..fd26a51 --- /dev/null +++ b/init/stage2.sns.sh @@ -0,0 +1,40 @@ +#============================================================================== +# Section: Argument Parsing +#============================================================================== + +NAME="" +NOTEBOOK="" +SECTION="" + +if [ -z "$1" ]; then #If no input was given, print help + help + exit +else #Assume the user wants to do something. + ARGS=( "$@" ) + for ARG in ${ARGS[@]};do + if [ "$ARG" = "-c" -o "$ARG" = "--create" ]; then CREATE="TRUE" + elif [ "$ARG" = "-d" -o "$ARG" = "--delete" ]; then DELETE="TRUE" + elif [ "$ARG" = "-e" -o "$ARG" = "--edit" ]; then EDIT="TRUE" + elif [ "$ARG" = "-ce" -o "$ARG" = "-ec" ]; then EDIT="TRUE";CREATE="TRUE" + elif [ "$ARG" = "-p" -o "$ARG" = "--print" ]; then PRINT="TRUE" + elif [ "$ARG" = "-l" -o "$ARG" = "--list" ]; then LIST="TRUE" + elif [ "$ARG" = "-h" -o "$ARG" == "--help" ]; then help; exit 0 + elif [ "$ARG" = "-w" -o "$ARG" == "--wconf" ]; then writeconf; exit + else + if [ -z "$NAME" -a -n $ARG ]; then + NAME=$ARG + echo "Name: $NAME" + elif [ -z "$NOTEBOOK" -a -n $ARG ]; then + NOTEBOOK=$ARG + echo "Notebook: $NOTEBOOK" + elif [ -z "$SECTION" -a -n $ARG ]; then + SECTION=$ARG + echo "Section: $SECTION" + fi + fi + done +fi + +#============================================================================== +# End Section: Argument Parsing +#============================================================================== diff --git a/init/stage3.sns.sh b/init/stage3.sns.sh new file mode 100644 index 0000000..9008b32 --- /dev/null +++ b/init/stage3.sns.sh @@ -0,0 +1,22 @@ + + + + + + + +# If no name or notebook is specified, the create, edit, and print functions will not function properly. +# Check $NAME and $NOTEBOOK and exit if either are empty. +if [ -z "$NAME" -o -z "$NOTEBOOK" ]; then; + echo " ERROR: Insufficient arguments"; + help; #Remind the user how to use the script + exit 10; +fi + + +NOTEDIR=$BASEDIR/$NOTEBOOK/$SECTION/ +NOTE=$NOTEDIR$NAME.$EXT + +if [ "$ENCRYPTION" == "TRUE" ]; then +NOTE=$NOTE.tmp +fi diff --git a/sns.sh b/sns.sh index 820c85f..c3084c4 100644 --- a/sns.sh +++ b/sns.sh @@ -1,24 +1,25 @@ #!/bin/bash #========================================================== -# Simple Note System, v1.1 +# Simple Note System, v2.0a1 # Copyright 2014, Xenese Labs/Sicron-Perion XNF #========================================================== PROD_STR="Simple Note System" -VER_STR=v1.1 +VER_STR=v2.0a1 #============================================================================== # Section: Helper Functions #============================================================================== function writeconf { -cat > $HOME/.sns << EOF +cat > $HOME/.sns/sns.conf << EOF #========================================================== -# Simple Note System Config, v1.1 +# Simple Note System Config, v2.0a1 # Copyright 2014, Xenese Labs/Sicron-Perion XNF #========================================================== #Directory where notes will be stored -BASEDIR=$HOME/notes +ROOTDIR=$HOME/.sns +BASEDIR=$ROOTDIR/notes #File extension to use (for listing notes) EXT=note @@ -32,7 +33,13 @@ ENCRYPTION="FALSE" ENC_KEY="" EOF -chmod 600 $HOME/.sns +chmod 600 $ROOTDIR/sns.conf +} + + +function pause { +read -p " Press [Enter] to continue." +echo "" } function help { @@ -52,22 +59,17 @@ echo " -w | --wconf : Write default configuration to ~/.sns (useful for Encryp echo "" } -function pause { -read -p " Press [Enter] to continue." -echo "" -} - #============================================================================== # End Section: Helper Functions #============================================================================== - #============================================================================== # Section: Configuration #============================================================================== -if [ -r $HOME/.sns ]; then -source $HOME/.sns +if [ -r $HOME/.sns/sns.conf ]; then +source $HOME/.sns/sns.conf else -BASEDIR=$HOME/notes +ROOTDIR=$HOME/.sns +BASEDIR=$ROOTDIR/notes EDITOR=vim EXT=note fi @@ -76,7 +78,6 @@ if [ "$ENCRYPTION" == "TRUE" ]; then if [ -z "$ENC_KEY" ]; then ERR_NO_KEY="TRUE" ENCRYPTION="FALSE" -pause fi command -v openssl >/dev/null 2>&1 || { ERR_NO_SSL="TRUE"; ENCRYPTION="FALSE"; } fi @@ -84,8 +85,8 @@ fi if [ "$ENCRYPTION" == "TRUE" ]; then PROD_STR="Simple Note System (Encryption Enabled)" EXT="$EXT.enc" -if [ ! -d ~/.tmp ]; then -mkdir -p ~/.tmp +if [ ! -d ~/.sns/tmp ]; then +mkdir -p ~/.sns/tmp fi fi @@ -104,8 +105,6 @@ fi #============================================================================== # End Section: Read Configuration #============================================================================== - - #============================================================================== # Section: Argument Parsing #============================================================================== @@ -115,51 +114,52 @@ NOTEBOOK="" SECTION="" if [ -z "$1" ]; then #If no input was given, print help -help -exit + help + exit else #Assume the user wants to do something. -ARGS=( "$@" ) -for ARG in ${ARGS[@]};do -if [ "$ARG" = "-c" -o "$ARG" = "--create" ]; then CREATE="TRUE" -elif [ "$ARG" = "-d" -o "$ARG" = "--delete" ]; then DELETE="TRUE" -elif [ "$ARG" = "-e" -o "$ARG" = "--edit" ]; then EDIT="TRUE" -elif [ "$ARG" = "-ce" -o "$ARG" = "-ec" ]; then EDIT="TRUE";CREATE="TRUE" -elif [ "$ARG" = "-p" -o "$ARG" = "--print" ]; then PRINT="TRUE" -elif [ "$ARG" = "-l" -o "$ARG" = "--list" ]; then LIST="TRUE" -elif [ "$ARG" = "-h" -o "$ARG" == "--help" ]; then help; exit 0 -elif [ "$ARG" = "-w" -o "$ARG" == "--wconf" ]; then writeconf; exit -else -if [ -z "$NAME" -a -n $ARG ]; then -NAME=$ARG -echo "Name: $NAME" -elif [ -z "$NOTEBOOK" -a -n $ARG ]; then -NOTEBOOK=$ARG -echo "Notebook: $NOTEBOOK" -elif [ -z "$SECTION" -a -n $ARG ]; then -SECTION=$ARG -echo "Section: $SECTION" -fi -fi -done + ARGS=( "$@" ) + for ARG in ${ARGS[@]};do + if [ "$ARG" = "-c" -o "$ARG" = "--create" ]; then CREATE="TRUE" + elif [ "$ARG" = "-d" -o "$ARG" = "--delete" ]; then DELETE="TRUE" + elif [ "$ARG" = "-e" -o "$ARG" = "--edit" ]; then EDIT="TRUE" + elif [ "$ARG" = "-ce" -o "$ARG" = "-ec" ]; then EDIT="TRUE";CREATE="TRUE" + elif [ "$ARG" = "-p" -o "$ARG" = "--print" ]; then PRINT="TRUE" + elif [ "$ARG" = "-l" -o "$ARG" = "--list" ]; then LIST="TRUE" + elif [ "$ARG" = "-h" -o "$ARG" == "--help" ]; then help; exit 0 + elif [ "$ARG" = "-w" -o "$ARG" == "--wconf" ]; then writeconf; exit + else + if [ -z "$NAME" -a -n $ARG ]; then + NAME=$ARG + echo "Name: $NAME" + elif [ -z "$NOTEBOOK" -a -n $ARG ]; then + NOTEBOOK=$ARG + echo "Notebook: $NOTEBOOK" + elif [ -z "$SECTION" -a -n $ARG ]; then + SECTION=$ARG + echo "Section: $SECTION" + fi + fi + done fi #============================================================================== # End Section: Argument Parsing #============================================================================== -#============================================================================== -#============================================================================== -# -# End of Setup process. By now, we should have a $BASEDIR, $NOTEBOOK, $SECTION, -# $NOTEDIR, and $EXT -# -#============================================================================== -#============================================================================== -#============================================================================== -# Section: Main -#============================================================================== + + + + +# If no name or notebook is specified, the create, edit, and print functions will not function properly. +# Check $NAME and $NOTEBOOK and exit if either are empty. +if [ -z "$NAME" -o -z "$NOTEBOOK" ]; then; + echo " ERROR: Insufficient arguments"; + help; #Remind the user how to use the script + exit 10; +fi + NOTEDIR=$BASEDIR/$NOTEBOOK/$SECTION/ NOTE=$NOTEDIR$NAME.$EXT @@ -167,10 +167,113 @@ NOTE=$NOTEDIR$NAME.$EXT if [ "$ENCRYPTION" == "TRUE" ]; then NOTE=$NOTE.tmp fi +#========================================================================== +# Subection: Create +#========================================================================== +if [ -z "$CREATE" -a -z "$EDIT" -a -z "$PRINT" ]; then #If no action specified, print help and exit +help +exit +else + +if [ "$CREATE" == "TRUE" ]; then +if [ -e $NOTE -o -e ${NOTE%.*} ]; then + +echo "" +echo "ERROR: Note already exists" +echo "Hint: use -e to edit the note." +echo "" +exit +else +#Create any necessary folders +mkdir -p $NOTEDIR + +#Fill in title +echo "TITLE: $NAME" > $NOTE +#Fill the second line with the date +echo "DATE: $(date)" >> $NOTE + +if [ "$ENCRYPTION" == "TRUE" ]; then +if [ $EDIT == "FALSE" ]; then +openssl enc -aes-256-cbc -salt -in $NOTE -out ${NOTE%.*} -pass pass:$ENC_KEY +fi +fi +fi +fi +# delete.sns.sh + +if [ "$DELETE" == "TRUE" ]; then +if [ -e $NOTE -o -e ${NOTE%.*} ]; then +if [ "$ENCRYPTION" == "TRUE" ]; then +rm ${NOTE%.*} +else +rm $NOTE +fi + +echo "" +echo "Deleted note: $NOTEBOOK/$SECTION$NAME." +exit +else + +echo "" +echo "ERROR: Note $NOTEBOOK/$SECTION$NAME does not exist." +exit +fi +fi #========================================================================== -# Subection: List +# Subection: Edit #========================================================================== +if [ "$EDIT" == "TRUE" ]; then +if [ -r "$NOTE" -o -r ${NOTE%.*} ]; then +if [ -z "$CREATE" ]; then +if [ "$ENCRYPTION" == "TRUE" ]; then +TMP_NAME=$ROOTDIR/tmp/$RANDOM +openssl enc -d -aes-256-cbc -in ${NOTE%.*} -pass pass:$ENC_KEY > $TMP_NAME +echo "" >> $TMP_NAME +echo "EDIT $(date)" >> $TMP_NAME +else +echo "" >> $NOTE +echo "EDIT $(date)" >> $NOTE +fi +fi +$EDITOR $NOTE +if [ "$ENCRYPTION" == "TRUE" ]; then +openssl enc -aes-256-cbc -salt -in $NOTE -out ${NOTE%.*} -pass pass:$ENC_KEY +rm $NOTE +fi + +else +echo "" +echo "ERROR: Note cannot be opened for editting." +echo "" +fi +fi + +fi +#========================================================================== +# Subection: Print +#========================================================================== +if [ "$PRINT" == "TRUE" ]; then +if [ -r "$NOTE" -o -r ${NOTE%.*} ]; then +if [ -z "$CREATE" ]; then +if [ "$ENCRYPTION" == "TRUE" ]; then +openssl enc -d -aes-256-cbc -in ${NOTE%.*} -pass pass:$ENC_KEY +else +cat $NOTE +echo "" >> $NOTE +fi +else + +echo "" +echo "ERROR: Note cannot be found." +echo "" + +fi +fi + +fi +# list.sns.sh + if [ -n "$LIST" ]; then NOTEBOOK="$NAME" #In case of a list command, arg parsing fails. if [ -z "$NOTEBOOK" ]; then @@ -208,119 +311,3 @@ fi fi exit fi -#====================================================================== -# Sanity Check - Actions below require a valid $NAME and $NOTEBOOK -#====================================================================== -if [ -z "$NAME" -o -z "$NOTEBOOK" ]; then -echo " ERROR: Insufficient arguments" -help -exit 10 -fi -#========================================================================== -# Subection: Delete -#========================================================================== -if [ "$DELETE" == "TRUE" ]; then -if [ -e $NOTE -o -e ${NOTE%.*} ]; then -if [ "$ENCRYPTION" == "TRUE" ]; then -rm ${NOTE%.*} -else -rm $NOTE -fi - -echo "" -echo "Deleted note: $NOTEBOOK/$SECTION$NAME." -exit -else - -echo "" -echo "ERROR: Note $NOTEBOOK/$SECTION$NAME does not exist." -exit -fi -fi - -#========================================================================== -# Subection: Create -#========================================================================== -if [ -z "$CREATE" -a -z "$EDIT" -a -z "$PRINT" ]; then #If no action specified, print help and exit -help -exit -else - - -if [ "$CREATE" == "TRUE" ]; then -if [ -e $NOTE -o -e ${NOTE%.*} ]; then - -echo "" -echo "ERROR: Note already exists" -echo "Hint: use -e to edit the note." -echo "" -exit -else -#Create any necessary folders -mkdir -p $NOTEDIR - -#Fill in title -echo "TITLE: $NAME" > $NOTE -#Fill the second line with the date -echo "DATE: $(date)" >> $NOTE - -if [ "$ENCRYPTION" == "TRUE" ]; then -if [ $EDIT == "FALSE" ]; then -openssl enc -aes-256-cbc -salt -in $NOTE -out ${NOTE%.*} -pass pass:$ENC_KEY -fi -fi -fi -fi - -#========================================================================== -# Subection: Edit -#========================================================================== -if [ "$EDIT" == "TRUE" ]; then -if [ -r "$NOTE" -o -r ${NOTE%.*} ]; then -if [ -z "$CREATE" ]; then -if [ "$ENCRYPTION" == "TRUE" ]; then -openssl enc -d -aes-256-cbc -in ${NOTE%.*} -pass pass:$ENC_KEY > $NOTE -fi -echo "" >> $NOTE -echo "EDIT $(date)" >> $NOTE -fi -$EDITOR $NOTE -if [ "$ENCRYPTION" == "TRUE" ]; then -openssl enc -aes-256-cbc -salt -in $NOTE -out ${NOTE%.*} -pass pass:$ENC_KEY -rm $NOTE -fi - -else - -echo "" -echo "ERROR: Note cannot be opened for editting." -echo "" - -fi -fi - -fi -#========================================================================== -# Subection: Print -#========================================================================== -if [ "$PRINT" == "TRUE" ]; then -if [ -r "$NOTE" -o -r ${NOTE%.*} ]; then -if [ -z "$CREATE" ]; then -if [ "$ENCRYPTION" == "TRUE" ]; then -openssl enc -d -aes-256-cbc -in ${NOTE%.*} -pass pass:$ENC_KEY -else -cat $NOTE -echo "" >> $NOTE -fi -else - -echo "" -echo "ERROR: Note cannot be found." -echo "" - -fi -fi - -fi - -exit diff --git a/sns.xcodeproj/project.pbxproj b/sns.xcodeproj/project.pbxproj index 11d1fa6..91cdc64 100644 --- a/sns.xcodeproj/project.pbxproj +++ b/sns.xcodeproj/project.pbxproj @@ -7,17 +7,55 @@ objects = { /* Begin PBXFileReference section */ - 5D7E611F1AB74D33001D49B9 /* sns.sh */ = {isa = PBXFileReference; lastKnownFileType = text.script.sh; path = sns.sh; sourceTree = ""; }; + 5D7E611F1AB74D33001D49B9 /* build.sh */ = {isa = PBXFileReference; lastKnownFileType = text.script.sh; path = build.sh; sourceTree = ""; }; + 5DE839761AB9D42F006CB4F6 /* list.sns.sh */ = {isa = PBXFileReference; lastKnownFileType = text.script.sh; path = list.sns.sh; sourceTree = ""; }; + 5DE839771AB9D52C006CB4F6 /* delete.sns.sh */ = {isa = PBXFileReference; lastKnownFileType = text.script.sh; path = delete.sns.sh; sourceTree = ""; }; + 5DE8397B1AB9D629006CB4F6 /* stage1.sns.sh */ = {isa = PBXFileReference; lastKnownFileType = text.script.sh; path = stage1.sns.sh; sourceTree = ""; }; + 5DE8397C1AB9D64B006CB4F6 /* stage2.sns.sh */ = {isa = PBXFileReference; lastKnownFileType = text.script.sh; path = stage2.sns.sh; sourceTree = ""; }; + 5DE8397D1AB9D694006CB4F6 /* stage3.sns.sh */ = {isa = PBXFileReference; lastKnownFileType = text.script.sh; path = stage3.sns.sh; sourceTree = ""; }; + 5DE8397E1AB9D72D006CB4F6 /* help.sns.sh */ = {isa = PBXFileReference; lastKnownFileType = text.script.sh; path = help.sns.sh; sourceTree = ""; }; + 5DE8397F1AB9D7B9006CB4F6 /* create.sns.sh */ = {isa = PBXFileReference; lastKnownFileType = text.script.sh; path = create.sns.sh; sourceTree = ""; }; + 5DE839801AB9D7DD006CB4F6 /* edit.sns.sh */ = {isa = PBXFileReference; lastKnownFileType = text.script.sh; path = edit.sns.sh; sourceTree = ""; }; + 5DE839811AB9D7F8006CB4F6 /* print.sns.sh */ = {isa = PBXFileReference; lastKnownFileType = text.script.sh; path = print.sns.sh; sourceTree = ""; }; + 5DE839821AB9DAA6006CB4F6 /* wconf.sns.sh */ = {isa = PBXFileReference; lastKnownFileType = text.script.sh; path = wconf.sns.sh; sourceTree = ""; }; + 5DE839831AB9DACE006CB4F6 /* sns.sh */ = {isa = PBXFileReference; lastKnownFileType = text.script.sh; path = sns.sh; sourceTree = ""; }; /* End PBXFileReference section */ /* Begin PBXGroup section */ 5D7E61181AB74D11001D49B9 = { isa = PBXGroup; children = ( - 5D7E611F1AB74D33001D49B9 /* sns.sh */, + 5DE839831AB9DACE006CB4F6 /* sns.sh */, + 5DE839791AB9D5F8006CB4F6 /* init */, + 5D7E611F1AB74D33001D49B9 /* build.sh */, + 5DE839751AB9D41B006CB4F6 /* functions */, ); sourceTree = ""; }; + 5DE839751AB9D41B006CB4F6 /* functions */ = { + isa = PBXGroup; + children = ( + 5DE839821AB9DAA6006CB4F6 /* wconf.sns.sh */, + 5DE839761AB9D42F006CB4F6 /* list.sns.sh */, + 5DE839771AB9D52C006CB4F6 /* delete.sns.sh */, + 5DE8397E1AB9D72D006CB4F6 /* help.sns.sh */, + 5DE8397F1AB9D7B9006CB4F6 /* create.sns.sh */, + 5DE839801AB9D7DD006CB4F6 /* edit.sns.sh */, + 5DE839811AB9D7F8006CB4F6 /* print.sns.sh */, + ); + path = functions; + sourceTree = ""; + }; + 5DE839791AB9D5F8006CB4F6 /* init */ = { + isa = PBXGroup; + children = ( + 5DE8397D1AB9D694006CB4F6 /* stage3.sns.sh */, + 5DE8397B1AB9D629006CB4F6 /* stage1.sns.sh */, + 5DE8397C1AB9D64B006CB4F6 /* stage2.sns.sh */, + ); + path = init; + sourceTree = ""; + }; /* End PBXGroup section */ /* Begin PBXProject section */