User:Przemoc/Notes: Difference between revisions
m (Use Cat and cmd templates (but not everywhere, because cmd requires too much escaping to be convenient).) |
m (nowiki'd dead links.) |
||
(11 intermediate revisions by one other user not shown) | |||
Line 21: | Line 21: | ||
Prompt after above change and relogin: <code style="background-color:black;color:gray;"><span style="color:red;">baytrail [</span>~<span style="color:red">]#</span> </code> | Prompt after above change and relogin: <code style="background-color:black;color:gray;"><span style="color:red;">baytrail [</span>~<span style="color:red">]#</span> </code> | ||
In case of normal users it's: <code style="background-color:black;color:gray;"><span style="color:lightgreen;">baytrail [</span>~<span style="color:lightgreen">]$</span> </code> | |||
==== Long history ==== | ==== Long history ==== | ||
Line 29: | Line 31: | ||
export HISTFILESIZE{{=}}$HISTSIZE | export HISTFILESIZE{{=}}$HISTSIZE | ||
}} | }} | ||
=== Console === | |||
If you have physical access to screen connected to your machine with AL, it's nice to have properly configured console. | |||
==== UTF-8 encoding ==== | |||
To have UTF-8 from OpenRC point of view, you have to set in <code>/etc/rc.conf</code>: | |||
<pre>unicode="YES"</pre> | |||
and add <code>/etc/init.d/termencoding</code> to autostart: | |||
{{cmd|rc-update add termencoding}} | |||
In fact it's mostly irrelevant (prove me wrong). | |||
==== Font with polish letters ==== | |||
To be able to see polish letters, you have to install ''kbd-misc'' package, set in <code>/etc/conf.d/consolefont</code>: | |||
<pre>consolefont="lat2-sun16.psfu.gz" | |||
consoletranslation="8859-2_to_uni.trans"</pre> | |||
and add <code>/etc/init.d/consolefont</code> to autostart: | |||
{{cmd|rc-update add consolefont}} | |||
If you don't like default <code>default8x16.psf.gz</code> font, then use <code>lat2-16.psfu.gz</code> instead. If you're comfortable with lower letter height, then I suggest using <code>lat2-14.psfu.gz</code>, which is still readable, yet on my 1920x1200 display increases LINES number from 75 to 85. | |||
==== Keymap with only right Alt used for inputting polish letters ==== | |||
Default polish keymap <code>pl</code> uses both Alt keys for polish letters. If you prefer left Alt to be usable for other stuff (like switching to active window in irssi via Alt+A), then you have to switch to <code>pl1</code> variant. ''bkeymaps'' package is needed for setting, but can be removed later. | |||
{{cmd|setup-keymap pl pl1}} | |||
==== UTF-8 in tmux ==== | |||
tmux checks upon start-up whether environment variable <code>LC_ALL</code>, or if it's empty then <code>LC_CTYPE</code>, or if it's empty then <code>LANG</code>, contain string <code>UTF-8</code> or <code>UTF8</code> to activate its UTF-8 mode. It can be also triggered by <code>-u</code> option. Important part is that globally turning on <code>utf8</code> window option in tmux configuration doesn't enforce UTF-8 mode. | |||
musl has locale system since v1.1.4, it was incomplete and experimental, but I'm not sure how it is now. The thing is it's not leveraged by AL and by default you have no <code>LC_*</code> variables set. In musl built-in default is <code>C.UTF-8</code>, so we can simply create one file to set <code>LC_CTYPE</code> to such default value and it will satisfy tmux check: | |||
{{Cat|/etc/profile.d/locale.sh|export LC_CTYPE{{=}}C.UTF-8 | |||
}} | |||
Possible alternative is to alias <code>tmux</code> to <code>tmux -u</code>, but it seems clunky. | |||
==== Serial console ==== | |||
To get tty on serial port you have to uncomment line in <code>/etc/inittab</code>: | |||
<pre> | |||
ttyS0::respawn:/sbin/getty -L ttyS0 115200 vt100 | |||
</pre> | |||
If you want to be able to log as root using serial console, you have to add the serial port (here: <code>ttyS0</code>) to <code>/etc/securetty</code>. | |||
Finally you can reload <code>init</code> process configuration: | |||
{{cmd|kill -HUP 1 | |||
}} | |||
Now you'll see login stuff on the serial port. | |||
=== Disk === | === Disk === | ||
Line 120: | Line 173: | ||
modprobe: ERROR: missing parameters. See -h. | modprobe: ERROR: missing parameters. See -h. | ||
</pre> | </pre> | ||
It can be fixed by improving sed command in <code>/etc/init.d/modules</code> from <code>'s/\#.*//g'</code> to <code>'s/\#.*//g;/^[ | It can be fixed by improving sed command in <code>/etc/init.d/modules</code> from <code>'s/\#.*//g'</code> to <code><nowiki>'s/\#.*//g;/^[[:space:]]*$/d'</nowiki></code> (deleting blank lines). | ||
{{note|Patch has been sent to alpine-devel ML. <nowiki>http://thread.gmane.org/gmane.linux.distributions.alpine.devel/3432</nowiki>. It was applied in commit [http://git.alpinelinux.org/cgit/aports/commit/?id{{=}}fc95677dd60833bca07ad5c2a037058e94471ff7 fc95677dd608] (2016-04-21)}} | |||
<li>It seems that nowadays you don't have to add <code>lm_sensors</code> to autostart, because in AL ''lm_sensors'' package is patched to create file <code>/etc/modules-load.d/lm_sensors.conf</code> (files in this directory are inspected by <code>/etc/init.d/modules</code>). <code>/etc/init.d/lm_sensors</code> seems in fact superfluous and it also doesn't work | <li>It seems that nowadays you don't have to add <code>lm_sensors</code> to autostart, because in AL ''lm_sensors'' package is patched to create file <code>/etc/modules-load.d/lm_sensors.conf</code> (files in this directory are inspected by <code>/etc/init.d/modules</code>). <code>/etc/init.d/lm_sensors</code> seems in fact superfluous and it also doesn't work | ||
Line 128: | Line 182: | ||
</pre> | </pre> | ||
because it expects old file (<code>/etc/conf.d/lm_sensors</code>), which is no longer provided. | because it expects old file (<code>/etc/conf.d/lm_sensors</code>), which is no longer provided. | ||
{{note|Problem has been reported to alpine-devel ML: <nowiki>http://thread.gmane.org/gmane.linux.distributions.alpine.devel/3433</nowiki>. File has been removed in commit [http://git.alpinelinux.org/cgit/aports/commit/?id{{=}}05ca027f69eb029ba8ddc97700639dbe5cb3ad91 05ca027f69eb] (2016-04-20). | |||
}} | |||
</ol> | </ol> | ||
{{ | === Mail === | ||
I don't need my own real mail server (as it's kind of PITA to set it up properly nowadays). Simple MTA is good enough. In the old days I used ssmtp, but it stopped being maintained (apparently debian devs maintain it now), so I switched to msmtp. | |||
==== msmtp ==== | |||
After installing ''msmtp'' package, you need to create configuration file in your home directory. You can find example for Zoho Mail account. | |||
{{Cat|~/.msmtprc|defaults | |||
tls on | |||
tls_trust_file /etc/ssl/certs/ca-certificates.crt | |||
logfile ~/.msmtp.log | |||
auth on | |||
port 587 | |||
account yourname@zoho.com | |||
from yourname@zoho.com | |||
user yourname@zoho.com | |||
host smtp.zoho.com | |||
account default : yourname@zoho.com | |||
}} | |||
You'll be asked for password every time mail is sent. | |||
===== Problems ===== | |||
If you use gmail, then it's no longer that simple. After changing each zoho to gmail in above exemplary configuration, you still won't be able to send any mail. You'll get: | |||
<pre>msmtp: server message: 534-5.7.14 <https://accounts.google.com/signin/continue?sarp=1&scc=1&plt=...> Please log in via your web browser and then try again. | |||
msmtp: server message: 534-5.7.14 Learn more at | |||
msmtp: server message: 534-5.7.14 https://support.google.com/mail/answer/78754 ... | |||
</pre> | |||
and you'll receive e-mail titled "Sign-in attempt prevented". | |||
You have to [https://www.google.com/settings/security/lesssecureapps turn on less secure apps] if you want to deal with it. If you're using 2-step verification, then you'll have to [https://security.google.com/settings/security/apppasswords add app password for msmtp]. | |||
=== Applications === | |||
Some tips for some applications. | |||
==== Irssi ==== | |||
Irssi is my IRC client of choice. | |||
===== /script support ===== | |||
You have to add following line in <code>~/.irssi/startup</code>: | |||
<pre>/LOAD perl</pre> |
Latest revision as of 02:49, 28 August 2023
I finally installed AL and I'm poking it a bit. Here you can find some notes regarding this experience. They should be helpful, but please use them with caution. I may add some additional commentary sometimes. If you think there is a better way to perform some of mentioned here tasks, then don't hesitate to notify me about it. Top-level headings denotes AL version that was used. Backward and forward compatibility is possible, but not tested.
Alpine Linux 3.3.3
Shell
Even though I always try to write POSIX sh-compliant scripts, I like to have bash
as my default shell, because it's quite handy. Being able to write for instance quick diff -u <(COMMAND1) <(COMMAND2)
(to compare output of two commands) or mv FILE{,SUFFIX}
(to rename file by adding suffix) is very convenient.
Bash as default shell
AL doesn't have vipw
, so root has to perform vi /etc/passwd
himself to change the last field of root record (should be the first line in the file). You have to install util-linux package to get chsh
utility.
Activate color prompt
Initial prompt: baytrail:~#
mv /etc/profile.d/color_prompt{,.sh}
Prompt after above change and relogin: baytrail [~]#
In case of normal users it's: baytrail [~]$
Long history
I like to have long history, so I created following file:
Contents of /etc/profile.d/long_history.sh
Console
If you have physical access to screen connected to your machine with AL, it's nice to have properly configured console.
UTF-8 encoding
To have UTF-8 from OpenRC point of view, you have to set in /etc/rc.conf
:
unicode="YES"
and add /etc/init.d/termencoding
to autostart:
rc-update add termencoding
In fact it's mostly irrelevant (prove me wrong).
Font with polish letters
To be able to see polish letters, you have to install kbd-misc package, set in /etc/conf.d/consolefont
:
consolefont="lat2-sun16.psfu.gz" consoletranslation="8859-2_to_uni.trans"
and add /etc/init.d/consolefont
to autostart:
rc-update add consolefont
If you don't like default default8x16.psf.gz
font, then use lat2-16.psfu.gz
instead. If you're comfortable with lower letter height, then I suggest using lat2-14.psfu.gz
, which is still readable, yet on my 1920x1200 display increases LINES number from 75 to 85.
Keymap with only right Alt used for inputting polish letters
Default polish keymap pl
uses both Alt keys for polish letters. If you prefer left Alt to be usable for other stuff (like switching to active window in irssi via Alt+A), then you have to switch to pl1
variant. bkeymaps package is needed for setting, but can be removed later.
setup-keymap pl pl1
UTF-8 in tmux
tmux checks upon start-up whether environment variable LC_ALL
, or if it's empty then LC_CTYPE
, or if it's empty then LANG
, contain string UTF-8
or UTF8
to activate its UTF-8 mode. It can be also triggered by -u
option. Important part is that globally turning on utf8
window option in tmux configuration doesn't enforce UTF-8 mode.
musl has locale system since v1.1.4, it was incomplete and experimental, but I'm not sure how it is now. The thing is it's not leveraged by AL and by default you have no LC_*
variables set. In musl built-in default is C.UTF-8
, so we can simply create one file to set LC_CTYPE
to such default value and it will satisfy tmux check:
Contents of /etc/profile.d/locale.sh
Possible alternative is to alias tmux
to tmux -u
, but it seems clunky.
Serial console
To get tty on serial port you have to uncomment line in /etc/inittab
:
ttyS0::respawn:/sbin/getty -L ttyS0 115200 vt100
If you want to be able to log as root using serial console, you have to add the serial port (here: ttyS0
) to /etc/securetty
.
Finally you can reload init
process configuration:
kill -HUP 1
Now you'll see login stuff on the serial port.
Disk
Set up RAID1 on two devices
# install package apk add mdadm # load "raid1" module during boot (not really needed if you perform further steps) echo raid1 >>/etc/modules # create RAID1 array on two whole disks with 1MB data offset mdadm --create --level=1 --raid-devices=2 --data-offset=1M /dev/md0 /dev/sda /dev/sdb # preserve original example mdadm.conf mv /etc/mdadm.conf{,.orig} # save current setup into configuration file # (usually people do not use -v, but it's more readable) mdadm --detail -v --scan >/etc/mdadm.conf # add raid devices starting to autostart rc-update add mdadm-raid # add raid devices monitoring to autostart rc-update add mdadm # start raid devices monitoring now /etc/init.d/mdadm start # following steps are needed if you want to support RAID early during boot # add "raid" to features (space-separated values) vi /etc/mkinitfs/mkinitfs.conf # rebuild /boot/initramfs-grsec mkinitfs # add "raid1" to modules (comma-separated values) vi /etc/update-extlinux.conf # update extlinux update-extlinux
Install smartctl and smartd
# install package apk add smartmontools # comment DEVICESCAN and uncomment DEVICESCAN -R 194 -R 231 -I 9 # to get meaningful and useful raw temperature in syslog vi /etc/smartd.conf # add smartd service to autostart rc-update add smartd # start the service now /etc/init.d/smartd start
Sensors
lm_sensors
# install package apk add lm_sensors # install package for detecting sensors (if needed) - installs perl too apk add lm_sensors-detect # load module required for detecting sensors modprobe i2c-dev # detect sensors (skip scanning Super I/O, IPMI, ISA if you're on grsec) sensors-detect # after detecting sensors you can remove perl (if you don't need it) apk del perl
Problems
sensors-detect
command created/etc/modules-load.d/lm_sensors.conf
file, but its first line is a comment, which leads to following message during bootmodprobe: ERROR: missing parameters. See -h.
It can be fixed by improving sed command in
/etc/init.d/modules
from's/\#.*//g'
to's/\#.*//g;/^[[:space:]]*$/d'
(deleting blank lines).Note: Patch has been sent to alpine-devel ML. http://thread.gmane.org/gmane.linux.distributions.alpine.devel/3432. It was applied in commit fc95677dd608 (2016-04-21)- It seems that nowadays you don't have to add
lm_sensors
to autostart, because in AL lm_sensors package is patched to create file/etc/modules-load.d/lm_sensors.conf
(files in this directory are inspected by/etc/init.d/modules
)./etc/init.d/lm_sensors
seems in fact superfluous and it also doesn't work* /etc/conf.d/lm_sensors does not exist, try running sensors-detect * ERROR: lm_sensors failed to start
because it expects old file (
/etc/conf.d/lm_sensors
), which is no longer provided.Note: Problem has been reported to alpine-devel ML: http://thread.gmane.org/gmane.linux.distributions.alpine.devel/3433. File has been removed in commit 05ca027f69eb (2016-04-20).
I don't need my own real mail server (as it's kind of PITA to set it up properly nowadays). Simple MTA is good enough. In the old days I used ssmtp, but it stopped being maintained (apparently debian devs maintain it now), so I switched to msmtp.
msmtp
After installing msmtp package, you need to create configuration file in your home directory. You can find example for Zoho Mail account.
Contents of ~/.msmtprc
You'll be asked for password every time mail is sent.
Problems
If you use gmail, then it's no longer that simple. After changing each zoho to gmail in above exemplary configuration, you still won't be able to send any mail. You'll get:
msmtp: server message: 534-5.7.14 <https://accounts.google.com/signin/continue?sarp=1&scc=1&plt=...> Please log in via your web browser and then try again. msmtp: server message: 534-5.7.14 Learn more at msmtp: server message: 534-5.7.14 https://support.google.com/mail/answer/78754 ...
and you'll receive e-mail titled "Sign-in attempt prevented".
You have to turn on less secure apps if you want to deal with it. If you're using 2-step verification, then you'll have to add app password for msmtp.
Applications
Some tips for some applications.
Irssi
Irssi is my IRC client of choice.
/script support
You have to add following line in ~/.irssi/startup
:
/LOAD perl