* Moved no editor warning to edit function
* Added message in create_sns_root showing SNS's environment was actually initialized * Changed flag to create SNS's environment from -w to -i
This commit is contained in:
22
sns.sh
22
sns.sh
@@ -15,10 +15,10 @@ readonly CONFIG_FILE="$ROOT_DIR/sns.conf"
|
||||
|
||||
|
||||
# Section: Functions
|
||||
function w_conf {
|
||||
function create_sns_root {
|
||||
|
||||
if [ ! -r "$ROOT_DIR" ]; then mkdir -p "$ROOT_DIR"; fi
|
||||
if [ ! -d "$TMP_DIR" ]; then mkdir -p "$TMP_DIR" ; fi
|
||||
if [ ! -r "$ROOT_DIR" ]; then mkdir -p "$ROOT_DIR"; WILL_INIT="TRUE"; fi
|
||||
if [ ! -d "$TMP_DIR" ]; then mkdir -p "$TMP_DIR" ; WILL_INIT="TRUE"; fi
|
||||
|
||||
|
||||
cat > "$CONFIG_FILE" << EOF
|
||||
@@ -45,6 +45,12 @@ PUBKEY=""
|
||||
EOF
|
||||
|
||||
chmod 600 "$CONFIG_FILE"
|
||||
|
||||
if [ "$WILL_INIT" == "TRUE" ]; then
|
||||
printf "%s %s\n" "Environment initialized in" "$ROOT_DIR"
|
||||
else
|
||||
printf "%s\n" "Environment already initialized."
|
||||
fi
|
||||
}
|
||||
function pause {
|
||||
read -rp " Press [Enter] to continue."
|
||||
@@ -123,7 +129,10 @@ function delete(){
|
||||
fi
|
||||
}
|
||||
function edit(){
|
||||
if [ ! -r "$NOTE" ]; then
|
||||
if [ -z "$EDITOR" ]; then
|
||||
>&2 echo "Error no editor specified in environment."
|
||||
exit
|
||||
elif [ ! -r "$NOTE" ]; then
|
||||
echo "ERROR: Note cannot be opened for editing."
|
||||
exit 40;
|
||||
fi
|
||||
@@ -207,10 +216,7 @@ fi
|
||||
|
||||
echo "$PROD_STR, $VER_STR"
|
||||
|
||||
if [ -z "$EDITOR" ]; then
|
||||
>&2 echo "Error no editor specified in environment."
|
||||
|
||||
elif [ -n "$ERR_NO_GPG" ]; then
|
||||
if [ -n "$ERR_NO_GPG" ]; then
|
||||
>&2 echo " Error: Encryption was specified, but GPG is not installed."
|
||||
exit 100
|
||||
elif [ -n "$ERR_NO_KEY" ]; then
|
||||
|
||||
@@ -1,7 +1,7 @@
|
||||
function w_conf {
|
||||
function create_sns_root {
|
||||
|
||||
if [ ! -r "$ROOT_DIR" ]; then mkdir -p "$ROOT_DIR"; fi
|
||||
if [ ! -d "$TMP_DIR" ]; then mkdir -p "$TMP_DIR" ; fi
|
||||
if [ ! -r "$ROOT_DIR" ]; then mkdir -p "$ROOT_DIR"; WILL_INIT="TRUE"; fi
|
||||
if [ ! -d "$TMP_DIR" ]; then mkdir -p "$TMP_DIR" ; WILL_INIT="TRUE"; fi
|
||||
|
||||
|
||||
cat > "$CONFIG_FILE" << EOF
|
||||
@@ -28,4 +28,10 @@ PUBKEY=""
|
||||
EOF
|
||||
|
||||
chmod 600 "$CONFIG_FILE"
|
||||
|
||||
if [ "$WILL_INIT" == "TRUE" ]; then
|
||||
printf "%s %s\n" "Environment initialized in" "$ROOT_DIR"
|
||||
else
|
||||
printf "%s\n" "Environment already initialized."
|
||||
fi
|
||||
}
|
||||
|
||||
@@ -1,5 +1,8 @@
|
||||
function edit(){
|
||||
if [ ! -r "$NOTE" ]; then
|
||||
if [ -z "$EDITOR" ]; then
|
||||
>&2 echo "Error no editor specified in environment."
|
||||
exit
|
||||
elif [ ! -r "$NOTE" ]; then
|
||||
echo "ERROR: Note cannot be opened for editing."
|
||||
exit 40;
|
||||
fi
|
||||
|
||||
@@ -27,10 +27,7 @@ fi
|
||||
|
||||
echo "$PROD_STR, $VER_STR"
|
||||
|
||||
if [ -z "$EDITOR" ]; then
|
||||
>&2 echo "Error no editor specified in environment."
|
||||
|
||||
elif [ -n "$ERR_NO_GPG" ]; then
|
||||
if [ -n "$ERR_NO_GPG" ]; then
|
||||
>&2 echo " Error: Encryption was specified, but GPG is not installed."
|
||||
exit 100
|
||||
elif [ -n "$ERR_NO_KEY" ]; then
|
||||
|
||||
@@ -16,7 +16,7 @@ else
|
||||
elif [ "$ARG" = "-p" ] || [ "$ARG" = "--print" ]; then PRINT="TRUE"
|
||||
elif [ "$ARG" = "-l" ] || [ "$ARG" = "--list" ]; then LIST="TRUE"
|
||||
elif [ "$ARG" = "-h" ] || [ "$ARG" == "--help" ]; then help; exit 0
|
||||
elif [ "$ARG" = "-w" ] || [ "$ARG" == "--wconf" ]; then create_sns_root; exit 0
|
||||
elif [ "$ARG" = "-i" ] || [ "$ARG" == "--init" ]; then create_sns_root; exit 0
|
||||
else
|
||||
if [ -z "$NAME" ] && [ -n "$ARG" ]; then NAME="$ARG"
|
||||
elif [ -z "$NOTEBOOK" ] && [ -n "$ARG" ]; then NOTEBOOK="$ARG"
|
||||
|
||||
Reference in New Issue
Block a user