coffin

secure lan file storage on a device
git clone git://parazyd.org/coffin.git
Log | Files | Refs | Submodules | README | LICENSE

commit 966866966ac2724313fe414e72899a4223d291b8
parent 9b059e9c831a05a416e9eb724e36f307c629d6db
Author: parazyd <parazyd@dyne.org>
Date:   Mon, 16 May 2016 17:16:32 +0200

refactor configuration, moved to src/extra

Diffstat:
Asrc/extra/Makefile | 12++++++++++++
Asrc/extra/coffin.init | 39+++++++++++++++++++++++++++++++++++++++
Asrc/extra/conf.sh | 74++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++
Asrc/extra/gen.sh | 32++++++++++++++++++++++++++++++++
4 files changed, 157 insertions(+), 0 deletions(-)

diff --git a/src/extra/Makefile b/src/extra/Makefile @@ -0,0 +1,12 @@ +all: + @./gen.sh + +clean: + rm -f coffin.key + rm -f coffin.pem + +install: + @./conf.sh snowman + +uninstall: + @./conf.sh unsnowman diff --git a/src/extra/coffin.init b/src/extra/coffin.init @@ -0,0 +1,39 @@ +#!/bin/sh +### BEGIN INIT INFO +# Provides: coffin +# Required-Start: $all +# Short-Description: Starts the coffin daemon +### END INIT INFO + +PATH=/usr/local/coffin/bin:/usr/local/sbin:/usr/local/bin:/sbin:/bin:/usr/sbin:/usr/bin +DAEMON=/usr/local/coffin/bin/coffin +NAME=coffin +DESC="coffin daemon" + +text -x $DAEMON || exit 0 + +case "$1" in + start) + echo "Starting $DESC..." + start-stop-daemon \ + --start \ + --background \ + --stdout /var/run/coffin.out \ + --make-pidfile \ + --pidfile /var/run/coffin.pid \ + --exec $DAEMON + ;; + stop) + echo "Stopping $DESC..." + start-stop-daemon \ + --stop \ + --pidfile /var/run/coffin.pid \ + --exec $DAEMON + ;; + *) + echo "Usage: $0 {start|stop}" >&2 + exit 1 + ;; +esac + +exit 0 diff --git a/src/extra/conf.sh b/src/extra/conf.sh @@ -0,0 +1,74 @@ +#!/usr/bin/env zsh +# +# Copyright (c) 2016 Dyne.org Foundation +# coffin is written and maintained by parazyd <parazyd@dyne.org> +# +# This file is part of coffin +# +# This source code is free software: you can redistribute it and/or modify +# it under the terms of the GNU General Public License as published by +# the Free Software Foundation, either version 3 of the License, or +# (at your option) any later version. +# +# This software is distributed in the hope that it will be useful, +# but WITHOUT ANY WARRANTY; without even the implied warranty of +# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the +# GNU General Public License for more details. +# +# You should have received a copy of the GNU General Public License +# along with this source code. If not, see <http://www.gnu.org/licenses/>. + +apachemods() { + if [[ $1 == "on" ]]; then + mods=(ssl dav dav_fs dav_lock auth_digest) + for i in $mods; do + a2enmod $i + done + elif [[ $1 == "off" ]]; then + mods=(auth_digest dav_lock dav_fs dav ssl) + for i in $mods; do + a2dismod $i + done + fi + return 0 +} + +edit-sudoers() { + if [[ $1 == "add" ]]; then + print "%coffin `hostname`=(ALL) NOPASSWD: ALL" | (EDITOR="tee -a" visudo) + [[ $? = 0 ]] && print "Added coffin group to sudoers" + elif [[ $1 == "del" ]]; then + tmp=`sed '/^%coffin / d' /etc/sudoers` + print $tmp | (EDITOR="tee" visudo) + [[ $? = 0 ]] && print "####################\nRemoved coffin group from sudoers" + fi +} + +# because all cool software has snowmen in them: ☃ +[[ $1 == "snowman" ]] && { + [[ `grep 'coffin' /etc/group` ]] || groupadd coffin + gpasswd -a www-data coffin && \ + print "Added www-data to coffin group!" + + [[ `grep '^DAVLockDB ' /etc/apache2/apache2.conf` ]] || { + cat << EOF >> /etc/apache2/apache2.conf +<Directory /media/> + Options Indexes + AllowOverride none + Require all granted +</Directory> +DAVLockDB /etc/apache2/DAV/DAVLock +EOF + } + + apachemods on + edit-sudoers add +} + +[[ $1 == "unsnowman" ]] && { + gpasswd -d www-data coffin && \ + print "Removed www-data from coffin group!" + + apachemods off + edit-sudoers del +} diff --git a/src/extra/gen.sh b/src/extra/gen.sh @@ -0,0 +1,32 @@ +#!/bin/sh +# +# Copyright (c) 2016 Dyne.org Foundation +# coffin is written and maintained by parazyd <parazyd@dyne.org> +# +# This file is part of coffin +# +# This source code is free software: you can redistribute it and/or modify +# it under the terms of the GNU General Public License as published by +# the Free Software Foundation, either version 3 of the License, or +# (at your option) any later version. +# +# This software is distributed in the hope that it will be useful, +# but WITHOUT ANY WARRANTY; without even the implied warranty of +# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the +# GNU General Public License for more details. +# +# You should have received a copy of the GNU General Public License +# along with this source code. If not, see <http://www.gnu.org/licenses/>. + +# generate ssl cert for webdav +openssl req -x509 -nodes -days 3650 -newkey rsa:4096 \ + -keyout coffin.key -out coffin.pem + +fprint=`openssl x509 -noout -in ./coffin.pem -fingerprint \ + | awk -F\= '{print $2}'` + +echo "#############################" +echo "Successfully generated coffin's SSL certificate!" +echo "The fingerprint is: $fprint" +echo "Compare it and/or set it as trusted when you connect to coffin." +echo "#############################"