diff --git a/README.md b/README.md index 96507ef..9e709f5 100644 --- a/README.md +++ b/README.md @@ -11,7 +11,7 @@ The following commands can be used to upgrade an existing psx-pi-smbshare device cd ~ wget -O setup.sh https://raw.githubusercontent.com/toolboc/psx-pi-smbshare/master/setup.sh chmod 755 setup.sh -sudo ./setup.sh +./setup.sh ``` ## How it works @@ -124,7 +124,7 @@ This configuration will forward all ftp requests made to the host ip of the psx- IP Address = 192.168.2.2 Subnet Mask = 255.255.255.0 Default Router = 192.168.2.1 - Primary DNS = 8.8.8.8 + Primary DNS = 1.1.1.1 Secondary DNS = "Automatic" => "Do Not Use" => "Enable" @@ -153,7 +153,7 @@ Ensure that the following options are set: IP address = 192.168.2.2 Mask = 255.255.255.0 Gateway = 192.168.2.1 - DNS Server = 8.8.8.8 + DNS Server = 1.1.1.1 SMB Server Address Type = IP Address = 192.168.2.1 diff --git a/automount-usb.sh b/automount-usb.sh index ca09ebc..489b5af 100644 --- a/automount-usb.sh +++ b/automount-usb.sh @@ -8,21 +8,44 @@ # This allows for use of USB & HDD in addition to Micro-SD # It also creates a new Samba configuration which exposes the last attached USB drive @ //SMBSHARE/ +USER=`whoami` + # Update packages sudo apt-get update -# Install NTFS Read/Write Support -sudo apt-get install -y ntfs-3g +# Install NTFS Read/Write Support and udisks2 +sudo apt-get install -y ntfs-3g udisks2 + +# Add user to disk group +sudo usermod -a -G disk ${USER} + +# Create polkit rule +sudo mkdir -p /etc/polkit-1/rules.d/ +sudo mkdir -p /etc/polkit-1/localauthority/50-local.d/ + +# For polkit > 105 +sudo cat <<'EOF' | sudo tee /etc/polkit-1/rules.d/10-udisks2.rules +// Allow udisks2 to mount devices without authentication +// for users in the "disk" group. +polkit.addRule(function(action, subject) { + if ((action.id == "org.freedesktop.udisks2.filesystem-mount-system" || + action.id == "org.freedesktop.udisks2.filesystem-mount" || + action.id == "org.freedesktop.udisks2.filesystem-mount-other-seat") && + subject.isInGroup("disk")) { + return polkit.Result.YES; + } +}); +EOF -# Install pmount with ExFAT support -sudo apt-get install -y exfat-fuse exfat-utils autoconf intltool libtool libtool-bin libglib2.0-dev libblkid-dev -cd ~ -git clone https://github.com/stigi/pmount-exfat.git -cd pmount-exfat -./autogen.sh -make -sudo make install prefix=usr -sudo sed -i 's/not_physically_logged_allow = no/not_physically_logged_allow = yes/' /etc/pmount.conf +# For polkit <= 105 +sudo cat <<'EOF' | sudo tee /etc/polkit-1/localauthority/50-local.d/10-udisks2.pkla +[Authorize mounting of devices for group disk] +Identity=unix-group:disk +Action=org.freedesktop.udisks2.filesystem-mount-system;org.freedesktop.udisks2.filesystem-mount;org.freedesktop.udisks2.filesystem-mount-other-seat +ResultAny=yes +ResultInactive=yes +ResultActive=yes +EOF # Create udev rule sudo cat <<'EOF' | sudo tee /etc/udev/rules.d/usbstick.rules @@ -41,7 +64,7 @@ After=dev-%i.device Type=oneshot RemainAfterExit=yes ExecStart=/usr/local/bin/automount.sh %I -ExecStop=/usr/bin/pumount /dev/%I +ExecStop=/usr/bin/udisksctl unmount -b /dev/%I EOF sudo cat <<'EOF' | sudo tee /lib/systemd/system/usbstick-cleanup@.service @@ -60,6 +83,7 @@ sudo cat <<'EOF' | sudo tee /usr/local/bin/automount.sh #!/bin/bash PART=$1 +UUID=`blkid /dev/${PART} -o value -s UUID` FS_LABEL=`lsblk -o name,label | grep ${PART} | awk '{print $2}'` if [ -z ${PART} ] @@ -67,10 +91,12 @@ then exit fi -runuser pi -s /bin/bash -c "/usr/bin/pmount --umask 000 --noatime -w --sync /dev/${PART} /media/${PART}" +runuser userplaceholder -s /bin/bash -c "udisksctl mount -b /dev/${PART} --no-user-interaction" -pkill ps3netsrv++ -/usr/local/bin/ps3netsrv++ -d /media/$PART +if [ -f /usr/local/bin/ps3netsrv++ ]; then + pkill ps3netsrv++ + /usr/local/bin/ps3netsrv++ -d /media/userplaceholder/$UUID +fi #create a new smb share for the mounted drive cat < /etc/dnsmasq.d/custom-dnsmasq.conf