aboutsummaryrefslogtreecommitdiffstats
path: root/emulators/pipelight/files/pipelight-mkufs.in
diff options
context:
space:
mode:
Diffstat (limited to 'emulators/pipelight/files/pipelight-mkufs.in')
-rw-r--r--emulators/pipelight/files/pipelight-mkufs.in94
1 files changed, 94 insertions, 0 deletions
diff --git a/emulators/pipelight/files/pipelight-mkufs.in b/emulators/pipelight/files/pipelight-mkufs.in
new file mode 100644
index 00000000000..449f6aa5b22
--- /dev/null
+++ b/emulators/pipelight/files/pipelight-mkufs.in
@@ -0,0 +1,94 @@
+#!/bin/sh
+# Helper script for ZFS users that want to view DRM protected content
+# with pipelight
+# Author: Kris Moore <kris@pcbsd.org>
+# License: BSD
+
+destroy_old()
+{
+ umount ${userhome}/.wine-pipelight
+ zfs destroy ${zpool}/$username-pipelight
+ cat /etc/fstab | grep -v "$zpool/$username-pipelight " > /etc/fstab.new
+ mv /etc/fstab.new /etc/fstab
+}
+
+if [ -z "$1" ] ; then
+ echo "Create UFS formatted ZVOL:
+${0} <username>
+
+Remove UFS formatted ZVOL:
+${0} --remove <username>"
+ exit 1
+fi
+
+doDestroy=0
+if [ "$1" = '--remove' ] ; then
+ doDestroy=1
+ username="$2"
+else
+ username="$1"
+fi
+
+# Get users HOME
+userhome=`cat /etc/passwd | grep "^$username:" | cut -d ':' -f 6`
+if [ -z "$userhome" ] ; then
+ echo "No such user: $userhome"
+ exit 1
+fi
+if [ ! -d "$userhome" ] ; then
+ echo "No such home directory: $userhome"
+ exit 1
+fi
+
+zpool=`mount | grep 'on / ' | awk '{print $1}' | cut -d '/' -f 1`
+if [ -z "$zpool" ] ; then
+ echo "Unable to detect zpool!"
+ exit 1
+fi
+
+# If the user wants to remove the zvol
+if [ $doDestroy -eq 1 ] ; then
+ destroy_old
+ exit 0
+fi
+
+# Running this on a user which already has the file-system, lets remove it first
+zfs list ${zpool}/$username-pipelight >/dev/null 2>/dev/null
+if [ $? -eq 0 ] ; then
+ echo "Removing old UFS ZVOL"
+ destroy_old
+fi
+
+# Create the ZVOL
+zfs create -V 200M $zpool/$username-pipelight
+if [ $? -ne 0 ] ; then
+ echo "Failed creating ZVOL"
+ exit 1
+fi
+
+# Format it with UFS
+newfs -U /dev/zvol/$zpool/$username-pipelight
+if [ $? -ne 0 ] ; then
+ echo "Failed formatting ZVOL"
+ exit 1
+fi
+
+# Create the directory
+if [ ! -d "${userhome}/.wine-pipelight" ] ; then
+ mkdir ${userhome}/.wine-pipelight
+fi
+
+# Mount the directory
+mount /dev/zvol/$zpool/$username-pipelight ${userhome}/.wine-pipelight
+if [ $? -ne 0 ] ; then
+ echo "Failed mounting ZVOL"
+ exit 1
+fi
+
+# Chown the directory
+chown $username:$username ${userhome}/.wine-pipelight
+
+# Save to fstab
+echo "/dev/zvol/$zpool/$username-pipelight ${userhome}/.wine-pipelight ufs rw 0 0" >> /etc/fstab
+
+echo "ZVOL created and mounted to: ${userhome}/.wine-pipelight"