The officially official Devuan Forum!

You are not logged in.

#1 2017-07-08 22:24:46

greenjeans
Member
Registered: 2017-04-07
Posts: 541  
Website

Nasty local hacks, the definitive and not-official Devuan list

Okay, been thinking about making this thread for a while. Got any local hacks you do post-install? You know, the not-pretty-or-sustainable-but-does-the-trick type of thing, the "oh-no-you-don't-force-me-into-this-crap" kind of thing that isn't solved by the delete-hammer alone?

I'll post one here and more as I think of them.

1. Hate Samba? (and you should). Don't share files with intentionally buggy Windoze machines? Don't want any of that crap on your machine but use GVFS so are stuck with libsmbclient and 20+ mb's of samba-libs and other assorted samba related depends?

gvfs-backends is the only real issue here, mounting/reading samba shares is one of the things gvfs is capable of doing, not something it HAS to do, it's one of the features but somebody decided to make it a dependency during packaging.

Hack it: go to /var/lib/dpkg/status and open that file as root for editing. Find the gvfs-backends entry (search function in text-editor is very helpful here, this is a LARGE file).  In the list of dependencies you will find libsmbclient, delete that entry only and change the "Version=" field of gvfs-backends to a higher number (currently on mine version is listed as 1.22.2-1, I changed only the last number to a 5). Save and close. Open Synaptic and refresh and if nothing else is using the samba libs they will be listed as "autoremoveable" by Synaptic. Now use the uninstall-hammer and enjoy linux without that buggy virus-port-of-entry samba crap.

Last edited by greenjeans (2017-07-10 19:21:58)


https://sourceforge.net/projects/vuu-do/
Vuu-do GNU/Linux, minimal Devuan-based openbox systems to build on, maximal versions if you prefer your linux fully-loaded.

Please donate to support Devuan and init freedom! https://devuan.org/os/donate

Offline

#2 2017-07-09 20:32:23

nixer
Member
From: North Carolina, USA
Registered: 2016-11-30
Posts: 211  

Re: Nasty local hacks, the definitive and not-official Devuan list

I have a couple of "nasty" hacks.  They are done on all my devuan installs.  So, I will share.

Before I start, one thing you may want to know.  I have a home network server operational 24/7.  It is only off during power outages, which is seldom.  The first of my hacks begin with already having successfully configured nfs to be shared on the server, and both hacks depend on the installation of and configuring autofs on the client computers.  Autofs is used on both hacks, to mount nfs network mounts and to mount the local partitions.  With autofs, the fstab file is not altered, but fstab may need to be altered to successfully test and troubleshoot the mount procedure.

Hack #1 - Recycle and Reuse Apt Cache, Use NFS network mount (with autofs)
I use this "nasty hack" to use, share, and recycle my downloaded apt cache across all my devuan installations.  I rename /var/cache/apt/archives to archives.local and then I create a symlink to the network mount location.
- Manually create the folder /mnt/nfs, and then /mnt/nfs/auto-server-data
- Install autofs, as root
   

apt-get install autofs

- Add the below to /etc/auto.master, adjusting for your paths

# nfs shares
/mnt/nfs/auto-server-data  /etc/auto.nfs --timeout=30 --ghost

 
- Create the file /etc/auto.nfs and add to it, adjusting to your needs

data -fstype=nfs,rw  192.168.1.100:/mnt/data

   
As root, enter the command

service autofs restart

These two entries combined will mount the remote location from 192.168.1.100:/mnt/data, and mount it locally at /mnt/nfs/auto-server-data/data.  The mount will timeout after 30 seconds (minutes?) and the "data" folder itself will disappear.  Don't worry, it will be re-created as needed, and upon a re-mount.  After it is successfully mounted, then the symlink to /var/cache/apt/archives can be created with, and adjust for your paths:

#  ln -s /mnt/nfs/auto-server-data/data/devuan/apt/archives /var/cache/apt/archives

   
For any permissions problem on the local system, I adjust the network folder to 0777.  Be sure to set apt to not delete the cache.  I do this from within synaptic.  This hack allows me to save bandwidth on the repository servers as I have several devuan installs in my network.

Hack #2 - Partition mounts, avoiding libsystemd0
I first used this to avoid the installation of libsystemd0, and I think it was wanting to be installed with gvfs, as this was used in the mounting of partitions within Thunar, if I recall correctly.  This hack helped me to avoid installing libsystemd0.  This is a nasty hack but is very simple and has never failed to work.
First configure autofs to mount local partitions. 
- Create mount point for partitions under /mnt (I use /mnt/sda, /mnt/sdb, etc.)
- Create the file /etc/auto.local.  Adjust to your needs for any and all partitions that you may wish to mount.  Each partition will mount under this folder name within /mnt/sda.  Add this to /etc/auto.local, and adjust for your local partitions

sda1 -fstype=ext4  :/dev/sda1
sda5 -fstype=ext4  :/dev/sda5
sda6 -fstype=ext4  :/dev/sda6
sda7 -fstype=ext4  :/dev/sda7
sda8 -fstype=ext4  :/dev/sda8
# current root partition in use
#sda9 -fstype=ext4  :/dev/sda9 
sda10 -fstype=ext4  :/dev/sda10

# not in use, nothing installed
#sda11 -fstype=ext4  :/dev/sda11
#sda12 -fstype=ext4  :/dev/sda12

NOTE:  The above looks "nasty" but really, I have this entry for all my installs and I simply comment out the partitions that are in use (and already mounted), or that I do not wish to access.  So for the entry above, I am currently booted into sda9, and do not wish to access sda11 and sda12 as there is nothing installed there.

- Add to /etc/auto.master this line

# local drives
/mnt/sda	/etc/auto.local --timeout=10 --ghost

Restart autofs, and this is it, finished.  However, I find it much simpler to create symlinks under the user directory for easy shortcut access.  For example, I access each partition within the ~/Partitions folder with a symlink to each partition on the drive.  Use the example command below to create a symlink and adjust for your partitions.  You can assign a descriptive name for the symlink to help you know which partition is which.

#  ln -s /mnt/sda/sda1 /home/USER/Partitions/sda1_Devuan
#  ln -s /mnt/sda/sda2 /home/USER/Partitions/sda2_Refracta

etc.

This will not mount partitions within the file manager like you would normally think it would.  The partitions will mount by clicking on the mount points under /mnt/sda or within the symlinks created just above in ~/Partitions.

Nasty?, a little but, but libsystemd0 is not installed and I can access my other partitions with a simple click.

These are my two "nasty hacks".  There are probably other ways of doing each, but this is what I came up with to help me accomplish what I wanted.

Edit: Eliminated some wordiness

Last edited by nixer (2017-07-09 20:36:14)

Offline

#3 2017-07-10 15:23:17

GNUser
Member
Registered: 2017-03-16
Posts: 570  

Re: Nasty local hacks, the definitive and not-official Devuan list

My "nasty hack" contribution: A startup script that runs your custom shutdown/reboot jobs (yes, you read that correctly smile).

#!/bin/bash

payload()
{
    command_or_script1
    command_or_script2
    command_or_scriptN
}
trap payload TERM

kill -SIGSTOP $$

To use it, just add this script to your startup applications and replace the placeholders with the commands or scripts you want to run at shutdown/reboot.

How it works: When executed, the script immediately stops itself. It stays in stopped state while system is running (or suspended). When you shutdown or reboot your system, every process (including stopped ones) is sent the TERM signal. In the case of this script, when it receives the TERM signal it runs the payload function containing your shutdown/reboot jobs.

What inspired this hack is the fact that it always seems easier to setup startup jobs than shutdown/reboot jobs.

Last edited by GNUser (2017-07-10 22:40:24)

Offline

#4 2017-07-13 14:27:01

catprints
Member
Registered: 2016-11-30
Posts: 145  

Re: Nasty local hacks, the definitive and not-official Devuan list

Thought it would be good to keep a list of packages I usually have to install (and forget the names of) after a fresh installation of an os. Then I figured why not a script to install instead?
My pkginstall.sh

#!/bin/bash
#
#Install most likely desired packages.
#Run as root in terminal.
apt-get update && apt-get install firejail gtkorphan gdebi guvcview claws-mail-fancy-plugin dconf-editor pastebinit hexchat 
exit 0

Of course all my pkg choices can change as I (or anyone) chooses. This is pretty basic but someone might find it handy.

*Though most of these posts are way over my head I really like this thread and enjoy the info.TY

Last edited by catprints (2017-07-13 14:37:13)


"The obstacle is the path."

Offline

#5 2017-07-14 07:01:54

linijkarz
Member
Registered: 2017-06-04
Posts: 12  

Re: Nasty local hacks, the definitive and not-official Devuan list

nixer wrote:

Hack #2 - Partition mounts, avoiding libsystemd0

Definitely going to save this one for later when I'm ready to part with gvfs and the convenience of mounting smb/nfs shares on a whim.

Here goes nothing. Not exactly "dirty hacks" but you got to understand where I'm coming from. I work with limited resources and me switching to GNU/Linux few years ago was a choice dictated primarily because my hardware isn't getting newer. Some useful (not crucial) software really takes a lot more resources than it should've and It irks me a lot

shoddy solution #1: replacement for pasystray and alternatives
I liked the functionality of pasystray, the fact that I could mute/unmute with a press of a button and the fact that It would tell me outright, what I didn't like was the mindboggling ~60M of memory it took for such a simple functionality. Unfortunately alternatives like volumeicon don't play right with pulseaudio.

#/bin/sh

getsinkname() {
    pacmd stat | awk -F": " '/^Default sink name: /{print $2}'
}

getsinkvolume() {
    pacmd list-sinks |
        awk '/^\s+name: /{indefault = $2 == "<'"$(getsinkname)"'>"}
            /^\s+volume: / && indefault {print $5; exit}'
}

getsinkstatus() {
    pacmd list sinks |
        awk '/^\s+name: /{indefault = $2 == "<'"$(getsinkname)"'>"}
            /^\s+muted: / && indefault {print $2; exit}'
}

mutesymbol() {
    if [ "$(getsinkstatus)" = "yes" ]
    then
        printf "<U+1F507>"
    elif [ "$(getsinkstatus)" = "no" ]
    then
        printf "<U+1F50A>"
fi
}

if [ "$1" = "up" ]
then
    pactl set-sink-volume 0 -- +5%
elif [ "$1" = "down" ]
then
    pactl set-sink-volume 0 -- -5%
elif [ "$1" = "mute" ] && [ "$(getsinkstatus)" = "no" ]
then
    pactl set-sink-mute 0 1
elif [ "$1" = "mute" ] && [ "$(getsinkstatus)" = "yes" ]
then
         pactl set-sink-mute 0 0
fi

#notification

id="2083402"
summary="volume: $(mutesymbol)"
body="$(getsinkvolume)"
actions="[]"
hints="{}"
timeout="1"

exec gdbus call --session   \
   --dest org.freedesktop.Notifications \
   --object-path /org/freedesktop/Notifications \
   --method org.freedesktop.Notifications.Notify \
   "${app_name}" "${id}" "${icon}" "${summary}" "${body}" \
   "${actions}" "${hints}" "${timeout}"

Should be pretty self-explanatory. It's just an "extension" so I could get a visual feedback from pressing built-in XF86 keys on my keyboard. It produces a notification telling me the status (mute/unmute) and the volume of the currently used pulseaudio sink. The gdbus fuckery is included so it's only one notification that gets updated instead of spamming the whole screen with rectangular windows.

shoddy solution #2: replacement for redshift daemon
Redshift and redshift-gtk for controlling it takes absolutely horrendous amount of resources. There's this tiny bit of C code that provides the functionality of redshift software suite (or f.lux if you're on Windows).
http://www.tedunangst.com/flak/post/sct … emperature

It obviously slacks the most crucial feature - handling transitions between night and day automatically. So I crudely reimplemented it using tools I already run on my machine, notably cron and a scriptable shell. Entire thing is composed of three scripts, one for smooth transition at dusk, one for smooth transition at dawn and a 3rd, more "general purpose" one that handles enabling/disabling the functionality as well as runs Xorg startup in case I login in the middle of the night and don't want to get blinded.
I am however totally inexperienced when it comes to shell scripting so If you know a way to make it more efficient (case statements are really fucking long) I would gladly appreciate help.

sct-dusk-transition.sh

#!/bin/sh

getminute="$(/bin/date +%M)"

case $getminute in
        "00") sct 6400;;
        "02") sct 6300;;
        "04") sct 6200;;
        "06") sct 6100;;
        "08") sct 6000;;
        "10") sct 5900;;
        "12") sct 5800;;
        "14") sct 5700;;
        "16") sct 5600;;
        "18") sct 5500;;
        "20") sct 5400;;
        "22") sct 5300;;
        "24") sct 5200;;
        "26") sct 5100;;
        "28") sct 5000;;
        "30") sct 4900;;
        "32") sct 4800;;
        "34") sct 4700;;
        "36") sct 4600;;
        "38") sct 4500;;
        "40") sct 4400;;
        "42") sct 4300;;
        "44") sct 4200;;
        "46") sct 4100;;
        "48") sct 4000;;
        "50") sct 3900;;
        "51") sct 3800;;
        "52") sct 3700;;
        "53") sct 3600;;
        "54") sct 3500;;
        "55") sct 3400;;
        "56") sct 3300;;
        "57") sct 3200;;
        "58") sct 3100;;
        "59") sct 3000;;
esac

sct-dawn-transition.sh

#!/bin/sh

getminute="$(/bin/date +%M)"

case $getminute in
        "00") sct 3100 ;;
        "02") sct 3200 ;;
        "04") sct 3300 ;;
        "06") sct 3400 ;;
        "08") sct 3500 ;;
        "10") sct 3600 ;;
        "12") sct 3700 ;;
        "14") sct 3800 ;;
        "16") sct 3900 ;;
        "18") sct 4000 ;;
        "20") sct 4100 ;;
        "22") sct 4200 ;;
        "24") sct 4300 ;;
        "26") sct 4400 ;;
        "28") sct 4500 ;;
        "30") sct 4600 ;;
        "32") sct 4700 ;;
        "34") sct 4800 ;;
        "36") sct 4900 ;;
        "38") sct 5000 ;;
        "40") sct 5100 ;;
        "42") sct 5200 ;;
        "44") sct 5300 ;;
        "46") sct 5400 ;;
        "48") sct 5500 ;;
        "50") sct 5600 ;;
        "51") sct 5700 ;;
        "52") sct 5800 ;;
        "53") sct 5900 ;;
        "54") sct 6000 ;;
        "55") sct 6100 ;;
        "56") sct 6200 ;;
        "57") sct 6300 ;;
        "58") sct 6400 ;;
        "59") sct ;;
esac

And finally
sct-switcher.sh

#!/bin/sh

switch_tmp() {
        if [ ! -f /tmp/sct-switch ]
        then
                touch /tmp/sct-switch
        else
                rm /tmp/sct-switch
        fi
}

get_hour() {
        date +%H
}

set_temp() {
        case "$(get_hour)" in
                (21) sct-dusk-transition.sh ;;
                ([2][2-3]) sct 3000 ;;
                ([0][0-3]) sct 3000 ;;
                (04) sct-dawn-transition.sh ;;
                ([0][5-9]) sct ;;
                ([1][0-9]) sct ;;
                (20) sct ;;
        esac
}
if [ "$1" = "switch" ]
then
        switch_tmp
fi

if [ -f /tmp/sct-switch ]
then
        sct
else
        set_temp
fi

And the crontab entries look like this

* 21 * * * [ ! -f /tmp/sct-switch ] && export DISPLAY=:0 && sct-dusk-transition.sh
* 04 * * * [ ! -f /tmp/sct-switch ] && export DISPLAY=:0 && sct-dawn-transition.sh

So far it's been working great. The transition is not as smooth as on redshift/f.lux but it's entirely tolerable.

Last edited by linijkarz (2017-07-15 13:09:23)

Offline

Board footer