The officially official Devuan Forum!

You are not logged in.

#476 Re: Installation » lost basic user account i think anyway » 2020-12-30 07:45:17

have you tried the root password in the user account?

@ Dustch_Master, Im not real clued up on login managers but does say LXDM need the user to be in the video group?

#477 Re: Off-topic » dd command inside script. » 2020-12-29 11:56:01

Thanks head on a stick, i forgot to do that. This has been a good learning experience and its good to make mistakes and learn from them. I will definitely be looking into more posix orientated scripts in the future. Updated the script as per shellcheck.

#478 Off-topic » cryptsetup encrypted container script » 2020-12-29 08:27:23

dice
Replies: 0

continued on from here: http://dev1galaxy.org/viewtopic.php?id=4018

Thought i should create a new thread on the nearly complete script ive been working on. Hopefully ive done the right setup for this?

Few more things i need figuring out, how to make the script so that any user is accepted, kind of like maybe a first run config file that just enters the user name into the correct variable in the script. Fixed by adding $SUDO_USER to the variable. No logname is better i read.Not sure about those who use root account directly that being [su -]?

Possibly some sort of verbosity with the dd and cryptsetup commands. Possibly allow for different file systems to be used like btrfs, xfs, ntfs etc.

I have created a help section inside the script now so it explains in some detail what im trying to accomplish.

Ive named it cryptc

#!/bin/sh

###############################################################
# © 2020 WTFPL – Do What the Fuck You Want to Public License. #
#							      #
#		http://www.wtfpl.net/about/                   #
###############################################################

u=$(logname)

crypt_dir () {
	dir="$2"
	mkdir -p /home/"${u}"/"${dir}"
}

crypt_img () {
	outfile="$2"
	blocksize="$3"
	dd if=/dev/urandom of="${outfile}" bs="${blocksize}" count=1 iflag=fullblock
}

crypt_create () {
	img="$2"
	name="$3"
        losetup -f > /tmp/nextloop
        LOOPDEV=$(cat /tmp/nextloop)
        losetup "${LOOPDEV}" "${img}"
        cryptsetup luksFormat "${img}"
        cryptsetup open "${img}" "${name}"
        mkfs.ext4 /dev/mapper/"${name}"
}

crypt_open () {
	img="$2"
	name="$3"
	cryptsetup open "${img}" "${name}"
}

crypt_mount () {
	name="$2"
	dir="$3"
	mount -t ext4 /dev/mapper/"${name}" /home/"${u}"/"${dir}"
}

crypt_umount () {
	name="$2"
	dir="$3"
	umount /home/"${u}"/"${dir}"
	cryptsetup close "${name}"
	losetup -d /dev/loop0
}

usage () {
    cat <<EOM

Usage:

This is just a simple script to create an encrypted container using dd + cryptsetup + luks and mount it on the user home directory.
All commands are to be run as sudo if not then root user (su) will need to be used. 
This script could be used to keep personal info safe inside an encrypted raw disk image container.
Depends: dd, cryptsetup, e2fsprogs

[-d] make the directory for the container first
sudo cryptc -d <name of directory>
example "sudo cryptc -d my-directory"

[-i] sudo cryptc -i <your.img> <size>
example: "sudo crypt-c -i your.img 100M"

[-C] sudo cryptc -C <your.img> <dev-mapper-name>
example: "sudo cryptc -C your.img dev-mapper-name"

[-m] mount to the directory you created for the container from step 1.
sudo cryptc -m <dev-mapper-name> <name-of-directory>
example: "sudo cryptc -m dev-mapper-name my-directory"

[-u] sudo cryptc -u <name>
example: "sudo cryptc -u dev-mapper-name"

[-o] to open the container again
sudo cryptc -o <your.img> <dev-mapper-name>
example: "sudo cryptc -o your.img dev-mapper-name"

EOM
    exit 0
}

while getopts ":diComuh" opt; do
  case ${opt} in
    d ) crypt_dir "$@"
      ;;
    i ) crypt_img "$@"
      ;;
    C ) crypt_create "$@"
      ;;
    o ) crypt_open "$@"
      ;;
    m ) crypt_mount "$@"
      ;;
    u ) crypt_umount "$@"
      ;;
    h ) usage
      ;;
    \? ) echo "Usage: cmd [-d --create-crypt-directory] [-i --create-img] [-C --create-container] [-o --open-image-container] [-m --mount-container] [-u --unmount-container] [-h --help]"
      ;;
  esac
done

Edited. Ran script through shell check as per head on a stick recommendation and updated.

edit 30/12/2020 - can now be installed/uninstalled using make, also included man page.
more details here: https://notabug.org/dice_1/cryptc

#479 Re: Off-topic » dd command inside script. » 2020-12-29 01:03:15

fsmithred wrote:

It looks like it worked. The previous error is gone. Maybe loop1 is left from before? I think you can just delete it manually.

that seems to be the case. Thanks again.

#480 Re: Off-topic » dd command inside script. » 2020-12-28 15:20:51

still showing two loop devices, thanks for your help though.

 ~ $ > sudo ./ccreate.sh -c test.img
+ img=test.img
+ getopts :c opt
+ case "${opt}" in
+ crypt_create test.img
+ losetup -f
++ cat /tmp/nextloop
+ LOOPDEV=/dev/loop0
+ losetup /dev/loop0 test.img
+ cryptsetup luksFormat test.img

WARNING!
========
This will overwrite data on test.img irrevocably.

Are you sure? (Type 'yes' in capital letters): YES
Enter passphrase for test.img:
Verify passphrase:
+ cryptsetup open test.img cryptfs
Enter passphrase for test.img:
+ mkfs.ext4 /dev/mapper/cryptfs
mke2fs 1.45.6 (20-Mar-2020)
Creating filesystem with 4096 1k blocks and 1024 inodes

Allocating group tables: done
Writing inode tables: done
Creating journal (1024 blocks): done
Writing superblocks and filesystem accounting information: done

+ getopts :c opt
 ~ $ > lsblk
NAME           MAJ:MIN RM   SIZE RO TYPE  MOUNTPOINT
loop0            7:0    0    20M  0 loop
loop1            7:1    0    20M  0 loop
└─cryptfs      254:1    0     4M  0 crypt
#!/bin/bash
set -x
img="$2"

crypt_create () {
        losetup -f > /tmp/nextloop
        LOOPDEV=$(cat /tmp/nextloop)
        losetup ${LOOPDEV} $img
        cryptsetup luksFormat $img
        cryptsetup open $img cryptfs
        mkfs.ext4 /dev/mapper/cryptfs
}

while getopts ":c" opt; do
    case "${opt}" in
        c ) crypt_create $2
        ;;
       \? ) echo "Usage: cmd [c]"
        ;;
    esac
done

#481 Re: Off-topic » dd command inside script. » 2020-12-28 13:24:03

Head_on_a_Stick wrote:
dice wrote:
    i ) crypt_img $2 $3

I think that should be

    i) crypt_img "$@"

Otherwise $2 & $3 will be interpreted as the third and forth arguments applied to the script.

Not sure about the encryption stuff though, I don't use that.

Yes that seems to work as well. Im having a hard time wrapping my head around this stuff, thanks.

#482 Re: Off-topic » dd command inside script. » 2020-12-28 13:19:24

fsmithred wrote:

If you somehow end up with more than one loop device, you might use something like this:

losetup -f > /tmp/nextloop
LOOPDEV=$(cat /tmp/nextloop)

losetup ${LOOPDEV} ${LOOP_FILENAME}

That's taken from refracta2usb which can make an encrypted loopback filesystem for live-usb persistence.

Hi fsmithred, if you see this would you say this is the right way to implement loopdev?

here is just the code to the cryptsetup commands, im yet to figure out how to use that in the main script.

#!/bin/bash
set -x
LOOPDEV=$(cat /tmp/nextloop)
img="$2"

crypt_create () {
        losetup -f > /tmp/nextloop
        losetup ${LOOPDEV} $img
        cryptsetup luksFormat $img
        cryptsetup open $img cryptfs
        mkfs.ext4 /dev/mapper/cryptfs
}

while getopts ":c" opt; do
    case "${opt}" in
        c ) crypt_create $2
        ;;
       \? ) echo "Usage: cmd [c]"
        ;;
    esac
done

seems to work although set -x throws some errors?

sudo ./ccreate.sh -c test.img

++ cat /tmp/nextloop
cat: /tmp/nextloop: No such file or directory
+ LOOPDEV=
+ img=test.img
+ getopts :c opt
+ case "${opt}" in
+ crypt_create test.img
+ crypt_create test.img
+ losetup -f
+ losetup test.img
losetup: test.img: failed to use device: No such device
+ cryptsetup luksFormat test.img

WARNING!
========
This will overwrite data on test.img irrevocably.

Are you sure? (Type 'yes' in capital letters): YES
Enter passphrase for test.img:
Verify passphrase:
+ cryptsetup open test.img cryptfs
Enter passphrase for test.img:
+ mkfs.ext4 /dev/mapper/cryptfs
mke2fs 1.45.6 (20-Mar-2020)
Creating filesystem with 4096 1k blocks and 1024 inodes

Allocating group tables: done
Writing inode tables: done
Creating journal (1024 blocks): done
Writing superblocks and filesystem accounting information: done

+ getopts :c opt

#483 Re: Off-topic » dd command inside script. » 2020-12-28 09:59:47

Managed to cobble this together, not in anyway portable but ill keep trying.
something interesting i found out, luks header keys takes up 16 mb of space so you cant have have a small img like 10mb.

NAME           MAJ:MIN RM   SIZE RO TYPE  MOUNTPOINT
loop0            7:0    0    20M  0 loop
└─cryptfs      254:1    0     4M  0 crypt /home/$u/crypt

Need to look into better command structure using more positional parameters, especially with the use of the crypt.img?
Find out how to use getopts usage better.

#!/bin/bash
set -x
u="<username>"
outfile="$2"
blocksize="$3"

crypt_img () {
	dd if=/dev/urandom of=$outfile bs=$blocksize count=1 iflag=fullblock
}

crypt_create () {
	losetup --find
	losetup /dev/loop0 crypt.img
	cryptsetup luksFormat crypt.img
	cryptsetup open crypt.img cryptfs
	mkfs.ext4 /dev/mapper/cryptfs
}

crypt_open () {
	cryptsetup open crypt.img cryptfs
}

crypt_mount () {
	mount -t ext4 /dev/mapper/cryptfs /home/$u/crypt
}

crypt_umount () {
	umount /home/$u/crypt
	cryptsetup close cryptfs
	losetup -d /dev/loop0
}

while getopts ":iComu" opt; do
  case ${opt} in
    i ) crypt_img $2 $3
      ;;
    C ) crypt_create
      ;;
    o ) crypt_open
      ;;
    m ) crypt_mount
      ;;
    u ) crypt_umount
      ;;
    \? ) echo "Usage: cmd [-i] [-C] [-o] [-m] [-u]"
      ;;
  esac
done

#484 Re: Off-topic » dd command inside script. » 2020-12-28 03:03:21

thanks chris, set -x is quite helpful.

thanks fsmithred, that is exactly where i am stuck right now having two loop devices.

This not anything serious btw, just trying to learn. Think i would rather use tomb to be quite honest wink

#485 Re: Off-topic » dd command inside script. » 2020-12-27 15:04:08

this is the script im working on, im stuck on the dd command as its giving me  dd: invalid number: ‘test.img’  when i run
sudo ./script.sh -C test.img 10 1
This has to be run via root or sudo, could be an issue there.

Im hoping to turn those crypt_open and crypt_close functions for the .img into positional parameters somehow.

EDIT: oops i need to also figure out cryptsetup creation. Ignore this post, keep it here for learning purposes.

cryptsetup options luksFormat device.img
cryptsetup open device.img name
mkfs.fstype /dev/mapper/name
cryptsetup open device.img name

#!/bin/bash

outfile="$2"
blocksize="$3"

create () {
        dd if=/dev/urandom of=$outfile bs=$blocksize count=1 iflag=fullblock
}

crypt_open () {
        losetup /dev/loop0 /home/$USER/ecrypt.img
        cryptsetup open /dev/loop0 ecryptfs
        mount -t ext4 /dev/mapper/ecryptfs /home/$USER/crypt/

}

crypt_close () {
        umount /home/$USER/crypt
        cryptsetup close ecryptfs
        losetup -d /dev/loop0

}

while getopts ":ocC" opt; do
  case ${opt} in
    o ) crypt_open
      ;;
    c ) crypt_close
      ;;
    C ) create $2 $3
      ;;
    \? ) echo "Usage: cmd [-o] [-c] [-C]"
      ;;
  esac
done

EDIT2; fixed dd function for getopts

#486 Re: Off-topic » dd command inside script. » 2020-12-27 12:59:56

Thanks both, positional parameters is what i need to learn. fsmithred, that looks like the way to go.

#487 Off-topic » dd command inside script. » 2020-12-27 12:25:57

dice
Replies: 20

hi, ive got a brain freeze on this and cant firgure it out, ive done something similar awhile ago.

what i want to do is fill in the values after the command as i want to put this in a script somehow.

dd if=/dev/urandom of=$1 bs=$2 count=$3 iflag=fullblock

so $1 will be say value.img and $2 will be 100M or whatever size the img should be and lastly $3 counts $2 incrementally.

??

so on the command line it would look similar to this before its run.

dd if=/dev/urandom of=$1 bs=$2 count=$3 iflag=fullblock value.img 100M 1

#488 Re: Other Issues » Etertics radio distro NO SOUND... help! » 2020-12-25 14:26:41

Lets see what your audio device is. let us know the output of below command from a terminal.

lspci -knn | grep "Audio"

also try contacting etertics.

https://gnuetertics.org/contacto.php

#489 Re: Documentation » dwm statusbar bash script » 2020-12-25 10:21:38

Head_on_a_Stick wrote:
dice wrote:

ip l shows ifaces even if they are down whereas ifconfig and netstat does not. So this would make the script only output multiple if ip was used.

Ah yes, of course. But ifconfig shows all interfaces that are up, which includes interfaces which are not connected.

How about this:

ip r | awk '/^default/{print $5}'

^ That shows the name of the interface currently connected.

I suppose the default gateway is the way to go, so if wlan0 is connected first and then usb0, the default is always going to be wlan0 and vice versa, would that be true?. I wonder how conky does the gw_iface object though.

In regards to ifconfig, atleast in my case on devuan beowulf, if wlan0 is not connected it wont show up in ifconfig, only lo. where ip l all interfaces are shown regardless if they are up or down.

#490 Re: Documentation » dwm statusbar bash script » 2020-12-25 01:36:54

head on a stick, I could use ip but have to tack on sort like so.

ip route | grep -ow 'wlan0\|usb0' | sort -u
usb0
wlan0

otherwise without sort

ip route | grep -ow 'wlan0\|usb0'
wlan0
wlan0
usb0

#491 Re: Documentation » dwm statusbar bash script » 2020-12-25 01:00:12

Head_on_a_Stick wrote:
dice wrote:

If it is old and deprecated why is it still in the kernel?

It's not in the kernel, ifconfig is a(n obsolete) userspace utility.

And anyway what's wrong with

a=$(ip l | grep -ow "wlan0\|usb0")

Off topic for this thread but you should check out slstatus — pure C ftw!

In regards to why is it in the kernel, i should have referenced the answer i got from stackoverflow. I know it is part of the net-tools package so i was confused about this quote:

That said, ifconfig shouldn't be used at all on Linux either; it hasn't been maintained by the upstream kernel team for well over a decade now

In regards to ip, i have some issues with ip l , the difference being that ip l shows ifaces even if they are down whereas ifconfig and netstat does not. So this would make the script only output multiple if ip was used.

Here is ip l on my machine with usb0 and wlan0, with only wlan0 up.

ifconfig
lo: flags=73<UP,LOOPBACK,RUNNING>
wlan0: flags=4163<UP,BROADCAST,RUNNING,MULTICAST>
netstat -i
Kernel Interface table
Iface      MTU    RX-OK RX-ERR RX-DRP RX-OVR    TX-OK TX-ERR TX-DRP TX-OVR Flg
lo       65536        0      0      0 0             0      0      0      0 LRU
wlan0     1500      810      0      0 0           724      0      0      0 BMRU
ip l
1: lo: <LOOPBACK,UP,LOWER_UP> mtu 65536 qdisc noqueue state UNKNOWN mode DEFAULT group default qlen 1000
2: eth0: <BROADCAST,MULTICAST> mtu 1500 qdisc noop state DOWN mode DEFAULT group default qlen 1000
3: wlan0: <BROADCAST,MULTICAST,UP,LOWER_UP> mtu 1500 qdisc mq state UP mode DORMANT group default qlen 1000
4: usb0: <BROADCAST,MULTICAST> mtu 1500 qdisc noop state DOWN mode DEFAULT group default qlen 1000

I have used slstatus in the past, i may revert back to it again, although this endeavor was just to see if i could create shell scripts to pipe to dwm statusbar instead, which i have accomplished.

#492 Re: Off-topic » Season's Greetings to all » 2020-12-24 11:41:17

merry xmas and a happy new year to all.

#493 Re: Documentation » dwm statusbar bash script » 2020-12-24 10:27:24

created a network iface script for this statusbar script. This kind of similar to how conky does it with -

gw_iface Displays the default route's interface or "multiple"/"none" accordingly.

I was told over at stackoverflow i shouldnt be using ifconfig for something as simple as this, which i think is ridiculous, if i wanted to do fancy stuff with the networks i would use iproute2 but for this, not needed. If it is old and deprecated why is it still in the kernel?

This will print on my statusbar as follows,

  • If usb net connected = usb0

  • If wlan0 connected = wlan0

  • If both usb and wlan0 connected =multiple

  • If no network = not connected

#!/usr/bin/env bash

a=$(ifconfig | grep -ow "wlan0\|usb0")
b=$'wlan0\nusb0'
c="%printf '$b'"

if      [[ "$a" = "wlan0" ]] ; then
        printf "wlan0"

elif    [[ "$a" = "usb0" ]] ; then
        printf "usb0"

elif    [[ "$a" =~ ["$c"] ]] ; then
        printf "multiple"

else
        printf "not connected"
fi

#494 Re: Off-topic » Info » AppImage security and alternatives » 2020-12-23 15:16:43

golinux wrote:

These pre-packaged all-in-one apps are an aberration and insult to Linux users.  Methinks they are for handicapped Winblows refugees who don't know what they're doing.

looks as though they are trying to emulate google play store, apple itunes, microsoft download etc for the gnome smartphone software, ever increasingly gnome desktop will probably morph into an android/iphone os spinoff. I was looking at that gnome look org and some of the top themes are all apple mac clones for gtk3, lol...

#495 Re: Off-topic » Info » AppImage security and alternatives » 2020-12-23 12:40:29

Can these appimages be used in software centers like gnome software or kde etc? Ive never used them, just curious how they are got.

#496 Re: Off-topic » Info » GNU/Linux for smartphones » 2020-12-22 14:52:22

Head_on_a_Stick wrote:

Related: https://xnux.eu/log/#017

And what's wrong with LineageOS & GrapheneOS? They're both open source operating systems that leverage Android rather than GNU/Linux and so would seem *much* better suited to smartphone usage.

that grapheneos looks interesting, if ever i come across a cheap pixel that is in their stable channel i would give it a try.

Im using lineageos, they have changed the way they do updates for my phone, i used to be able to update via the phone updater, now needs a push_update script via adb from a linux machine.

https://wiki.lineageos.org/devices/kltedv/update

#497 Re: Off-topic » post your interesting bashrc commands » 2020-12-22 14:19:10

messing around with a minimal exit menu script.

get_exit () {
read -n 1 -p "(e)xit, (r)eboot, (s)hutdown, (l)ock  " exit;

case $exit in
    e)
       pkill xinit;;
    r)
        sudo reboot;;
    s)
        sudo poweroff;;
    l)
       xscreensaver-command -l;;
esac

}

this could be a separate script as well, ive called an xterm using the following line as a keybind from my window manager. This places a small xterm in the center of the screen and all i need do is press whatever button needed or press escape to quit the xterm.

xterm -geo 50x1+400+300 -e exit-menu

#498 Re: Other Issues » [SOLVED] File manager delay after boot/login » 2020-12-22 00:08:02

Head_on_a_Stick wrote:
dice wrote:

This is why i dislike where gnome is heading

Almost all the desktop environments have some sort of indexing feature, it's actually quite useful for some users.

yes, i suppose it is a useful feature for some, i have read it that tracker, tracker miner etc have been known to use a lot of memory and cpu load in doing what they do. I dont use desktop environments anymore so im somewhat bias. Last year a security risk via gnome extensions was found called evilgnome, unrelated to tracker but i find these web extensions to be a security risk, im assuming tracker search is a gnome web extension?

https://www.securityweek.com/evilgnome- … inux-users

https://extensions.gnome.org/extension/ … er-search/

#499 Re: Other Issues » [SOLVED] File manager delay after boot/login » 2020-12-21 13:45:46

Head_on_a_Stick wrote:

Erm, not sure. Tracking the cache, perhaps? tongue

I asked startpage.com and it said https://www.noulakaz.net/2019/04/09/dis … t-need-it/

and therein is the answer. This is why i dislike where gnome is heading.

#500 Re: Other Issues » [SOLVED] File manager delay after boot/login » 2020-12-21 13:38:43

Head_on_a_Stick wrote:

Try this:

rm ~/.xsession-errors
nautilus

Then check ~/.xsession-errors after Nautilus launches.

EDIT: https://unix.stackexchange.com/question … ing-buster

what is ~/.cache/tracker/ doing ?

Board footer

Forum Software