#!/usr/bin/python """ CryptoBottle - minimalistic webfrontend for cryptsetup prepare your Debian/squeeze: aptitude install python-bottle cryptsetup modprobe dm_crypt set all variables before the first run & create "mntpoint" run this script as root """ from bottle import route, run, post, request, debug from subprocess import * serverport = 83 cryptcmd = "/sbin/cryptsetup" mntcmd = "/bin/mount" umntcmd = "/bin/umount" cryptdevice = "/dev/vdc1" mapperpath = "/dev/mapper/" mappername = "vdc1_crypt" mntpoint = "/mnt" @route('/') def index(): return '''
%s''' % err if len(cryptsetup_out) == 0: cryptsetup_out = '
"%s%s" is not mapped
' % (mapperpath, mappername) shell = Popen(["df", "-h"], stdout=PIPE) df_out = shell.communicate()[0] return '''%s
%s''' % (cryptsetup_out, df_out) @route('/cryptopen', method='POST') def cryptopen(): cryptpw = request.forms.get('passwd') if len(cryptpw) == 0: return '''
%szurück ''' % err if len(cryptsetup_out) == 0: cryptsetup_out = '
Einhängen war erfolgreich!
' shell = Popen([mntcmd, mapperpath + mappername, mntpoint], stdout=PIPE,stderr=PIPE) (mount_out, err) = shell.communicate() return '''%szurück ''' % (cryptsetup_out) @route('/cryptclose') def cryptclose(): shell = Popen([umntcmd, mntpoint], stdout=PIPE,stderr=PIPE) (umount_out, err) = shell.communicate() shell = Popen([cryptcmd, "luksClose", mappername], stdout=PIPE,stderr=PIPE) (cryptsetup_out, err) = shell.communicate() if len(err) != 0: return '''
%szurück ''' % err if len(cryptsetup_out) == 0: cryptsetup_out = '
Aushängen war erfolgreich!
' return '''%szurück ''' % (cryptsetup_out) debug(True) run(host='', port=serverport, reloader=True)