feature-ssh (1684B)
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 create-sshfs-hook() { 22 fn create-sshfs-hook 23 req=(entry tombid COFFINDOT undertaker) 24 ckreq || return 1 25 26 if [[ $entry =~ sshfs && -f $COFFINDOT/$tombid.pub ]]; then 27 act "Found SSH data. Setting up..." 28 29 [[ -d /home/$undertaker/.ssh ]] || mkdir -p /home/$undertaker/.ssh 30 cat $COFFINDOT/$tombid.pub >> /home/$undertaker/.ssh/authorized_keys 31 chown -R $undertaker:$undertaker /home/$undertaker/.ssh 32 chmod 700 /home/$undertaker/.ssh && chmod 600 /home/$undertaker/.ssh/authorized_keys 33 34 ## NOTE: maybe remove SSH key from usb, consider deletion 35 else 36 act "No SSH data found" 37 fi 38 } 39 40 delete-sshfs-hook() { 41 fn delete-sshfs-hook $* 42 req=(undertaker tombid) 43 local undertaker="$1" 44 local tombid="$2" 45 ckreq || return 1 46 47 local authkeys="/home/$undertaker/.ssh/authorized_keys" 48 49 grep -v $tombid $authkeys > $authkeys.tmp 50 mv $authkeys.tmp $authkeys 51 52 act "Deleted SSH data" 53 }