URI:
       tconf.sh - coffin - secure lan file storage on a device
  HTML git clone git://parazyd.org/coffin.git
   DIR Log
   DIR Files
   DIR Refs
   DIR Submodules
   DIR README
   DIR LICENSE
       ---
       tconf.sh (2042B)
       ---
            1 #!/usr/bin/env zsh
            2 #
            3 # Copyright (c) 2016 Dyne.org Foundation
            4 # coffin is written and maintained by parazyd <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 apachemods() {
           22         if [[ $1 == "on" ]]; then
           23                 mods=(ssl dav dav_fs dav_lock auth_digest)
           24                 for i in $mods; do
           25                         a2enmod $i
           26                 done
           27         elif [[ $1 == "off" ]]; then
           28                 mods=(auth_digest dav_lock dav_fs dav ssl)
           29                 for i in $mods; do
           30                         a2dismod $i
           31                 done
           32         fi
           33 }
           34 
           35 edit-sudoers() {
           36         if [[ $1 == "add" ]]; then
           37                 print "%coffin `hostname`=(ALL) NOPASSWD: ALL" | (EDITOR="tee -a" visudo)
           38                 [[ $? = 0 ]] && print "####################\nAdded coffin group to sudoers"
           39         elif [[ $1 == "del" ]]; then
           40                 tmp=`sed '/^%coffin / d' /etc/sudoers`
           41                 print $tmp | (EDITOR="tee" visudo)
           42                 [[ $? = 0 ]] && print "####################\nRemoved coffin group from sudoers"
           43         fi
           44 }
           45 
           46 # because all cool software has snowmen in them: ☃
           47 [[ $1 == "snowman" ]] && {
           48         [[ `grep 'coffin' /etc/group` ]] || groupadd coffin
           49         gpasswd -a www-data coffin
           50 
           51         [[ `grep '^DAVLockDB ' /etc/apache2/apache2.conf` ]] || {
           52                 cat << EOF >> /etc/apache2/apache2.conf
           53 <Directory /media/>
           54         Options Indexes
           55         AllowOverride none
           56         Require all granted
           57 </Directory>
           58 DAVLockDB /etc/apache2/DAV/DAVLock
           59 EOF
           60         }
           61 
           62         edit-sudoers add
           63         apachemods on
           64         return 0
           65 }
           66 
           67 [[ $1 == "unsnowman" ]] && {
           68         gpasswd -d www-data coffin && \
           69                 print "Removed www-data from coffin group!"
           70 
           71         edit-sudoers del
           72         apachemods off
           73 }