tombops (2109B)
1 #!/usr/bin/env zsh 2 # 3 # Copyright (c) 2016 Dyne.org Foundation 4 # coffin is written and maintained by Ivan J. <parazyd@dyne.org> 5 # 6 # This file is part of coffin 7 # 8 # This source code is free software: you can redistribute it and/or modify 9 # it under the terms of the GNU General Public License as published by 10 # the Free Software Foundation, either version 3 of the License, or 11 # (at your option) any later version. 12 # 13 # This software is distributed in the hope that it will be useful, 14 # but WITHOUT ANY WARRANTY; without even the implied warranty of 15 # MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the 16 # GNU General Public License for more details. 17 # 18 # You should have received a copy of the GNU General Public License 19 # along with this source code. If not, see <http://www.gnu.org/licenses/>. 20 21 dig-tomb() { 22 fn dig-tomb 23 req=(undertaker tombid tombsize GRAVEYARD) 24 freq=(TOMB) 25 ckreq || return 1 26 27 sudo -u $undertaker $TOMB dig -s $tombsize $GRAVEYARD/$tombid.tomb || \ 28 { die "digging went downhill, cleaning and exiting" && \ 29 clean-failed-hook } 30 } 31 32 forge-tomb-key() { 33 fn forge-tomb-key 34 req=(undertaker tombid GRAVEYARD) 35 freq=(TOMB) 36 ckreq || return 1 37 38 encrypt-password $(pwgen 30 -1 1) 39 sudo -u $undertaker $TOMB forge -k $COFFINDOT/$tombid.key \ 40 --kdf 10 \ 41 --unsafe \ 42 --tomb-pwd "$(decrypt-password)" || \ 43 { die "forging went downhill; cleaning and exiting" && \ 44 clean-failed-hook } 45 } 46 47 lock-tomb() { 48 fn lock-tomb 49 req=(undertaker tombid GRAVEYARD) 50 freq=(TOMB) 51 ckreq || return 1 52 53 sudo -u $undertaker $TOMB lock $GRAVEYARD/$tombid.tomb || \ 54 -k $COFFINDOT/$tombid.key \ 55 --unsafe \ 56 --tomb-pwd "$(decrypt-password)" || \ 57 { die "locking went downhill; cleaning and exiting" && \ 58 clean-failed-hook } 59 } 60 61 open-tomb() { 62 fn open-tomb 63 req=(undertaker tombid GRAVEYARD) 64 freq=(TOMB) 65 ckreq || return 1 66 67 sudo -u $undertaker $TOMB open \ 68 $GRAVEYARD/$tombid.tomb \ 69 -k $COFFINDOT/$tombid.key \ 70 --unsafe \ 71 --tomb-pwd "$(decrypt-password)" 72 } 73 74 close-tomb() { 75 fn close-tomb 76 req=(undertaker tombid) 77 freq=(TOMB) 78 ckreq || return 1 79 80 sudo -u $undertaker $TOMB slam $tombid 81 }