# HG changeset patch # User ft # Date 1393517579 -3600 # Node ID 60bc07f3f415d549d9b9fc8c445501f5af8d4c28 initial commit diff -r 000000000000 -r 60bc07f3f415 hibernate/common.conf --- /dev/null Thu Jan 01 00:00:00 1970 +0000 +++ b/hibernate/common.conf Thu Feb 27 17:12:59 2014 +0100 @@ -0,0 +1,176 @@ +# Configuration options common for suspending to disk or RAM. +# Options are not case sensitive. +# +# See hibernate.conf(5) for help on the configuration items. + +############################################################################## +### Some global settings +############################################################################## + +Verbosity 0 +LogFile /var/log/hibernate.log +LogVerbosity 1 +# LogTimestamp yes +# AlwaysForce yes +# AlwaysKill yes +# HibernateVT 15 +Distribution debian +# XDisplay :0 + +############################################################################## +### Scriptlets +### Scriptlets provide support for doing all sorts of things before and after +### suspending. The defaults settings here should work for most people, but +### you may wish to edit these to taste. Consult "hibernate -h" for help on +### the configuration settings. +############################################################################## + +### bootsplash +## If you use bootsplash, also enabling SwitchToTextMode is recommended if +## you use X, otherwise you may end up with a garbled X display. +# Bootsplash on +# BootsplashConfig /etc/bootsplash/default/config/bootsplash-1024x768.cfg + +### clock +SaveClock restore-only +#DirectIsa + +### devices +# IncompatibleDevices /dev/dsp /dev/video* + +### diskcache +# DisableWriteCacheOn /dev/hda + +### fbsplash (enable SwitchToTextMode if you use this) +# FBSplash on +# FBSplashTheme tuxonice + +### filesystems +# Unmount /nfsshare /windows /mnt/sambaserver +# UnmountFSTypes smbfs nfs +# UnmountGraceTime 1 +# Mount /windows + +### grub +# ChangeGrubMenu yes +# GrubMenuFile /boot/grub/grub.cfg +# AlternateGrubMenuFile /boot/grub/grub-suspended.cfg +# BackupGrubMenuFile /var/backups/grub.cfg.hibernate + +# see http://bugs.debian.org/317479 +# RemountXFSBoot yes + +### hardware_tweaks +# IbmAcpi yes +# RadeonTool yes +# Runi915resolution yes +# FullSpeedCPU yes + +### lilo +# EnsureLILOResumes yes + +### lock (generally you only want one of the following options) +## For console you need vlock available. +## For x you need xscreensaver-command-command available. +## For gnome you need gnome-screensaver-command available. +## For kde you need dcop, kscreensaver available. +## For XAuto you need xautolock available. +## For Xtr you need xtrlock available. +## For Freedesktop (for example KDE4) you need dbus-send available +# LockConsoleAs root +# LockXScreenSaver yes +# LockGnomeScreenSaver yes +# LockFreedesktop +# LockKDE yes +# LockXLock yes +# LockXAutoLock yes +# LockXtrLock yes + +### misclaunch +# OnSuspend 20 echo "Good night!" +# OnResume 20 echo "Good morning!" + +### modules +# UnloadModules snd_via82cxxx usb-ohci +# UnloadAllModules yes +UnloadBlacklistedModules yes +LoadModules auto +# LoadModulesFromFile /etc/modules + +### modules-gentoo +# GentooModulesAutoload yes + +### network +# DownInterfaces eth0 +# UpInterfaces auto + +### networkmanager +# EnableNMReconnect yes + +### wicd +# EnableWICDReconnect yes + +### pause_audio +# MuteAudio yes +# PauseAudio yes + +### pcmcia +# EjectCards yes + +### programs +# IncompatiblePrograms xmms + +### services +# RestartServices laptop-mode anacron +# StopServices alsasound +# StartServices aumix + +### vbetool +# EnableVbetool yes +# RestoreVbeStateFrom /var/lib/vbetool/vbestate +# VbetoolPost yes +# RestoreVCSAData yes + +### xhacks +SwitchToTextMode yes +# UseDummyXServer yes +# DummyXServerConfig xorg-dummy.conf + +### xstatus +## This can be set to gnome, kde or x: +## For gnome you need zenity available. +## For kde you need dcop, kstart, kdialog available. +## For x you need to have xosd OR xmessage available. +# XStatus gnome +# XmessageDisable yes +# XSuspendText Preparing to suspend... +# XResumeText Resuming from suspend... +## When using XStatus x, and you have xosd installed: +# XosdSettings --font '-misc-fixed-medium-r-semicondensed--*-120-*-*-c-*-*-*' --colour=Green --shadow 1 --pos bottom --align center --offset 50 + +### xbacklight +# BackLight yes + +### gaim +## You need to have dbus, gaim_remote available. +# LogoutGaim yes +# GaimRestoreStatus yes +# GaimLogoutMessage Hibernating +# GaimLoginMessage Back from hibernation + +### pidgin +# LogoutPidgin yes +# PidginRestoreStatus yes +# PidginLogoutMessage Hibernating - bye! +# PidginLoginMessage I'm back! + +### SSH and PGP keys +# AgentsClearGPG yes +# AgentsClearSSH yes + +### Virtualbox +# SuspendVirtualbox yes + +# osecvm +StopServices vboxadd-service vboxadd rc.local +StartServices vboxadd vboxadd-service rc.local diff -r 000000000000 -r 60bc07f3f415 init.d/osecfs_downloads --- /dev/null Thu Jan 01 00:00:00 1970 +0000 +++ b/init.d/osecfs_downloads Thu Feb 27 17:12:59 2014 +0100 @@ -0,0 +1,50 @@ +#! /bin/sh +### BEGIN INIT INFO +# Provides: osecfsmount +# Required-Start: $all +# Required-Stop: +# Default-Start: 2 3 4 5 +# Default-Stop: 0 1 6 +# Short-Description: Mounts /home/osecuser/Downloads to /var/run/Downloads with osecfs +# Description: Mounts /home/osecuser/Downloads to /var/run/Downloads with osecfs +### END INIT INFO + +do_start () { + # + # If login delaying is enabled then remove the flag file + # + mkdir -p /var/run/Downloads + /usr/bin/osecfs /etc/osecfs/osecfs_downloads.cfg /var/run/Downloads ro +} + +do_status () { + /bin/df -hT +} + +do_stop () { + /bin/umount /var/run/Downloads + rmdir /var/run/Downloads +} + +case "$1" in + start) + do_start + ;; + restart|reload|force-reload) + echo "Error: argument '$1' not supported" >&2 + exit 3 + ;; + stop) + do_stop + ;; + status) + do_status + exit $? + ;; + *) + echo "Usage: $0 start|stop" >&2 + exit 3 + ;; +esac + +: diff -r 000000000000 -r 60bc07f3f415 logrotate.d/usbmount --- /dev/null Thu Jan 01 00:00:00 1970 +0000 +++ b/logrotate.d/usbmount Thu Feb 27 17:12:59 2014 +0100 @@ -0,0 +1,12 @@ +/var/log/usbmount +{ + rotate 4 + weekly + missingok + notifempty + compress + sharedscripts + postrotate + invoke-rc.d rsyslog rotate > /dev/null + endscript +} diff -r 000000000000 -r 60bc07f3f415 network/if-pre-up.d/01_ssh_only_eth0 --- /dev/null Thu Jan 01 00:00:00 1970 +0000 +++ b/network/if-pre-up.d/01_ssh_only_eth0 Thu Feb 27 17:12:59 2014 +0100 @@ -0,0 +1,11 @@ +#!/bin/sh + +# Only run once (not for every interface) +if [ "$IFACE" != "--all" ] +then + exit 0 +fi + +# only allow ssh connections on eth0 (host only) +iptables -A INPUT -i eth0 -p tcp --dport 22 -j ACCEPT +iptables -A INPUT -p tcp --dport 22 -j REJECT diff -r 000000000000 -r 60bc07f3f415 osecvm-config --- /dev/null Thu Jan 01 00:00:00 1970 +0000 +++ b/osecvm-config Thu Feb 27 17:12:59 2014 +0100 @@ -0,0 +1,108 @@ +### Commented entries have reasonable defaults. +### Uncomment to edit them. +# Source: +Section: misc +Priority: optional +# Homepage: +Standards-Version: 3.9.2 + +Package: osecvm-config +Version: 0.0.30 +Maintainer: ft +Pre-Depends: samba,usbmount,python,python-fuse,python-requests,ntfs-3g,rsyslog,logrotate,osecfs,python-webpy,python-netifaces,osecvm-password-receiver,python-netifaces,python-netaddr,ipcalc,file,sudo,hibernate +# Depends: +# Recommends: +# Suggests: +# Provides: +# Replaces: +Architecture: all +# Copyright: +# Changelog: +# Readme: +# Extra-Files: +Files: logrotate.d/usbmount /etc/osecvm-configs/ + rsyslog.d/usbmount.conf /etc/osecvm-configs/ + samba/smb.conf /etc/osecvm-configs/ + usbmount/usbmount.conf /etc/osecvm-configs/ + usbmount/mount.d/00_create_model_symlink /etc/osecvm-configs/ + usbmount/umount.d/00_remove_model_symlink /etc/osecvm-configs/ + usr/share/usbmount/usbmount /etc/osecvm-configs/ + usr/share/usbmount/async_usbmount /etc/osecvm-configs/ + init.d/osecfs_downloads /etc/ + rc.local /etc/osecvm-configs/ + network/if-pre-up.d/01_ssh_only_eth0 /etc/osecvm-configs/ + sudoers /etc/osecvm-configs/ + hibernate/common.conf /etc/osecvm-configs/ +File: postinst + #!/bin/sh -e + # preinst for main-package-config. Divert some configuration file of main-package. + . + set -e + . + if [ -f "/etc/init.d/osecfs_downloads" ] + then + /etc/init.d/osecfs_downloads stop + fi + . + PKG=osecvm-config + PKG_LIST="logrotate.d/usbmount rsyslog.d/usbmount.conf samba/smb.conf usbmount/usbmount.conf usbmount/mount.d/00_create_model_symlink usbmount/umount.d/00_remove_model_symlink rc.local network/if-pre-up.d/01_ssh_only_eth0 hibernate/common.conf" + . + if [ "$1" = configure ] + then + . + for f in $PKG_LIST + do + dpkg-divert --add --package ${PKG} --rename --divert /etc/$f.distrib /etc/$f + [ \! -e /etc/$f -o -L /etc/$f ] && ln -sf /etc/osecvm-configs/$f /etc/$f + done + . + fi + . + dpkg-divert --add --package ${PKG} --rename --divert /usr/share/usbmount/usbmount.distrib /usr/share/usbmount/usbmount + [ \! -e /usr/share/usbmount/usbmount -o -L /usr/share/usbmount/usbmount ] && ln -sf /etc/osecvm-configs/usr/share/usbmount/usbmount /usr/share/usbmount/usbmount + . + dpkg-divert --add --package ${PKG} --rename --divert /usr/share/usbmount/async_usbmount.distrib /usr/share/usbmount/async_usbmount + [ \! -e /usr/share/usbmount/async_usbmount -o -L /usr/share/usbmount/async_usbmount ] && ln -sf /etc/osecvm-configs/usr/share/usbmount/async_usbmount /usr/share/usbmount/async_usbmount + . + dpkg-divert --add --package ${PKG} --rename --divert /etc/sudoers.distrib /etc/sudoers + [ \! -e /etc/sudoers -o -L /etc/sudoers ] && cp -v /etc/osecvm-configs/sudoers /etc/sudoers + . + /etc/init.d/rsyslog restart + /etc/init.d/samba restart + mkdir -p /home/osecuser/Downloads + chown osecuser:osecuser /home/osecuser/Downloads + update-rc.d osecfs_downloads defaults + /etc/init.d/osecfs_downloads start + chmod 440 /etc/osecvm-configs/sudoers + . + exit 0 +File: prerm + #!/bin/sh -e + # prerm for main-package-config. Divert some configuration file of main-package. + . + set -e + . + PKG=osecvm-config + PKG_LIST="logrotate.d/usbmount rsyslog.d/usbmount.conf samba/smb.conf usbmount/usbmount.conf usbmount/mount.d/00_create_model_symlink usbmount/umount.d/00_remove_model_symlink rc.local network/if-pre-up.d/01_ssh_only_eth0 sudoers hibernate/common.conf" + . + if [ "$1" = remove -o "$1" = purge ] + then + . + # make sure to include all the files inside $PKG.tar.gz in this *for* cycle. + for f in $PKG_LIST + do + [ -L /etc/$f ] && rm /etc/$f + dpkg-divert --remove --package $PKG --rename --divert /etc/$f.distrib /etc/$f + done + . + fi + . + [ -L /usr/share/usbmount/usbmount ] && rm /usr/share/usbmount/usbmount + dpkg-divert --remove --package $PKG --rename --divert /usr/share/usbmount/usbmount.distrib /usr/share/usbmount/usbmount + . + /etc/init.d/osecfs_downloads stop + update-rc.d osecfs_downloads remove + . + exit 0 +Description: Default configuration for osecvm + Brings default configuration files for some pakages diff -r 000000000000 -r 60bc07f3f415 osecvm-config.conf --- /dev/null Thu Jan 01 00:00:00 1970 +0000 +++ b/osecvm-config.conf Thu Feb 27 17:12:59 2014 +0100 @@ -0,0 +1,2 @@ +# Original main-package.conf file. +# Do not touch it!! It belongs to dpkg. diff -r 000000000000 -r 60bc07f3f415 osecvm-config_0.0.10_all.deb Binary file osecvm-config_0.0.10_all.deb has changed diff -r 000000000000 -r 60bc07f3f415 osecvm-config_0.0.11_all.deb Binary file osecvm-config_0.0.11_all.deb has changed diff -r 000000000000 -r 60bc07f3f415 osecvm-config_0.0.12_all.deb Binary file osecvm-config_0.0.12_all.deb has changed diff -r 000000000000 -r 60bc07f3f415 osecvm-config_0.0.13_all.deb Binary file osecvm-config_0.0.13_all.deb has changed diff -r 000000000000 -r 60bc07f3f415 osecvm-config_0.0.14_all.deb Binary file osecvm-config_0.0.14_all.deb has changed diff -r 000000000000 -r 60bc07f3f415 osecvm-config_0.0.15_all.deb Binary file osecvm-config_0.0.15_all.deb has changed diff -r 000000000000 -r 60bc07f3f415 osecvm-config_0.0.16_all.deb Binary file osecvm-config_0.0.16_all.deb has changed diff -r 000000000000 -r 60bc07f3f415 osecvm-config_0.0.17_all.deb Binary file osecvm-config_0.0.17_all.deb has changed diff -r 000000000000 -r 60bc07f3f415 osecvm-config_0.0.18_all.deb Binary file osecvm-config_0.0.18_all.deb has changed diff -r 000000000000 -r 60bc07f3f415 osecvm-config_0.0.19_all.deb Binary file osecvm-config_0.0.19_all.deb has changed diff -r 000000000000 -r 60bc07f3f415 osecvm-config_0.0.1_all.deb Binary file osecvm-config_0.0.1_all.deb has changed diff -r 000000000000 -r 60bc07f3f415 osecvm-config_0.0.20_all.deb Binary file osecvm-config_0.0.20_all.deb has changed diff -r 000000000000 -r 60bc07f3f415 osecvm-config_0.0.21_all.deb Binary file osecvm-config_0.0.21_all.deb has changed diff -r 000000000000 -r 60bc07f3f415 osecvm-config_0.0.22_all.deb Binary file osecvm-config_0.0.22_all.deb has changed diff -r 000000000000 -r 60bc07f3f415 osecvm-config_0.0.23_all.deb Binary file osecvm-config_0.0.23_all.deb has changed diff -r 000000000000 -r 60bc07f3f415 osecvm-config_0.0.24_all.deb Binary file osecvm-config_0.0.24_all.deb has changed diff -r 000000000000 -r 60bc07f3f415 osecvm-config_0.0.25_all.deb Binary file osecvm-config_0.0.25_all.deb has changed diff -r 000000000000 -r 60bc07f3f415 osecvm-config_0.0.26_all.deb Binary file osecvm-config_0.0.26_all.deb has changed diff -r 000000000000 -r 60bc07f3f415 osecvm-config_0.0.27_all.deb Binary file osecvm-config_0.0.27_all.deb has changed diff -r 000000000000 -r 60bc07f3f415 osecvm-config_0.0.28_all.deb Binary file osecvm-config_0.0.28_all.deb has changed diff -r 000000000000 -r 60bc07f3f415 osecvm-config_0.0.29_all.deb Binary file osecvm-config_0.0.29_all.deb has changed diff -r 000000000000 -r 60bc07f3f415 osecvm-config_0.0.2_all.deb Binary file osecvm-config_0.0.2_all.deb has changed diff -r 000000000000 -r 60bc07f3f415 osecvm-config_0.0.30_all.deb Binary file osecvm-config_0.0.30_all.deb has changed diff -r 000000000000 -r 60bc07f3f415 osecvm-config_0.0.3_all.deb Binary file osecvm-config_0.0.3_all.deb has changed diff -r 000000000000 -r 60bc07f3f415 osecvm-config_0.0.4_all.deb Binary file osecvm-config_0.0.4_all.deb has changed diff -r 000000000000 -r 60bc07f3f415 osecvm-config_0.0.5_all.deb Binary file osecvm-config_0.0.5_all.deb has changed diff -r 000000000000 -r 60bc07f3f415 osecvm-config_0.0.6_all.deb Binary file osecvm-config_0.0.6_all.deb has changed diff -r 000000000000 -r 60bc07f3f415 osecvm-config_0.0.7_all.deb Binary file osecvm-config_0.0.7_all.deb has changed diff -r 000000000000 -r 60bc07f3f415 osecvm-config_0.0.8_all.deb Binary file osecvm-config_0.0.8_all.deb has changed diff -r 000000000000 -r 60bc07f3f415 osecvm-config_0.0.9_all.deb Binary file osecvm-config_0.0.9_all.deb has changed diff -r 000000000000 -r 60bc07f3f415 rc.local --- /dev/null Thu Jan 01 00:00:00 1970 +0000 +++ b/rc.local Thu Feb 27 17:12:59 2014 +0100 @@ -0,0 +1,31 @@ +#!/bin/sh -e +# +# rc.local +# +# This script is executed at the end of each multiuser runlevel. +# Make sure that the script will "exit 0" on success or any other +# value on error. +# +# In order to enable or disable this script just change the execution +# bits. +# +# By default this script does nothing. + +getRemoteIp () +{ + ip_address=$(ifconfig eth0 | grep "inet " | awk '{ print $2 }' | cut -d ":" -f 2) + ip_netmask=$(ifconfig eth0 | grep "inet " | awk '{ print $4 }' | cut -d ":" -f 2) + remote_ip=$(ipcalc $ip_address/$ip_netmask | grep HostMin | awk '{ print $2}') + + echo $remote_ip +} + + +# Disable error exit (not usefull for this command) +#set +e +#wget -q -T 3 -t 1 -O /dev/null http://$(getRemoteIp):8080/sdvm_started +#set -e +VBoxControl guestproperty set SDVMStarted True + + +exit 0 diff -r 000000000000 -r 60bc07f3f415 rsyslog.d/usbmount.conf --- /dev/null Thu Jan 01 00:00:00 1970 +0000 +++ b/rsyslog.d/usbmount.conf Thu Feb 27 17:12:59 2014 +0100 @@ -0,0 +1,2 @@ +# extra usbmount log +:syslogtag, contains, "usbmount" /var/log/usbmount.log diff -r 000000000000 -r 60bc07f3f415 samba/smb.conf --- /dev/null Thu Jan 01 00:00:00 1970 +0000 +++ b/samba/smb.conf Thu Feb 27 17:12:59 2014 +0100 @@ -0,0 +1,46 @@ +[global] + interfaces = eth0 lo + bind interfaces only = yes + workgroup = osec + restrict anonymous = no + server string = osecvm + security = share + disable spoolss = yes + unix extensions = no + guest account = root + + + # disable printing + load printers = no + printing = cups + printcap name = /dev/null + show add printer wizard = no + disable spoolss = yes + + # disable netbios + disable netbios = yes + +[USB] + comment = Zugriff auf USB Sticks + path = /var/run/usbmount/ + read only = no + browseable = yes + writeable = yes + follow symlinks = yes + available = yes + public = yes + guest ok = yes + wide links = no + +[Download] + comment = Zugriff auf Downloads + path = /var/run/Downloads/ + read only = yes + browseable = yes + writeable = no + follow symlinks = yes + available = yes + public = yes + guest ok = yes + wide links = no + diff -r 000000000000 -r 60bc07f3f415 sudoers --- /dev/null Thu Jan 01 00:00:00 1970 +0000 +++ b/sudoers Thu Feb 27 17:12:59 2014 +0100 @@ -0,0 +1,33 @@ +# +# This file MUST be edited with the 'visudo' command as root. +# +# Please consider adding local content in /etc/sudoers.d/ instead of +# directly modifying this file. +# +# See the man page for details on how to write a sudoers file. +# +Defaults env_reset +Defaults mail_badpass +Defaults secure_path="/usr/local/sbin:/usr/local/bin:/usr/sbin:/usr/bin:/sbin:/bin" + +# Host alias specification + +# User alias specification + +# Cmnd alias specification + +# User privilege specification +root ALL=(ALL:ALL) ALL + +osecuser ALL=(root)NOPASSWD:/usr/bin/apt-get -y up* +osecuser ALL=(root)NOPASSWD:/usr/bin/apt-get -y dist-upgrade* +osecuser ALL=(root)NOPASSWD:/sbin/shutdown* +osecuser ALL=(root)NOPASSWD:/usr/sbin/hibernate-disk* + + +# Allow members of group sudo to execute any command +%sudo ALL=(ALL:ALL) ALL + +# See sudoers(5) for more information on "#include" directives: + +#includedir /etc/sudoers.d diff -r 000000000000 -r 60bc07f3f415 usbmount/mount.d/00_create_model_symlink --- /dev/null Thu Jan 01 00:00:00 1970 +0000 +++ b/usbmount/mount.d/00_create_model_symlink Thu Feb 27 17:12:59 2014 +0100 @@ -0,0 +1,41 @@ +#!/bin/sh +# This script creates the model name symlink in /var/run/usbmount. +# Copyright (C) 2005 Martin Dickopp +# +# This file is free software; the copyright holder gives unlimited +# permission to copy and/or distribute it, with or without +# modifications, as long as this notice is preserved. +# +# This file is distributed in the hope that it will be useful, +# but WITHOUT ANY WARRANTY, to the extent permitted by law; without +# even the implied warranty of MERCHANTABILITY or FITNESS FOR A +# PARTICULAR PURPOSE. +# +set -e + +# Replace spaces with underscores, remove special characters in vendor +# and model name. +UM_VENDOR=`echo "$UM_VENDOR" | sed 's/ /_/g; s/[^0123456789abcdefghijklmnopqrstuvwxyzABCDEFGHIJKLMNOPQRSTUVWXYZ._-]//g'` +UM_MODEL=`echo "$UM_MODEL" | sed 's/ /_/g; s/[^0123456789abcdefghijklmnopqrstuvwxyzABCDEFGHIJKLMNOPQRSTUVWXYZ._-]//g'` + +# Exit if both vendor and model name are empty. +test -n "$UM_VENDOR" || test -n "$UM_MODEL" || exit 0 + +# Build symlink name. +if test -n "$UM_VENDOR" && test -n "$UM_MODEL"; then + name="${UM_VENDOR}_$UM_MODEL" +else + name="$UM_VENDOR$UM_MODEL" +fi + +# Append partition number, if any, to the symlink name. +partition=`echo "$UM_DEVICE" | sed 's/^.*[^0123456789]\([0123456789]*\)/\1/'` +if test -n "$partition"; then + name="${name}_$partition" +fi + +mkdir -p "/var/run/usbmount/$name" +osecfs /etc/osecfs/osecfs_usb.cfg /var/run/usbmount/$name ro + + +exit 0 diff -r 000000000000 -r 60bc07f3f415 usbmount/umount.d/00_remove_model_symlink --- /dev/null Thu Jan 01 00:00:00 1970 +0000 +++ b/usbmount/umount.d/00_remove_model_symlink Thu Feb 27 17:12:59 2014 +0100 @@ -0,0 +1,19 @@ +#!/bin/sh +# This script removes the model name symlink in /var/run/usbmount. +# Copyright (C) 2005 Martin Dickopp +# +# This file is free software; the copyright holder gives unlimited +# permission to copy and/or distribute it, with or without +# modifications, as long as this notice is preserved. +# +# This file is distributed in the hope that it will be useful, +# but WITHOUT ANY WARRANTY, to the extent permitted by law; without +# even the implied warranty of MERCHANTABILITY or FITNESS FOR A +# PARTICULAR PURPOSE. +# +set -e + +umount "/var/run/usbmount/"* +rmdir "/var/run/usbmount/"* + +exit 0 diff -r 000000000000 -r 60bc07f3f415 usbmount/usbmount.conf --- /dev/null Thu Jan 01 00:00:00 1970 +0000 +++ b/usbmount/usbmount.conf Thu Feb 27 17:12:59 2014 +0100 @@ -0,0 +1,53 @@ +# Configuration file for the usbmount package, which mounts removable +# storage devices when they are plugged in and unmounts them when they +# are removed. + +# Change to zero to disable usbmount +ENABLED=1 + +# Mountpoints: These directories are eligible as mointpoints for +# removable storage devices. A newly plugged in device is mounted on +# the first directory in this list that exists and on which nothing is +# mounted yet. +MOUNTPOINTS="/media/usb0 /media/usb1 /media/usb2 /media/usb3 + /media/usb4 /media/usb5 /media/usb6 /media/usb7" + +# Filesystem types: removable storage devices are only mounted if they +# contain a filesystem type which is in this list. +FILESYSTEMS="vfat ext2 ext3 ext4 hfsplus ntfs fuseblk" + +############################################################################# +# WARNING! # +# # +# The "sync" option may not be a good choice to use with flash drives, as # +# it forces a greater amount of writing operating on the drive. This makes # +# the writing speed considerably lower and also leads to a faster wear out # +# of the disk. # +# # +# If you omit it, don't forget to use the command "sync" to synchronize the # +# data on your disk before removing the drive or you may experience data # +# loss. # +# # +# It is highly recommended that you use the pumount command (as a regular # +# user) before unplugging the device. It makes calling the "sync" command # +# and mounting with the sync option unnecessary---this is similar to other # +# operating system's "safely disconnect the device" option. # +############################################################################# +# Mount options: Options passed to the mount command with the -o flag. +# See the warning above regarding removing "sync" from the options. +MOUNTOPTIONS="sync,noexec,nodev,noatime,nodiratime" + +# Filesystem type specific mount options: This variable contains a space +# separated list of strings, each which the form "-fstype=TYPE,OPTIONS". +# +# If a filesystem with a type listed here is mounted, the corresponding +# options are appended to those specificed in the MOUNTOPTIONS variable. +# +# For example, "-fstype=vfat,gid=floppy,dmask=0007,fmask=0117" would add +# the options "gid=floppy,dmask=0007,fmask=0117" when a vfat filesystem +# is mounted. +FS_MOUNTOPTIONS="" + +# If set to "yes", more information will be logged via the syslog +# facility. +VERBOSE=yes diff -r 000000000000 -r 60bc07f3f415 usr/share/usbmount/async_usbmount --- /dev/null Thu Jan 01 00:00:00 1970 +0000 +++ b/usr/share/usbmount/async_usbmount Thu Feb 27 17:12:59 2014 +0100 @@ -0,0 +1,251 @@ +#!/bin/sh +# This script mounts USB mass storage devices when they are plugged in +# and unmounts them when they are removed. +# Copyright © 2004, 2005 Martin Dickopp +# Copyright © 2008, 2009, 2010 Rogério Theodoro de Brito +# +# This file is free software; the copyright holder gives unlimited +# permission to copy and/or distribute it, with or without +# modifications, as long as this notice is preserved. +# +# This file is distributed in the hope that it will be useful, +# but WITHOUT ANY WARRANTY, to the extent permitted by law; without +# even the implied warranty of MERCHANTABILITY or FITNESS FOR A +# PARTICULAR PURPOSE. +# +set -e +exec > /dev/null 2>&1 + +###################################################################### +# Auxiliary functions + +# Log a string via the syslog facility. +log() +{ + if [ $1 != debug ] || expr "$VERBOSE" : "[yY]" > /dev/null; then + logger -p user.$1 -t "usbmount[$$]" -- "$2" + fi +} + + +# Test if the first parameter is in the list given by the second +# parameter. +in_list() +{ + for v in $2; do + [ "$1" != "$v" ] || return 0 + done + return 1 +} + + +###################################################################### +# Main program + +# Default values for configuration variables. +ENABLED=1 +MOUNTPOINTS= +FILESYSTEMS= +MOUNTOPTIONS= +FS_MOUNTOPTIONS= +VERBOSE=no + +if [ -r /etc/usbmount/usbmount.conf ]; then + . /etc/usbmount/usbmount.conf + log debug "loaded usbmount configurations" +fi + +if [ "${ENABLED:-1}" -eq 0 ]; then + log info "usbmount is disabled, see /etc/usbmount/usbmount.conf" + exit 0 +fi + +if [ ! -x /sbin/blkid ]; then + log err "cannot execute /sbin/blkid" + exit 1 +fi + +# Per Policy 9.3.2, directories under /var/run have to be created +# after every reboot. +if [ ! -e /var/run/usbmount ]; then + mkdir -p /var/run/usbmount + log debug "creating /var/run/usbmount directory" +fi + +umask 022 + +if [ "$1" = add ]; then + + # Acquire lock. + log debug "trying to acquire lock /var/run/usbmount/.mount.lock" + lockfile-create --retry 3 /var/run/usbmount/.mount || \ + { log err "cannot acquire lock /var/run/usbmount/.mount.lock"; exit 1; } + trap '( lockfile-remove /var/run/usbmount/.mount )' 0 + log debug "acquired lock /var/run/usbmount/.mount.lock" + + # Grab device information from device and "divide it" + # FIXME: improvement: implement mounting by label (notice that labels + # can contain spaces, which makes things a little bit less comfortable). + + set +e + DEVINFO=$(/sbin/blkid -p $DEVNAME) + BLKID_RESULT="$?" + if [ "$BLKID_RESULT" != "0" ] + then + log info "blkid -p $DEVNAME has retured with $BLKID_RESULT" + log info "Stick is maybe encrypted. Try decrypt" + wget -q -T 3 -t 1 -O /dev/null http://192.168.56.1:8090/password?text=Please+send+me+the+password + if [ "$?" != "0" ] + then + log err "Connection to http://192.168.56.1:8090/password?text=Please+send+me+the+password failed" + exit 1 + fi + log info "Password notification sended, wait for response" + + /usr/bin/osecvm-password-receiver.py eth0 58080 $DEVNAME /media/usb0 + if [ "$?" != "0" ] + then + log err "Stick removed. exit" + exit 1 + fi + + mkdir -p "/var/run/usbmount/encrypted" + /usr/bin/osecfs /etc/osecfs/osecfs_usb.cfg "/var/run/usbmount/encrypted" rw + log info "Encrypted stick mounted" + exit 0 + fi + set -e + + FSTYPE=$(echo "$DEVINFO" | sed 's/.*[[:blank:]]TYPE="\([^"]*\)".*/\1/g; s/[[:blank:]]*//g;') + UUID=$(echo "$DEVINFO" | sed 's/.*[[:blank:]]UUID="\([^"]*\)".*/\1/g; s/[[:blank:]]*//g;') + USAGE=$(echo "$DEVINFO" | sed 's/.*[[:blank:]]USAGE="\([^"]*\)".*/\1/g; s/[[:blank:]]*//g;') + + if ! echo $USAGE | egrep -q "(filesystem|disklabel)"; then + log info "$DEVNAME does not contain a filesystem or disklabel" + exit 1 + fi + + + # Try to use specifications in /etc/fstab first. + if egrep -q "^[[:blank:]]*$DEVNAME" /etc/fstab; then + log info "executing command: mount $DEVNAME" + mount $DEVNAME || log err "mount by DEVNAME with $DEVNAME wasn't successful; return code $?" + + elif grep -q "^[[:blank:]]*UUID=$UUID" /etc/fstab; then + log info "executing command: mount -U $UUID" + mount -U $UUID || log err "mount by UUID with $UUID wasn't successful; return code $?" + + else + log debug "$DEVNAME contains filesystem type $FSTYPE" + + fstype=$FSTYPE + # Test if the filesystem type is in the list of filesystem + # types to mount. + if in_list "$fstype" "$FILESYSTEMS"; then + # Search an available mountpoint. + for v in $MOUNTPOINTS; do + if [ -d "$v" ] && ! grep -q "^[^ ][^ ]* *$v " /proc/mounts; then + mountpoint="$v" + log debug "mountpoint $mountpoint is available for $DEVNAME" + break + fi + done + if [ -n "$mountpoint" ]; then + # Determine mount options. + options= + for v in $FS_MOUNTOPTIONS; do + if expr "$v" : "-fstype=$fstype,."; then + options="$(echo "$v" | sed 's/^[^,]*,//')" + break + fi + done + if [ -n "$MOUNTOPTIONS" ]; then + options="$MOUNTOPTIONS${options:+,$options}" + fi + + # Mount the filesystem. + log info "executing command: mount -t$fstype ${options:+-o$options} $DEVNAME $mountpoint" + mount "-t$fstype" "${options:+-o$options}" "$DEVNAME" "$mountpoint" + + # Determine vendor and model. + vendor= + if [ -r "/sys$DEVPATH/device/vendor" ]; then + vendor="`cat \"/sys$DEVPATH/device/vendor\"`" + elif [ -r "/sys$DEVPATH/../device/vendor" ]; then + vendor="`cat \"/sys$DEVPATH/../device/vendor\"`" + elif [ -r "/sys$DEVPATH/device/../manufacturer" ]; then + vendor="`cat \"/sys$DEVPATH/device/../manufacturer\"`" + elif [ -r "/sys$DEVPATH/../device/../manufacturer" ]; then + vendor="`cat \"/sys$DEVPATH/../device/../manufacturer\"`" + fi + vendor="$(echo "$vendor" | sed 's/^[[:blank:]]\+//; s/[[:blank:]]\+$//')" + + model= + if [ -r "/sys$DEVPATH/device/model" ]; then + model="`cat \"/sys$DEVPATH/device/model\"`" + elif [ -r "/sys$DEVPATH/../device/model" ]; then + model="`cat \"/sys$DEVPATH/../device/model\"`" + elif [ -r "/sys$DEVPATH/device/../product" ]; then + model="`cat \"/sys$DEVPATH/device/../product\"`" + elif [ -r "/sys$DEVPATH/../device/../product" ]; then + model="`cat \"/sys$DEVPATH/../device/../product\"`" + fi + model="$(echo "$model" | sed 's/^[[:blank:]]\+//; s/[[:blank:]]\+$//')" + + # Run hook scripts; ignore errors. + export UM_DEVICE="$DEVNAME" + export UM_MOUNTPOINT="$mountpoint" + export UM_FILESYSTEM="$fstype" + export UM_MOUNTOPTIONS="$options" + export UM_VENDOR="$vendor" + export UM_MODEL="$model" + log info "executing command: run-parts /etc/usbmount/mount.d" + run-parts /etc/usbmount/mount.d || : + else + # No suitable mount point found. + log warning "no mountpoint found for $DEVNAME" + exit 1 + fi + fi + fi +elif [ "$1" = remove ]; then + + # A block or partition device has been removed. + # Test if it is mounted. + for device in $(/usr/bin/truecrypt -l | awk '{ print $2}') + do + if [ "$DEVNAME" = "$device" ] + then + log info "encrypted device was removed" + umount "/var/run/usbmount/encrypted" + rmdir "/var/run/usbmount/encrypted" + log info "/usr/bin/truecrypt -d $DEVNAME" + /usr/bin/truecrypt -d "$DEVNAME" + log info "everything done" + fi + done + while read device mountpoint fstype remainder; do + if [ "$DEVNAME" = "$device" ]; then + # If the mountpoint and filesystem type are maintained by + # this script, unmount the filesystem. + if in_list "$mountpoint" "$MOUNTPOINTS" && + in_list "$fstype" "$FILESYSTEMS"; then + log info "executing command: umount -l $mountpoint" + umount -l "$mountpoint" + + # Run hook scripts; ignore errors. + export UM_DEVICE="$DEVNAME" + export UM_MOUNTPOINT="$mountpoint" + export UM_FILESYSTEM="$fstype" + log info "executing command: run-parts /etc/usbmount/umount.d" + run-parts /etc/usbmount/umount.d || : + fi + break + fi + done < /proc/mounts +else + log err "unexpected: action '$1'" + exit 1 +fi + +log debug "usbmount execution finished" diff -r 000000000000 -r 60bc07f3f415 usr/share/usbmount/usbmount --- /dev/null Thu Jan 01 00:00:00 1970 +0000 +++ b/usr/share/usbmount/usbmount Thu Feb 27 17:12:59 2014 +0100 @@ -0,0 +1,16 @@ +#!/bin/sh + +# run usbmount asyncron from udev +# wait in the subshell until the network comes up and then start the rest +( + +if [ "$1" != "remove" ] +then + while [ -z "$(ifconfig eth0 | grep "inet addr:")" ] + do + sleep 0.5 + done +fi + +/usr/share/usbmount/async_usbmount $1 +) &