<?xml version="1.0" encoding="utf-8"?>
<feed xmlns="http://www.w3.org/2005/Atom">
	<title type="html"><![CDATA[HyperForum — Hyperbola setup and user programs]]></title>
	<link rel="self" href="https://forums.hyperbola.info/extern.php?action=feed&amp;tid=1066&amp;type=atom" />
	<updated>2024-06-10T13:26:30Z</updated>
	<generator>PunBB</generator>
	<id>https://forums.hyperbola.info/viewtopic.php?id=1066</id>
		<entry>
			<title type="html"><![CDATA[Re: Hyperbola setup and user programs]]></title>
			<link rel="alternate" href="https://forums.hyperbola.info/viewtopic.php?pid=8106#p8106" />
			<content type="html"><![CDATA[<p>Thanks for adding. <img src="https://forums.hyperbola.info/img/smilies/smile.png" width="15" height="15" alt="smile" /><br />But also note: Luke Smith is not getting any &quot;welcome&quot; here. So please do not add further sources from him or based on him. Thanks!</p><p>We do not support <a href="https://web.archive.org/web/20240401015546/https://www.theguardian.com/world/2021/mar/12/far-right-open-source-technology-censorship">people oriented on far-right political ideologies</a> (with pointing on our <a href="https://wiki.hyperbola.info/doku.php?id=en:project:social_contract">social contract</a>).</p>]]></content>
			<author>
				<name><![CDATA[throgh]]></name>
				<uri>https://forums.hyperbola.info/profile.php?id=347</uri>
			</author>
			<updated>2024-06-10T13:26:30Z</updated>
			<id>https://forums.hyperbola.info/viewtopic.php?pid=8106#p8106</id>
		</entry>
		<entry>
			<title type="html"><![CDATA[Re: Hyperbola setup and user programs]]></title>
			<link rel="alternate" href="https://forums.hyperbola.info/viewtopic.php?pid=8104#p8104" />
			<content type="html"><![CDATA[<p>Okay, I indicated the author of this script, here is the source (GPL-3.0 license )</p>]]></content>
			<author>
				<name><![CDATA[jim]]></name>
			</author>
			<updated>2024-06-10T09:28:20Z</updated>
			<id>https://forums.hyperbola.info/viewtopic.php?pid=8104#p8104</id>
		</entry>
		<entry>
			<title type="html"><![CDATA[Re: Hyperbola setup and user programs]]></title>
			<link rel="alternate" href="https://forums.hyperbola.info/viewtopic.php?pid=8099#p8099" />
			<content type="html"><![CDATA[<p>Please always name the source where those scripts are coming from, so it is possible to check the license for other interested. If you are the creator(s), please add a corresponding free, permissive license for others to check out.</p>]]></content>
			<author>
				<name><![CDATA[throgh]]></name>
				<uri>https://forums.hyperbola.info/profile.php?id=347</uri>
			</author>
			<updated>2024-06-09T01:18:21Z</updated>
			<id>https://forums.hyperbola.info/viewtopic.php?pid=8099#p8099</id>
		</entry>
		<entry>
			<title type="html"><![CDATA[Re: Hyperbola setup and user programs]]></title>
			<link rel="alternate" href="https://forums.hyperbola.info/viewtopic.php?pid=8098#p8098" />
			<content type="html"><![CDATA[<p>Thank you for your answer. I meant this script, this is Luke Smith</p><div class="codebox"><pre><code>#!/bin/bash

# Mounts Android Phones and USB drives (encrypted or not). This script will
# replace the older `dmenumount` which had extra steps and couldn&#039;t handle
# encrypted drives.
# TODO: Try decrypt for drives in crtypttab
# TODO: Add some support for connecting iPhones (although they are annoying).

IFS=&#039;
&#039;
# Function for escaping cell-phone names.
escape(){ echo &quot;$@&quot; | iconv -cf UTF-8 -t ASCII//TRANSLIT | tr -d &#039;[:punct:]&#039; | tr &#039;[:upper:]&#039; &#039;[:lower:]&#039; | tr &#039; &#039; &#039;-&#039; | sed &quot;s/-\+/-/g;s/\(^-\|-\$\)//g&quot; ;}

# Check for phones.
phones=&quot;$(simple-mtpfs -l 2&gt;/dev/null | sed &quot;s/^/📱/&quot;)&quot;
mountedphones=&quot;$(grep &quot;simple-mtpfs&quot; /etc/mtab)&quot;
# If there are already mounted phones, remove them from the list of mountables.
[ -n &quot;$mountedphones&quot; ] &amp;&amp; phones=&quot;$(for phone in $phones; do
    for mounted in $mountedphones; do
        escphone=&quot;$(escape &quot;$phone&quot;)&quot;
        [[ &quot;$mounted&quot; =~ &quot;$escphone&quot; ]] &amp;&amp; break 1
    done &amp;&amp; continue 1
    echo &quot;$phone&quot;
done)&quot;

# Check for drives.
lsblkoutput=&quot;$(lsblk -rpo &quot;uuid,name,type,size,label,mountpoint,fstype&quot;)&quot;
# Get all LUKS drives
allluks=&quot;$(echo &quot;$lsblkoutput&quot; | grep crypto_LUKS)&quot;
# Get a list of the LUKS drive UUIDs already decrypted.
decrypted=&quot;$(find /dev/disk/by-id/dm-uuid-CRYPT-LUKS2-* | sed &quot;s|.*LUKS2-||;s|-.*||&quot;)&quot;
# Functioning for formatting drives correctly for dmenu:
filter() { sed &quot;s/ /:/g&quot; | awk -F&#039;:&#039; &#039;$7==&quot;&quot;{printf &quot;%s%s (%s) %s\n&quot;,$1,$3,$5,$6}&#039; ; }

# Get only LUKS drives that are not decrypted.
unopenedluks=&quot;$(for drive in $allluks; do
    uuid=&quot;${drive%% *}&quot;
    uuid=&quot;${uuid//-}&quot;    # This is a bashism.
    [ -n &quot;$decrypted&quot; ] &amp;&amp; for open in $decrypted; do
        [ &quot;$uuid&quot; = &quot;$open&quot; ] &amp;&amp; break 1
    done &amp;&amp; continue 1
    echo &quot;🔒 $drive&quot;
done | filter)&quot;

# Get all normal, non-encrypted or decrypted partitions that are not mounted.
normalparts=&quot;$(echo &quot;$lsblkoutput&quot;| grep -v crypto_LUKS | grep &#039;part\|rom\|crypt&#039; | sed &quot;s/^/💾 /&quot; | filter )&quot;

# Add all to one variable. If no mountable drives found, exit.
alldrives=&quot;$(echo &quot;$phones
$unopenedluks
$normalparts&quot; | sed &quot;/^$/d;s/ *$//&quot;)&quot;

# Quit the script if a sequential command fails.
set -e

test -n &quot;$alldrives&quot;

# Feed all found drives to dmenu and get user choice.
chosen=&quot;$(echo &quot;$alldrives&quot; | dmenu -p &quot;Mount which drive?&quot; -i)&quot;

# Function for prompting user for a mountpoint.
getmount(){
    mp=&quot;$(find /mnt /media /mount /home -maxdepth 1 -type d 2&gt;/dev/null | dmenu -i -p &quot;Mount this drive where?&quot;)&quot;
    test -n &quot;$mp&quot;
    if [ ! -d &quot;$mp&quot; ]; then
        mkdiryn=$(printf &quot;No\\nYes&quot; | dmenu -i -p &quot;$mp does not exist. Create it?&quot;)
        [ &quot;$mkdiryn&quot; = &quot;Yes&quot; ] &amp;&amp; (mkdir -p &quot;$mp&quot; || sudo -A mkdir -p &quot;$mp&quot;)
    fi
}

attemptmount(){
        # Attempt to mount without a mountpoint, to see if drive is in fstab.
        sudo -A mount &quot;$chosen&quot; || return 1
        notify-send &quot;💾Drive Mounted.&quot; &quot;$chosen mounted.&quot;
        exit
}

case &quot;$chosen&quot; in
    💾*)
        chosen=&quot;${chosen%% *}&quot;
        chosen=&quot;${chosen:1}&quot;    # This is a bashism.
        attemptmount || getmount
        sudo -A mount &quot;$chosen&quot; &quot;$mp&quot; -o uid=&quot;$(id -u)&quot;,gid=&quot;$(id -g)&quot;
        notify-send &quot;💾Drive Mounted.&quot; &quot;$chosen mounted to $mp.&quot;
        ;;

    🔒*)
        chosen=&quot;${chosen%% *}&quot;
        chosen=&quot;${chosen:1}&quot;    # This is a bashism.
        # Number the drive.
        while true; do
            [ -f &quot;/dev/mapper/usb$num&quot; ] || break
            num=&quot;$(printf &quot;%02d&quot; &quot;$((num +1))&quot;)&quot;
        done

        # Decrypt in a terminal window
        ${TERMINAL:-st} -n floatterm -g 60x1 -e sudo cryptsetup open &quot;$chosen&quot; &quot;usb$num&quot;
        # Check if now decrypted.
        test -b &quot;/dev/mapper/usb$num&quot;

        attemptmount || getmount
        sudo -A mount &quot;/dev/mapper/usb$num&quot; &quot;$mp&quot; -o uid=&quot;$(id -u)&quot;,gid=&quot;$(id -g)&quot;
        notify-send &quot;🔓Decrypted drive Mounted.&quot; &quot;$chosen decrypted and mounted to $mp.&quot;
        ;;

    📱*)
        notify-send &quot;❗Note&quot; &quot;Remember to allow file access on your phone now.&quot;
        getmount
        number=&quot;${chosen%%:*}&quot;
        number=&quot;${chosen:1}&quot;    # This is a bashism.
        sudo -A simple-mtpfs -o allow_other -o fsname=&quot;simple-mtpfs-$(escape &quot;$chosen&quot;)&quot; --device &quot;$number&quot; &quot;$mp&quot;
        notify-send &quot;🤖 Android Mounted.&quot; &quot;Android device mounted to $mp.&quot;
        ;;
esac</code></pre></div>]]></content>
			<author>
				<name><![CDATA[jim]]></name>
			</author>
			<updated>2024-06-08T21:50:20Z</updated>
			<id>https://forums.hyperbola.info/viewtopic.php?pid=8098#p8098</id>
		</entry>
		<entry>
			<title type="html"><![CDATA[Hyperbola setup and user programs]]></title>
			<link rel="alternate" href="https://forums.hyperbola.info/viewtopic.php?pid=8097#p8097" />
			<content type="html"><![CDATA[<p>From<br /> &quot;Bringing my .cwmrc to Hyperbola&quot; thread:<br /></p><div class="quotebox"><cite>jim wrote:</cite><blockquote><p>As I understand it, you also decrypt disks or usb using the <br />terminal. </p><p>What do you think about scripts to automate this process? Can you write <br />complex scripts?</p></blockquote></div><p>I don&#039;t encrypt full disks as I don&#039;t see the usefulness to, putting a <br />password in BIOS is simpler if needed to protect the system itself at <br />boot, but even then you can&#039;t know that the disks haven&#039;t been removed <br />and executables changed unless you sign them or reinstall the whole <br />system. But a line in an init script that would decrypt some file using a password at <br />startup with aescrypt2 for example, and encrypt it at shutdown is a good way of <br />protecting privacy. </p><p>Regarding full usb encryption, use fscrypt: <br /><a href="https://wiki.archlinux.org/title/Fscrypt#ext4.">https://wiki.archlinux.org/title/Fscrypt#ext4.</a> <br />Compile and install fscryptctl: <br /><a href="https://github.com/google/fscryptctl/blob/master/README.md.">https://github.com/google/fscryptctl/bl … README.md.</a> <br />and follow the instructions <br />For auto_mounting, you can add a udev rule, for example (supposing you want to enter the password in dmenu): </p><p>(inspired by <br /><a href="https://stackoverflow.com/questions/45186643/auto-mount-usb-drive-from-udev-rules-and-shell-script">https://stackoverflow.com/questions/451 … ell-script</a>)</p><p>/lib/udev/rules.d/10-usb-decryption-automount.rules<br /></p><div class="codebox"><pre><code>// SPDX-License-Identifier: BSD-3-Clause
ACTION==&quot;add&quot;, KERNEL==&quot;sdb[0-9]&quot;, SUBSYSTEM==&quot;block&quot;, RUN+=&quot;auto-mount&quot;
ACTION==&quot;remove&quot;, KERNEL==&quot;sdb[0-9]&quot;, SUBSYSTEM==&quot;block&quot;, RUN+=&quot;auto-mount&quot;</code></pre></div><p>/usr/bin/auto-mount <br /></p><div class="codebox"><pre><code>// SPDX-License-Identifier: BSD-3-Clause
#!/bin/sh

Name=$(basename $0)
Logger=&quot;/usr/bin/logger -p local3.info -t $Name &quot;
Message=&quot;$* $DEVNAME $ACTION $ID_FS_LABEL&quot;
$Logger &lt;&lt;&lt; $Message

usb_add ()
{ Message=&quot;automounting  $DEVNAME $ID_FS_LABEL&quot;
  $Logger &lt;&lt;&lt; $Message
  /sbin/mount $DEVNAME /mnt &amp;&amp; $Logger &lt;&lt;&lt; &quot;mounted&quot; ||
 $Logger &lt;&lt;&lt; &quot;failed&quot;
  dmenu &lt; /dev/null | fscryptctl add_key /mnt
}

pico_remove ()
{ Message=&quot;umounting  $DEVNAME $ID_FS_LABEL&quot;
  $Logger &lt;&lt;&lt; $Message
  /sbin/umount -f /mnt &amp;&amp; $Logger &lt;&lt;&lt; &quot;umounted&quot; || $LOGGER &quot;failed&quot;
}

usb_$ACTION</code></pre></div><p>then: udevadm control --reload-rules &amp;&amp; udevadm trigger</p>]]></content>
			<author>
				<name><![CDATA[benyouyou]]></name>
				<uri>https://forums.hyperbola.info/profile.php?id=694</uri>
			</author>
			<updated>2024-06-07T15:33:06Z</updated>
			<id>https://forums.hyperbola.info/viewtopic.php?pid=8097#p8097</id>
		</entry>
</feed>
