zsh.li Pinkhat Memories Me About ?

Dear My
Linux

Live Gentoo installation


Recently created my social network instance https://gentoo.live, so I remembered that this post was pending.

Long time ago I did a live Debian SID installation on Twitter, on November 2019 was Gentoo turn, on the Fediverse Network (Mastodon, Gnusocial, Pleroma) I posted my Gentoo installation commands:

Warning! This is not a Gentoo install guide, also my errors were posted!

1. screen
#This command allows me to resume my shell session if I close the terminal

2. mkfs.ext4 /dev/sda7
# I'm formatting an existing partition of my hard disk.

3. mount /dev/sda7 /mnt/tmp/

4. cd /tmp && wget http://distfiles.gentoo.org/releases/amd64/autobuilds/20191110T214504Z/stage3-amd64-20191110T214504Z.tar.xz
#Downloading Gentoo, my network is slow, one hour remaining.

5. cd /mnt/tmp/ && tar xpvf /tmp/stage3-*.tar.xz --xattrs-include='*.*' --numeric-owner
# Extracts the Gentoo tarball into the partition.

6. mount --bind /run/ /mnt/tmp/run/ && mount --bind /proc /mnt/tmp/proc && mount --bind /dev /mnt/tmp/dev/ && mount --bind /sys/ /mnt/tmp/sys/ && chroot /mnt/tmp/
# Chroot into gentoo.

7. source /etc/profile

8. nano /etc/portage/make.conf

# There I added this line:
MAKEOPTS="-j3"
The number is the double of the cpu cores plus one.
And modified the COMMON FLAGS variable to this value:
-march=native -O2 -pipe

9. mkdir --parents /etc/portage/repos.conf && cp /usr/share/portage/config/repos.conf /etc/portage/repos.conf/gentoo.conf && emerge --sync
#note: out of the chroot cp the /etc/resolv.conf to the chroot

# 10.  I had an unexpected error I had never had in life. I solved in this way:

rm -rf /usr/portage/app-crypt/openpgp-keys-gentoo-release && emerge --sync
# Thanks forums!

11. emerge -1 mirrorselect
# This is taking a while, meanwhile I can practice the Lotus pose and listen at sacred music.

#11.5  I remembered that is a good idea to mount a tmpfs into /var/tmp, I will do so when the mirrorselect compilation ends. 

12. mirrorselect -i -o >> /mnt/gentoo/etc/portage/make.conf
# I selected some mirrors here

13. mount -t tmpfs tmpfs /var/tmp/
# Mounted a tmpfs into /var/tmp

14. eselect profile list

15. eselect profile set 5
# Chose the desktop profile

16. emerge --ask app-portage/cpuid2cpuflags

Calculating dependencies... done!
[ebuild N ] app-portage/cpuid2cpuflags-6
Would you like to merge these packages? [Yes/No] Yes

17. echo "*/* $(cpuid2cpuflags)" >> /etc/portage/package.use/00cpuflags

18. emerge -NaDu @world
# Updating the system

18.5 emerge etc-update
# I cancel the system update, portage is not happy with the USEs, I'm going to install etc-update for helping me editing uses files:

18.9 # I made a mistake, etc-update is part of the base system.

19. etc-update
# Ask for user input, I merge the uses file (/etc/portage/package.use/00cpuflags) with -3:

20. emerge -NaDu @world

# I retry the world update, this will recompile the system # I said yes and the compilation started

20.5 # Killed the system update by accident, I resumed using:
emerge --resume

20.6 Still compiling...

20.7 I will take a nap

20.8 . # Your sleepy beauty is back, but a package failed to compile

20.9 # I realized that I selected the wrong profile, in my day, only the 13.0 profiles were available, from the 2017 seems that Gentoo uses 17s profiles. Probably the first apps I will  install will be Wine and steam to check the multi lib support. 
So, in the end I will have to perform an extra step to migrate from 17.0 to 17.1, ah, also it can be a good idea to remove some global uses.

20.99 The base system and the basic X libraries have been being compiled for 8 hours, I will sleep, nini !! This step (number 20) will be completed during my sleep time

SECOND DAY
21. emerge --ask app-portage/gentoolkit
# I need this tool to check the uses descriptions

22. emerge --info | grep ^USE
# I will disable global uses

23. # I added this line to /etc/portake/make.conf
USE="-kde -bluetooth -ipv6 -nls -gmp -qt5"

24. emerge -NDu @world
# I will rebuild the affected packages to maintain USEs coherency in the future, also added the consolekit, networkmanager and dbus global use

25. # I canceled the rebuild, disabling nls affects gcc (it will be recompiled)

emerge genlop
# genlop is need for measure the compiling time
# I enabled the timezone for reporting the correct time:
echo "America/Mexico_City" > /etc/timezone

genlop -t gcc
pinkstar / # genlop -t sys-devel/gcc-9.2.0-r2
!!! Error: no merge found for 'sys-devel/gcc-9.2.0-r2'


# It seems that I haven't recompiled the toolchain. Welp, I will resume the world rebuilding

emerge -aNDu --with-bdeps=y @world

25.5 # Also added dbus as global use

26. emerge -1v app-portage/unsymlink-lib
# Time to migrate from 17.0 profile to 17.1 (this is an extra step because I chose a wrong profile)

27. unsymlink-lib --migrate

28. eselect profile set default/linux/amd64/17.1/desktop
# Since this is a new Gentoo installation, the past two steps was not needed, instead it only was need to change the profile to the new one.

29. # I'm moving the Slackware kernel sources to /usr/src in Gentoo. I'm not sure, but this will save me 6 hours of compilation and the kernel configuration part which is the most exciting thing in Gentoo. 

30. cd /usr/linux/src && make install
# Since the grub is managed by slackware, I will modify the grub in Slackware

30.5 # Added to /etc/fstab:
/dev/sda7 / ext4 noatime 0 1

31. emerge -a xorg-server

31.5 I had modified the VIDEO_CARDS variable in /etc/portage/make.conf

31.6 Added libinput keyboard mouse to INPUT_DEVICES in make.conf

32. # I almost forgot in /usr/src/linux:
make modules_install

33. emerge awesome
# This will install the windows manager.

34. emerge -a networkmanager-openvpn openvpn dhcpcd lynx links dhcpcd networkmanager nm-applet screenfetch zsh sakura spacefm cryptsetup btrfs-progs squashfs-tools lvm2 gnuchess bsd-games xautolock slock

# I will install some apps, however I created an uses file in /etc/portage/package.use/apps with this content:
sys-fs/squashfs lz4 lzma lzo
net-wireless/wpa_supplicant ap eap-sim eapol_test fasteap macsec p2p privsep smartcard tdls uncommon-eap-types -wimax wps
media-video/ffmpeg x265 vpx wavpack webp theora twolame opus libass libcaca gmp fontconfig openh264 wavpack
net-misc/networkmanager connection-sharing
And modified some others with etc-update

35. Bad news and good news.
The bad news is that my computer had a kernel panic. Which made me to reboot my computer interrupting the Gentoo installation.
The good news is that I was able to boot into Gentoo with the awesome WM and my custom wallpaper.
However I had to reboot the computer using REISUB since I am not in the sudoers file nor root has a pass!!
And my keyboard is not working in xorg, but I think that is because is one of these old ps/2 keyboards. It's easy to solve.

35.5 However I just installed Gentoo, but we want perfection, don't we?

36. emerge -a sudo

37. visudo
# Uncomment the wheel group
38. gpasswd -a $myuser wheel

39. emerge --resume
# This will take a while

40 ln -s /usr/share/X11/xorg.conf.d/40-libinput.conf /etc/X11/xorg.conf.d/
# I will try to solve the keyboard issue with this command, I'm still compiling software.

41. Everything works perfect, I'm sending this post from Gentoo, I will use Gentoo forever! and remember, you never end to install Gentoo. It took me two days using a Celeron processor. 


Email notifications in your terminal


I lost my domain zsh.li mainly because I didn't check my email pretty often, getting email notifications in the terminal is pretty easy, but it took me a while to figure out how to do it.

This is an old-fashioned method, but I like because nowadays developers are too obsessive with deficient and bloated apps, it can use IMAP but I like POP3 as it deletes the original message from the server which is great for privacy.

I'm using Slackware current which is the testing branch for Slackware 15. Slackware current is using Postfix as the system mail service, surprisingly Postfix is also used for an internet email server but here postfix is restricted to our local installation.

Sadly I haven't been receiving the cron mails in a lot of time and the command mailq showed me lots of mails in queue, so I had to fix the postfix service, I did so generating an alias database. Mailq show me lots of mail alias errors.

Most of time the mail system works out of the box, so you will only need the following:

1. Install fetchmail

2. Paste the following code and replace daya with your local unix user, mail.gmail.com with the mail domain, flor@gmail.com to your email address and parangaricutirimicuaro to your password:


set daemon 600
set syslog
poll mail.gmail.com
  with nodns,
  with protocol POP3
  user "flor@gmail.com" there is daya here,
  with password parangaricutirimicuaro ,
  with ssl, sslcertck;

Add to .bashrc (or .profile):

mail -e && mail -H

And for having an ascii cow displaying the email headers:

mail -e && cowsay "$(mail -H)"

You may need to install the bsdgames for it

Notice: Your emails would be deleted from the email server. You may add the keep parameter after here (daya here)


How to automatically convert the PNG pictures to JPG images.


On the server I have this script running in the background that converts all the PNG files I upload through SFTP to the jpg format in order to improve the website performance.

Requeriments: inotify-tools


#! /bin/bash
inotifywait -m --format '%w%f' -e close_write -r /var/www/ | while read FILE
do
	if ( echo $FILE  | grep -e png$ ); then
#	       sleep 10 
	       convert "$FILE" "${FILE%.png}.jpg"
	      mv "$FILE" /tmp
	       fi
done

How to record and replay a terminal session


Paste the following code in $HOME/.profile or $HOME/.bashrc

, I was inspired for internet forums, however I added the exit function a, it's important mainly for SSH. Also included the time parameter, using the time parameter allows us to replay the script record using the scriptreplay --time=FILE1 FILE2 command.

In the case that you want it to be more hidden or system-wide you can add the code into /etc/profile.


mkdir -p $HOME/.log
test "$(ps -ocommand= -p $PPID) | awk '{print $1}')" == 'script'  || script --timing=$HOME/.logs/$(date +%s).time $HOME/.logs/$(date +%s) -q

if [[ "$(ps -ocommand= -p $PPID) | awk '{print $1}')" == 'script' ]]; then
	exit
else
kill -9 $$
fi

Getting ip from radio streaming station


First of all you may use directory.shoutcast.com for getting the ip and port that may change over the time.

However using this method I wasn't able to search any working vocaloid station, so I searched it in my favorite search engine and found this online vocaloid radio site: vocaloidradio,, however despite of using the developers tools in the web browser I wasn't able to find the streaming station IP, this javascripts radio players are getting smarter over time for hiding the source IP.

The most surprising is that the servers are using a free technology for streaming, icecast, however the fronted is privative and includes advertisement. So even if the web browser is not showing me the ip, I had an idea, I would use a package instrospection tool if that is the right name, I used iptraf-ng in Linux for monitoring in realtime all the ips with the DNS revolver enabled and found this url: http://curiosity.shoutca.st:8019/. This is the icecast webserver page. Here I was able to download the right port of this streaming service since this software is free.

This is helpful because I like to use streamripper to download the music I'm listen to because I believe in sharing.