Bash Scripting For Buffoons - NoName Script

Ceri Shaw
02/28/16 04:34:54AM
@ceri-shaw

NoName Script



⇦ Back to 'Bash Scripting For Buffoons'

This is an attempt to do the same thing as the earlier 'Bills' script  utilizing the excellent ' dialog ' program which enables you to present a 'pseudo' GUI within the shell ( using the ncurses library ). You will need to install 'dialog' if you dont already have it and once again it is to be found in the Debian or Ubuntu repositories. This script is not complete but it does display the menu correctly. After that it's mostly downhill. You will need to create a folder called 'vault' in your home folder if you want to try and make this function. Best of luck!

#!/bin/bash
# Script for controlling access to encrypted directory.
#documents

while [ 0 ]; do
pwd > /tmp/pd
PD=" `cat /tmp/pd` "
dialog --title "Enter the Vault" \
 --radiolist "Choose one of the following or press <Cancel> to exit" 11 40 6 \
   "1" "Open vault" off\
   "2" "Close vault" off\
   "3" "Append a file" ON 2>/tmp/ans
   if [ $? = 1 ]; then
   rm -f /tmp/ans
   clear
   exit 0
fi
R="`cat /tmp/ans`"
if [ $R = "1" ]; then
chmod 700 ~/vault ;
ccrypt -d ~/vault/* ;
nautilus ~/vault;
elif [ $R = "2" ]; then
chmod 700 ~/vault ;
ccrypt -e ~/vault/* ;
chmod 000 ~/vault ;
elif [ $R = "3" ]; then
dialog --inputbox "Enter the file name:" 8 40 2>/tmp/answer
F="`cat /tmp/answer`"
rm -f /tmp/answer
chmod 700 ~/vault ;
ccrypt -d ~/vault/*
for ea in $F; do mv $ea ~/vault; done
cd ~/vault
for i in $ea; do mv {,"`date`"}$ea ; done
ccrypt -e ~/vault/*
chmod 000 ~/vault ;
cd $PD
fi
rm -f /tmp/pd
done