ADD: UI Elements, main launcher and install script

main
Kamal Curi 4 years ago
parent 0e18158666
commit 4b55334669

2
.gitignore vendored

@ -1,3 +1,5 @@
main.py
test.py
pasfile.csv
poptest.sh
what.sh

@ -0,0 +1,86 @@
#!/usr/bin/env bash
echo Steelbox install
echo Copying steelbox.sh
sudo cp -f steelbox.sh /opt/steelbox.sh
if [ $? -gt 0 ]
then
echo COULD NOT COPY STEELBOX.SH
echo QUITTING
exit 1
fi
echo Copying steelbox.py
sudo cp -f steelbox.py /opt/steelbox.py
if [ $? -gt 0 ]
then
echo COULD NOT COPY STEELBOX.PY
echo QUITTING
sudo rm /opt/steelbox.sh
exit 1
fi
echo Setting up permissions
sudo chmod +x /opt/steelbox.sh
if [ $? -gt 0 ]
then
echo COULD NOT SET PERMISSIONS
echo QUITTING
sudo rm /opt/steelbox.sh
sudo rm /opt/steelbox.py
exit 1
fi
echo Creating symbolic link to /usr/bin
if [ ! -f /usr/bin/steelbox ]
then
sudo ln -s /opt/steelbox.sh /usr/bin/steelbox
if [ $? -gt 0 ]
then
echo COULD NOT CREATE LINK
echo QUITTING
sudo rm /opt/steelbox.sh
sudo rm /opt/steelbox.py
exit 1
fi
fi
echo Creating initial password file
touch $HOME/.pasfile.csv
if [ $? -gt 0 ]
then
echo COULD NOT CREATE PASSWORD FILE
echo QUITTING
sudo rm /opt/steelbox.sh
sudo rm /opt/steelbox.py
sudo rm /usr/bin/steelbox
exit 1
fi
echo Setting up password file
echo service,user,pswd > $HOME/.pasfile.csv &> /dev/null
echo Loading GPG to encrypt the file for the first time.
echo ===========================================================
echo YOU WILL BE ASKED TO GIVE A PASSWORD TO THE PASSWORD FILE
echo \(And yes, I\'m not immune to the irony\)
echo YOU WILL NEED THIS PASSWORD TO OPEN YOUR FILE
echo gpg-agent \(OR WHATEVER AGENT YOU USE\) WILL
echo HANDLE YOUR PASSWORDS UNTIL YOU REBOOT
echo ===========================================================
echo PRESS ENTER TO CONTINUE
read
gpg -c --cipher-algo AES256 $HOME/.pasfile.csv
if [ $? -gt 0 ]
then
echo ERROR ENCRYPTING THE FILE
echo YOU MUST TYPE A PASSWORD FOR THE INITIAL PASSWORD FILE
echo DELETING ALL INSTALATION FILES
sudo rm /opt/steelbox.sh
sudo rm /opt/steelbox.py
sudo rm /usr/bin/steelbox
rm $HOME/.pasfile.csv
exit 1
fi
rm $HOME/.pasfile.csv

@ -3,7 +3,8 @@ import curses
from curses import wrapper
from curses.textpad import Textbox
import sys
import os
version = sys.argv[1]
## Initialization of bottomline dependencies
@ -16,7 +17,8 @@ files = []
fields = ["service", "user", "pswd"]
# Password file
PASFILE="pasfile.csv"
HOMEDIR = os.environ['HOME']
PASFILE=HOMEDIR+"/.pasfile.csv"
# Initializes Curses' screen
@ -115,6 +117,7 @@ def main(stdscr):
mainwin.clear()
statusWin.clear()
mainwin.border()
mainwin.addstr(0, 1, "SteelBox V" + str(version))
mainwin.refresh()
statusWin.border()
statusWin.refresh()
@ -207,13 +210,21 @@ def main(stdscr):
fileWin.addstr(1, 1, "SRVC: " + passService)
fileWin.addstr(2, 1, "NAME: " + passUser)
fileWin.addstr(3, 1, "PSWD: " + passPswd)
statusWin.clear()
STATUS_MESSAGE = "cmds:(d|DEL)ete "
statusWin.addstr(0,0, STATUS_MESSAGE)
statusWin.refresh()
fileWin.refresh()
# Gets command to act on the highlighted file
c = fileWin.getch()
if c == ord('d'):
if c == ord('d') or c == curses.KEY_DC:
dlWin = curses.newwin(3, 22, int(TERM_LINES/2), int(TERM_COLS/2))
dlWin.border()
dlWin.refresh()
statusWin.clear()
STATUS_MESSAGE = "Delete " + displayList[GLOBAL_CURSOR] + "?"
statusWin.addstr(0,0, STATUS_MESSAGE)
statusWin.refresh()
dlWin.addstr(1, 1, "Are you sure? (y/N)")
c = dlWin.getch()
if c == ord('y'):
@ -258,7 +269,7 @@ def main(stdscr):
psBox.edit()
passPswd = psBox.gather()
if passService is not '' and passUser is not '' and passPswd is not '':
if passService != '' and passUser != '' and passPswd != '':
# wtf = write to file
wtf = {'service' : passService, 'user' : passUser, 'pswd' : passPswd}
files.append(wtf)
@ -267,18 +278,5 @@ def main(stdscr):
csvwriter.writeheader()
csvwriter.writerows(files)
def close():
# This makes sure the terminal gets completely "free of curses" when the application ends
curses.nocbreak()
curses.echo()
curses.endwin()
# Debbuging
print("LINES: ", TERM_LINES)
print("COLS : ", TERM_COLS)
print("MAX_ROWS :", MAX_ROWS)
print("Goodbye! \n")
wrapper(main)
close()
wrapper(main)

@ -0,0 +1,33 @@
#!/usr/bin/env bash
version="0.2"
if [ -f $HOME/.pasfile.csv.gpg ]
then
gpg $HOME/.pasfile.csv.gpg &> /dev/null
if [ $? -gt 0 ]
then
echo WRONG PASSWORD!
exit 1
fi
rm $HOME/.pasfile.csv.gpg
else
echo ERROR: NO ENCRYPTED PASSWORD FILE FOUND
echo STEELBOX WILL ATTEMPT TO OPEN UNENCRYPTED FILE
echo PRESS ENTER TO CONTINUE.
read
fi
python /opt/steelbox.py $version
gpg -c --cipher-algo AES256 $HOME/.pasfile.csv
if [ $? -gt 0 ]
then
echo ERROR ENCRYPTING PASSWORD FILE!
echo UNENCRYPTED FILE IN $HOME/.pasfile.csv
echo PRESS ENTER TO QUIT
read
exit 1
fi
rm $HOME/.pasfile.csv
Loading…
Cancel
Save