Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
9 changes: 9 additions & 0 deletions rpi/enable-automount.sh
Original file line number Diff line number Diff line change
@@ -0,0 +1,9 @@
#!/bin/bash

BASEDIR=$HOME

# initially this is just USB automount at some point we might add the wifi stuff
sudo ln -sf $BASEDIR/pellcorp/rpi/etc/automount /etc
sudo cp $BASEDIR/pellcorp/rpi/etc/systemd/system/usb-mount\@.service /etc/systemd/system/
sudo cp $BASEDIR/pellcorp/rpi/etc/udev/rules.d/99-automount.rules /etc/udev/rules.d/
sudo systemctl daemon-reload
46 changes: 46 additions & 0 deletions rpi/etc/automount/automount.sh
Original file line number Diff line number Diff line change
@@ -0,0 +1,46 @@
#!/bin/bash
# shamelessly copied from https://github.com/k1-debian/

ACTION=$1
DEVBASE=$2
DEVICE="/dev/${DEVBASE}"

# See if this drive is already mounted
MOUNT_POINT=$(/bin/mount | /bin/grep ${DEVICE} | /usr/bin/awk '{ print $3 }')

do_mount() {
if [[ -n ${MOUNT_POINT} ]]; then
# Already mounted, exit
exit 1
fi

MOUNT_POINT="/media/usb"

/bin/mkdir -p ${MOUNT_POINT}

# Global mount options
OPTS="ro,relatime"

# File system type specific mount options
if [[ ${ID_FS_TYPE} == "vfat" ]]; then
OPTS+=",user,uid=1000,gid=1000,umask=000,shortname=mixed,utf8=1,flush"
fi

if ! /bin/mount -o ${OPTS} ${DEVICE} ${MOUNT_POINT}; then
exit 1
fi
}

do_unmount() {
if [[ -n ${MOUNT_POINT} ]]; then
/bin/umount -l ${DEVICE}
fi
}
case "${ACTION}" in
add)
do_mount
;;
remove)
do_unmount
;;
esac
8 changes: 8 additions & 0 deletions rpi/etc/systemd/system/[email protected]
Original file line number Diff line number Diff line change
@@ -0,0 +1,8 @@
[Unit]
Description=Mount USB Drive on %i

[Service]
Type=oneshot
RemainAfterExit=true
ExecStart=/etc/automount/automount.sh add %i
ExecStop=/etc/automount/automount.sh remove %i
2 changes: 2 additions & 0 deletions rpi/etc/udev/rules.d/99-automount.rules
Original file line number Diff line number Diff line change
@@ -0,0 +1,2 @@
KERNEL=="sd*", SUBSYSTEMS=="usb", ACTION=="add", RUN+="/bin/systemctl start usb-mount@%k.service"
KERNEL=="sd*", SUBSYSTEMS=="usb", ACTION=="remove", RUN+="/bin/systemctl stop usb-mount@%k.service"
5 changes: 5 additions & 0 deletions rpi/install-grumpyscreen.sh
Original file line number Diff line number Diff line change
Expand Up @@ -53,6 +53,11 @@ if [ $? -ne 0 ]; then
[ -f $BASEDIR/printer_data/config/grumpyscreen.cfg ] && rm $BASEDIR/printer_data/config/grumpyscreen.cfg
fi

# si that you can print
if [ ! -L $BASEDIR/printer_data/gcodes/usb ]; then
ln -sf /media/usb $BASEDIR/printer_data/gcodes/usb
fi

cp $BASEDIR/pellcorp/rpi/services/cursor.sh $BASEDIR/guppyscreen/
sudo cp $BASEDIR/pellcorp/rpi/services/grumpyscreen.service /etc/systemd/system/ || exit $?
sudo sed -i "s:\$HOME:$BASEDIR:g" /etc/systemd/system/grumpyscreen.service
Expand Down