# HG changeset patch # User Christophe Lincoln # Date 1307826683 -7200 # Node ID 2ab2f1cbd20332b8b3b37b6f43affd4ba7266ed1 # Parent 048464223866737f9980e23bf4d90ed0996c70ca ssf-server: Add check-vdisk to check vdisk filesystem diff -r 048464223866 -r 2ab2f1cbd203 data/ssfs-server.conf --- a/data/ssfs-server.conf Sat Jun 11 22:31:07 2011 +0200 +++ b/data/ssfs-server.conf Sat Jun 11 23:11:23 2011 +0200 @@ -5,10 +5,10 @@ SSFS_CHROOT="/ssfs" # Path to Ssfs virtual disk. -SSFS_VDISK="/home/ssfs.ext3" +SSFS_VDISK="/home/ssfs.disk" # Virtual disk size in Gb. -SSFS_SIZE="10" +SSFS_SIZE="4" # User configuration file path. SSFS_USERS="/etc/ssfs/users" diff -r 048464223866 -r 2ab2f1cbd203 ssfs-server --- a/ssfs-server Sat Jun 11 22:31:07 2011 +0200 +++ b/ssfs-server Sat Jun 11 23:11:23 2011 +0200 @@ -57,6 +57,7 @@ chroot $(gettext "Chroot to Ssfs storage root.") gen-vdisk $(gettext "Create a vdisk with chroot for files storage.") clean-vdisk $(gettext "Clean the vdisk but skip home and root.") + check-vdisk $(gettext "Check vdisk filesystem with e2fsck.") mount-vdisk $(gettext "Mount ssfs virtual disk.") umount-vdisk $(gettext "Unmount the vdisk and free loop device.") @@ -122,10 +123,14 @@ } mount_vdisk() { - umount_vdisk - [ -d "$root" ] || mkdir -p $root - gettext "Mounting virtual disk:"; echo " $vdisk $root" - mount -o loop -t ext3 $vdisk $root + if ! mount | fgrep -q $root; then + [ -d "$root" ] || mkdir -p $root + gettext "Mounting virtual disk:" + mount -o loop -t ext3 $vdisk $root + else + gettext "Ssfs vdisk is already mounted:" + fi + echo " $vdisk $root" } # @@ -165,7 +170,7 @@ # We don't want any files from /etc/skel. gettext "Cleaning home and creating: Sync/..." - rm -rf $home && mkdir -p $home/Sync && status + rm -rf $home && mkdir -p $home/Sync $home/.ssh && status gettext "Changing mode on user home: 0700..." chown -R $login.$login $home chmod 0700 $home && status @@ -260,6 +265,19 @@ mount_vdisk ;; umount-vdisk) umount_vdisk ;; + check-vdisk) + # Check vdisk with e2fsck. + echo "" + gettext -e "Checking Ssfs virtual disk\n" + separator + gettext "Virtual disk : "; du -sh $vdisk + gettext "Filesystem usage : "; du -sh $root + gettext "Remounting vdisk read/only before e2fsck -p..." + mount -o remount,loop,ro $vdisk $root && status + e2fsck -p $vdisk + gettext "Remounting vdisk read/write..." + mount -o remount,loop,rw $vdisk $root && status + separator && echo "" ;; clean-vdisk) # clean up the vdisk storage chroot. if [ ! -d "$root/bin" ] || [ ! -d "$root/usr" ]; then