Share your Debian SCRIPTS
- fabien
- Forum Helper
- Posts: 1158
- Joined: 2019-12-03 12:51
- Location: Anarres (Toulouse, France actually)
- Has thanked: 101 times
- Been thanked: 265 times
Re: Share your Debian SCRIPTS
As I don't plan to change my apps, I have no reason to postpone.
updated apt-fly from v.3.1 to v.3.2
- working on arbitrary packages is no longer limited by the maximum length of system arguments,
in other words, it is now possible to work with as many packages as one likes
(this was previously possible, but extremely slow)
updated apt-fly from v.3.1 to v.3.2
- working on arbitrary packages is no longer limited by the maximum length of system arguments,
in other words, it is now possible to work with as many packages as one likes
(this was previously possible, but extremely slow)
Share your Debian SCRIPTS
There will be neither barrier nor walls, neither official nor guard, there will be no more desert and the entire world will become a garden. — Anacharsis Cloots
There will be neither barrier nor walls, neither official nor guard, there will be no more desert and the entire world will become a garden. — Anacharsis Cloots
- Hallvor
- Global Moderator
- Posts: 2127
- Joined: 2009-04-16 18:35
- Location: Kristiansand, Norway
- Has thanked: 169 times
- Been thanked: 231 times
Re: Share your Debian SCRIPTS
A Russian Roulette Simulator - because I'm watching The Deer Hunter. Disclaimer: I am not trying to trivialize a serious issue, so please don't take offense: This is for entertainment and educational use only.
Code: Select all
#!/bin/bash
echo "Welcome to the Russian Roulette Simulator!"
# Number of chambers
num_chambers=6
# Load a bullet in a random chamber
bullet_chamber=$((1 + RANDOM % num_chambers))
# Function to pull the trigger
pull_trigger() {
outcome=$((1 + RANDOM % num_chambers))
[ "$outcome" -eq "$bullet_chamber" ] && echo "BANG! You got the bullet. Game over!" || echo "Click. You survived this round."
}
# Prompt trigger pull
read -p "Press Enter to pull the trigger..."
# Call the pull_trigger function
pull_trigger
[HowTo] Install and configure Debian bookworm
Debian 12 | KDE Plasma | ThinkPad T440s | 4 × Intel® Core™ i7-4600U CPU @ 2.10GHz | 12 GiB RAM | Mesa Intel® HD Graphics 4400 | 1 TB SSD
Debian 12 | KDE Plasma | ThinkPad T440s | 4 × Intel® Core™ i7-4600U CPU @ 2.10GHz | 12 GiB RAM | Mesa Intel® HD Graphics 4400 | 1 TB SSD
- fabien
- Forum Helper
- Posts: 1158
- Joined: 2019-12-03 12:51
- Location: Anarres (Toulouse, France actually)
- Has thanked: 101 times
- Been thanked: 265 times
Re: Share your Debian SCRIPTS
Note that this also works with the Linux kernel
Code: Select all
#!/bin/bash
echo "Welcome to the Linux Roulette Simulator!"
# Number of kernels
num_kernels=6
# sed -i 's/^GRUB_DEFAULT=[[:digit:]]$/GRUB_DEFAULT='"$((RANDOM % num_kernels))"'/' /etc/default/grub && update-grub && reboot
GRUB_default() {
echo "Setting GRUB default boot entry..."
outcome=$(( new_entry - RANDOM % num_kernels))
echo "Reboot..."; sleep 1
case "$outcome" in
14) echo "BANG! Kernel 6.1.0-$outcome, EXT4 data corruption. Game over!";;
15) echo "BOOM! Kernel 6.1.0-$outcome, WIFI down. Game over!";;
*) echo "Kernel 6.1.0-$outcome. You survived this reboot."; return 0;;
esac
return 1
}
# apt install linux-image-amd64
read -p "Press Enter to update the kernel..."
new_entry=$(( 17 - RANDOM % num_kernels ))
(( new_entry < 17 )) && echo -e "The following NEW packages will be installed:\nlinux-image-6.1.0-$new_entry" \
|| { echo "linux-image-amd64 is already the newest version"; exit 0; }
# update-grub and reboot
GRUB_default
Share your Debian SCRIPTS
There will be neither barrier nor walls, neither official nor guard, there will be no more desert and the entire world will become a garden. — Anacharsis Cloots
There will be neither barrier nor walls, neither official nor guard, there will be no more desert and the entire world will become a garden. — Anacharsis Cloots
- Hallvor
- Global Moderator
- Posts: 2127
- Joined: 2009-04-16 18:35
- Location: Kristiansand, Norway
- Has thanked: 169 times
- Been thanked: 231 times
Re: Share your Debian SCRIPTS
Nothing simulates the suffering of a loss or the thrill of a click like a potential malicious command on a production machine, but I am not going down that route.
[HowTo] Install and configure Debian bookworm
Debian 12 | KDE Plasma | ThinkPad T440s | 4 × Intel® Core™ i7-4600U CPU @ 2.10GHz | 12 GiB RAM | Mesa Intel® HD Graphics 4400 | 1 TB SSD
Debian 12 | KDE Plasma | ThinkPad T440s | 4 × Intel® Core™ i7-4600U CPU @ 2.10GHz | 12 GiB RAM | Mesa Intel® HD Graphics 4400 | 1 TB SSD
- FreewheelinFrank
- Global Moderator
- Posts: 2412
- Joined: 2010-06-07 16:59
- Has thanked: 45 times
- Been thanked: 266 times
Re: Share your Debian SCRIPTS
An XFCE genmon script to notify of unread mails in Claws Mail with Gmail.
Claws Mail will not notify of unread emails with Gmail, because it uses the IMAP "new" tag for notifications, which Google does not implement. Claws Mail won't fix this because Google is not following standards. There is a patch for Claws Mail 4.1 to notify of unread mails, which involves compiling Claws Mail. I did this for 4.1, but some of the plugins and spell checking didn't work, and with the update to 4.2, I decided to write a Genmon script to notify of unread mail, using Claws Mail terminal output.
This is the result:
The script uses the Claws Mail NewMail plugin to display the header of any unread mail. It's a bit flakey at times, but sometimes works nicely, as above. Other times it doesn't print headers, or prints header from old mail that has been filtered to the bin (despite setting Claws Mail not to scan the bin for new mail). My current theory is that it works best if the "all mail" folder is selected in Claws Mail.
I used a system icon for new mail, and greyed it out for the "no mail" icon. There are "no mail" icons available in installed icons, but I didn't like any of them.
I don't know scripting - it's just hacked together from bits of code from the internet - so it may not be the best code, but it works. Instructions are for other people like me who just dabble.
The commented-out line will delete the new mail log from time to time. I wondered if that was causing problems and commented it out.
Replace <Gmail address> and <user name> with personal address/user name.
The script needs two other scripts to work. Save as executable files in home directory, or directory of your choice but modify script accordingly. Not sure if they could have been incorporated in the main script.
panelclick.sh
Replace <n> with the genmon instance in Panel Preferences. (Hover to view).
refresh.sh
Again replace <n> with the genmon instance in Panel Preferences. (Hover to view).
Edit 6/1/24
Added a bit of code to remove emails sent to the bin after a certain date, which the NewMail plugin adds to the file of new mail headers for some reason, before displaying in the tooltip. Modified from answer 10 here:
https://unix.stackexchange.com/question ... sed-or-awk
Claws Mail will not notify of unread emails with Gmail, because it uses the IMAP "new" tag for notifications, which Google does not implement. Claws Mail won't fix this because Google is not following standards. There is a patch for Claws Mail 4.1 to notify of unread mails, which involves compiling Claws Mail. I did this for 4.1, but some of the plugins and spell checking didn't work, and with the update to 4.2, I decided to write a Genmon script to notify of unread mail, using Claws Mail terminal output.
This is the result:
The script uses the Claws Mail NewMail plugin to display the header of any unread mail. It's a bit flakey at times, but sometimes works nicely, as above. Other times it doesn't print headers, or prints header from old mail that has been filtered to the bin (despite setting Claws Mail not to scan the bin for new mail). My current theory is that it works best if the "all mail" folder is selected in Claws Mail.
I used a system icon for new mail, and greyed it out for the "no mail" icon. There are "no mail" icons available in installed icons, but I didn't like any of them.
Code: Select all
#!/bin/bash
allmail=$(claws-mail --status "#imap/<Gmail address>/[Google Mail]/All Mail" | awk '{print $2}')
inbox=$(claws-mail --status "#imap/<Gmail address>/INBOX" | awk '{print $2}')
lines=$(( $allmail * 10 ))
echo $lines
lastmails=$(tail -$lines /home/donald/Mail/NewLog | sed -e:b -e'$!{N;2,9bb' -e\} -e'/.*'Folder:[[:space:]]*Bin'/!P;D'| grep 'Date\|Subject\|From\|---' | sed 's/^\(.\{50\}\).*$/\1/' | sed 's/&/\&/g' | sed 's/</\‹/g' |sed 's/>/\›/g' | sed 's/Date://g;s/Subject://g;s/From://g' | sed -e 's/^[ \t]*//' | sed 's/+0000//' | sed 's/---//')
unread=$allmail
notifiedemails=$(cat /home/<user name>/Mail/count)
if [ $notifiedemails -gt $unread ] ; then
echo "0" > /home/<user name>/Mail/count
fi
if [ $unread -gt 0 ] && [ $unread -gt $notifiedemails ] ; then
canberra-gtk-play -i message
$(notify-send --hint=int:transient:1 --icon=internet-mail "Claws Mail" "$unread Unread Mail")
echo $unread > /home/<user name>/Mail/count
fi
if [ $unread -gt 0 ] ; then
PANEL="<icon>mail-mark-unread</icon>"
PANEL+="<iconclick>./refresh.sh</iconclick>"
TOOLTIP="<tool>"
TOOLTIP+="<span weight='bold'>Unread Emails: </span>\n"
TOOLTIP+="Inbox: $inbox\n"
TOOLTIP+="All Mail: $allmail\n"
TOOLTIP+="$lastmails\n\n"
TOOLTIP+="<span weight='bold'>Click to update</span>"
TOOLTIP+="</tool>"
else
echo $unread > /home/<user name>/Mail/count
#echo -n > /home/<user name>/Mail/NewLog
PANEL="<img>/home/<user name>/applications-email-panel.png</img>"
PANEL+="<click>./panelclick.sh</click>"
TOOLTIP="<tool>"
TOOLTIP+="<span weight='bold'>No unread emails</span>\n"
TOOLTIP+="Check for new mail"
TOOLTIP+="</tool>"
fi
echo -e "${PANEL}"
echo -e "${TOOLTIP}"
The commented-out line will delete the new mail log from time to time. I wondered if that was causing problems and commented it out.
Replace <Gmail address> and <user name> with personal address/user name.
The script needs two other scripts to work. Save as executable files in home directory, or directory of your choice but modify script accordingly. Not sure if they could have been incorporated in the main script.
panelclick.sh
Code: Select all
#!/bin/bash
claws-mail --receive
notify-send -t 5000 --hint=int:transient:1 "Claws Mail" "Checking for new messages" -i xfce-newmail
xfce4-panel --plugin-event=genmon-<n>:refresh:bool:true
allmail=$(claws-mail --status "#imap/<Gmail address>/[Google Mail]/All Mail" | awk '{print $2}')
if [ $allmail == 0 ]; then
echo -n > /<user name>/Mail/NewLog
fi
refresh.sh
Code: Select all
#!/bin/bash
allmailold=$(claws-mail --status "#imap/<Gmail address>/[Google Mail]/All Mail" | awk '{print $2}')
xfce4-panel --plugin-event=genmon-<n>:refresh:bool:true
allmailnew=$(claws-mail --status "#imap/<Gmail address>/[Google Mail]/All Mail" | awk '{print $2}')
new=$((allmailnew - allmailold))
if [ $allmailnew == $allmailold ] && [ $allmailnew -gt 0 ] ; then
notify-send -t 5000 --hint=int:transient:1 "Claws Mail" "No new mail \n$allmailnew unread" -i xfce-newmail
fi
if [ $allmailnew == 0 ] ; then
notify-send -t 5000 --hint=int:transient:1 "Claws Mail" "All mail read" -i xfce-newmail
fi
if [ $allmailnew -gt $allmailold ] ; then
notify-send -t 5000 --hint=int:transient:1 "Claws Mail" "$new new \n$allmailnew unread" -i xfce-newmail
fi
Edit 6/1/24
Added a bit of code to remove emails sent to the bin after a certain date, which the NewMail plugin adds to the file of new mail headers for some reason, before displaying in the tooltip. Modified from answer 10 here:
https://unix.stackexchange.com/question ... sed-or-awk
- fabien
- Forum Helper
- Posts: 1158
- Joined: 2019-12-03 12:51
- Location: Anarres (Toulouse, France actually)
- Has thanked: 101 times
- Been thanked: 265 times
Re: Share your Debian SCRIPTS
Never say never (which I didn't)
updated apt-fly from v.3.2 to v.3.3
- if the Release file of a Debian (apt) repository does not contain the
'No-Support-for-Architecture-all: Packages' field, clients split the Packages files between
'binary-all_Packages' and 'binary-$ARCH_Packages'. This is not yet the case for Debian
repositories, but it is for some repositories. This version takes this into account, and
this has also been corrected in schow-pkg v.5.1 and why-pkg v.0.11a.
- the Debian Policy Manual does not stipulate that the Package: field must be placed in the first
position in the stanza, and some (non-Debian) repositories actually place it elsewhere.
This can have consequences and has been corrected in this version as well as in schow-pkg v.5.1
and why-pkg v.0.11a.
updated schow-pkg from 5.0 to 5.1
- new -I option: show not installed packages only
- new -W option: pass the arguments to why-pkg
updated why-pkg from v.0.10a v.0.11a
- due to occurrences, a warning is issued if the APT database has not been correctly updated (f_audit)
- remaining dependencies on debtags have been removed and its installation is discouraged
- new Bash completion function, please update /etc/bash_completion.d/why-pkg
- added 'provided by' information for real packages when using c/C/y/Y options (f_why)
- new -Z option: count all possible installed reverse dependencies for each package (f_reverse)
updated apt-fly from v.3.2 to v.3.3
- if the Release file of a Debian (apt) repository does not contain the
'No-Support-for-Architecture-all: Packages' field, clients split the Packages files between
'binary-all_Packages' and 'binary-$ARCH_Packages'. This is not yet the case for Debian
repositories, but it is for some repositories. This version takes this into account, and
this has also been corrected in schow-pkg v.5.1 and why-pkg v.0.11a.
- the Debian Policy Manual does not stipulate that the Package: field must be placed in the first
position in the stanza, and some (non-Debian) repositories actually place it elsewhere.
This can have consequences and has been corrected in this version as well as in schow-pkg v.5.1
and why-pkg v.0.11a.
updated schow-pkg from 5.0 to 5.1
- new -I option: show not installed packages only
- new -W option: pass the arguments to why-pkg
updated why-pkg from v.0.10a v.0.11a
- due to occurrences, a warning is issued if the APT database has not been correctly updated (f_audit)
- remaining dependencies on debtags have been removed and its installation is discouraged
- new Bash completion function, please update /etc/bash_completion.d/why-pkg
- added 'provided by' information for real packages when using c/C/y/Y options (f_why)
- new -Z option: count all possible installed reverse dependencies for each package (f_reverse)
Share your Debian SCRIPTS
There will be neither barrier nor walls, neither official nor guard, there will be no more desert and the entire world will become a garden. — Anacharsis Cloots
There will be neither barrier nor walls, neither official nor guard, there will be no more desert and the entire world will become a garden. — Anacharsis Cloots
- ruwolf
- Posts: 907
- Joined: 2008-02-18 05:04
- Location: Banovce nad Bebravou
- Has thanked: 89 times
- Been thanked: 67 times
Re: Share your Debian SCRIPTS
Hello.
I use very simple script, when I need bigger place than is my maximal resolution of monitor.
It is called panning in xrandr.
I am very lazy to write help in it.
Without arguments, it sets maximal resolution without panning.
With -h2 option, it set panning height to 2 × maximal monitor height.
With -w1.5 option, it sets panning width to 1.5 × maximal monitor width.
(Of course, numbers can be different, here are only examples and options can be combined.)
It contains several commented out commands, which I have used for trivial debugging.
There is also commented out alternative, when I have also set DPI by it.
I use very simple script, when I need bigger place than is my maximal resolution of monitor.
It is called panning in xrandr.
I am very lazy to write help in it.
Without arguments, it sets maximal resolution without panning.
With -h2 option, it set panning height to 2 × maximal monitor height.
With -w1.5 option, it sets panning width to 1.5 × maximal monitor width.
(Of course, numbers can be different, here are only examples and options can be combined.)
It contains several commented out commands, which I have used for trivial debugging.
There is also commented out alternative, when I have also set DPI by it.
Code: Select all
#!/bin/env sh
# RES=`xrandr -q | grep -P -o '^ +\d+x\d+' | head -n 1 | grep -P -o '\d+x\d+'`
DPI=142
while getopts h:w: f ; do
case $f in
h) harg=$OPTARG;;
w) warg=$OPTARG;;
# \?) echo $USAGE; exit 1;;
esac
done
xrandr_q=`xrandr -q`
# echo "xrandr_q=$xrandr_q"
DEV=`echo "$xrandr_q" | egrep -o '^[-[:alnum:]]* +connected primary' | egrep -o '^[^ ]+'`
# echo "DEV=$DEV"
MON_RES=`echo "$xrandr_q" | egrep -o '^ +[x0-9]+' | head -n 1 | egrep -o '[x0-9]+'`
# echo "MON_RES=$MON_RES"
MON_W=${MON_RES%x*}
MON_H=${MON_RES#*x}
# echo "MON_W=$MON_W MON_H=$MON_H"
# echo "harg=$harg warg=$warg"
SCR_W=`echo "scale=0; $MON_W*${warg:=1}"|bc -l`
SCR_H=`echo "scale=0; $MON_H*${harg:=1}"|bc -l`
SCR_W=${SCR_W%.*}
SCR_H=${SCR_H%.*}
# echo "SCR_W=$SCR_W"
# echo "SCR_H=$SCR_H"
# cmd="xrandr --output ${DEV} --dpi ${DPI} --mode ${MON_W}x${MON_H} --panning ${SCR_W}x${SCR_H}"
cmd="xrandr --output ${DEV} --mode ${MON_W}x${MON_H} --panning ${SCR_W}x${SCR_H}"
echo $cmd
$cmd
- wizard10000
- Global Moderator
- Posts: 1152
- Joined: 2019-04-16 23:15
- Location: southeastern us
- Has thanked: 121 times
- Been thanked: 201 times
Re: Share your Debian SCRIPTS
disclaimer: I'm pretty anal about backups
Thought I would share part of my backup solution. There are four Debian machines here - each machine has a script that backs up the important stuff to a server drive - the machines are scheduled 30 minutes apart. To optimize the backup all six of the rsync tasks below run in parallel. The local machine scripts are simple, they look like this -backups are pretty speedy, if there's nothing to sync this script takes less than a minute to run. Breakdown below the script -
First thing I do is create a dump of packages I have installed and stick that list in /etc/apt so I can use it to restore applications I had installed.
Next, we use mountpoint to check to see if the target drive is actually mounted; if it's not mounted the script sets an errorlevel an exits,
The six rsync jobs are run in parallel instead of sequentially (notice that five of them end in "&").
After that we sync filesystems to ensure disk writes are complete and clear swap before exiting the script.
The server-side backup script also copies backups from all four machines to gdrive, syncs documents and pictures back to all four machines so all four machines have the same content and then clones the backup drive to two additional drives, on mounted on the server and another mounted on another machine on the network.
¿See? Toldja I was pretty anal about backups Hope this gives some folks ideas about backing up their own systems.
Thought I would share part of my backup solution. There are four Debian machines here - each machine has a script that backs up the important stuff to a server drive - the machines are scheduled 30 minutes apart. To optimize the backup all six of the rsync tasks below run in parallel. The local machine scripts are simple, they look like this -backups are pretty speedy, if there's nothing to sync this script takes less than a minute to run. Breakdown below the script -
Code: Select all
#!/bin/bash
dpkg --get-selections > /etc/apt/dpkg-selections.list
if mountpoint -q /media/server-internal; then
/usr/bin/rsync -qa --chown=wizard:wizard --del /etc/ /media/server-internal/laptop/etc &
/usr/bin/rsync -qa --chown=wizard:wizard --del /usr/local/ /media/server-internal/laptop/usr-local &
/usr/bin/rsync -qa --chown=wizard:wizard /home/wizard/documents/ /media/server-internal/documents &
/usr/bin/rsync -qa --chown=wizard:wizard /home/wizard/pictures/ /media/server-internal/pictures &
/usr/bin/rsync -qa --chown=wizard:wizard --exclude-from=/usr/local/etc/rsync/exclude --del /root/ /media/server-internal/laptop/root &
/usr/bin/rsync -qa --chown=wizard:wizard --exclude-from=/usr/local/etc/rsync/exclude --del /home/wizard/ /media/server-internal/laptop/home
else
exit 1
fi
sync
swapoff -a && swapon -a
exit 0
Next, we use mountpoint to check to see if the target drive is actually mounted; if it's not mounted the script sets an errorlevel an exits,
The six rsync jobs are run in parallel instead of sequentially (notice that five of them end in "&").
After that we sync filesystems to ensure disk writes are complete and clear swap before exiting the script.
The server-side backup script also copies backups from all four machines to gdrive, syncs documents and pictures back to all four machines so all four machines have the same content and then clones the backup drive to two additional drives, on mounted on the server and another mounted on another machine on the network.
¿See? Toldja I was pretty anal about backups Hope this gives some folks ideas about backing up their own systems.
we see things not as they are, but as we are.
-- anais nin
-- anais nin
Re: Share your Debian SCRIPTS
@fabien , could you upload those to some sort of publicly available git repository? I would imagine they are tracked in version-control system on your side.
- fabien
- Forum Helper
- Posts: 1158
- Joined: 2019-12-03 12:51
- Location: Anarres (Toulouse, France actually)
- Has thanked: 101 times
- Been thanked: 265 times
Re: Share your Debian SCRIPTS
Why should I? How would it be useful for you?/usr/ wrote: 2024-09-03 20:07 could you upload those to some sort of publicly available git repository?
No they are not, I found it a bit overkill for single file projects. I just make a copy in a directory before major changes so I can track the origin of bugs, compare performance, keep track of tested solutions and so on. I have more than forty intermediate versions of why-pkg./usr/ wrote: 2024-09-03 20:07 I would imagine they are tracked in version-control system on your side.
Share your Debian SCRIPTS
There will be neither barrier nor walls, neither official nor guard, there will be no more desert and the entire world will become a garden. — Anacharsis Cloots
There will be neither barrier nor walls, neither official nor guard, there will be no more desert and the entire world will become a garden. — Anacharsis Cloots
- fabien
- Forum Helper
- Posts: 1158
- Joined: 2019-12-03 12:51
- Location: Anarres (Toulouse, France actually)
- Has thanked: 101 times
- Been thanked: 265 times
Re: Share your Debian SCRIPTS
updated apt-fly from v.3.4 to v.3.5
- edge case fix
updated schow-pkg from v.5.1 to v.5.2
- new -B option: human readable “apt-listbugs”
- new -c option: retrieve package changelog
- new -P option: human readable “apt-cache policy”
- The -d option now defaults to fetching manpages from manpages.debian.org. This is a
rewrite of dman from the debian-goodies package. debmany integration is still available.
- showsrc (-R option) now emulates --no-all-versions (show only the highest version unless
the -a switch is used).
updated why-pkg from v.0.11a to v.0.11b
- some improvements
===========================
note: there is currently a bug in Bash in testing and unstable that affects printf.
It is used in schow-pkg to detect the decimal separator in the current locale. Although it is not
used for actual calculation, it seriously affects the presentation of package sizes.
This is how it should work:
If you are using testing or unstable, temporarily add a line after line 1727 of schow-pkg after
favorite decimal separator:
- edge case fix
updated schow-pkg from v.5.1 to v.5.2
- new -B option: human readable “apt-listbugs”
- new -c option: retrieve package changelog
- new -P option: human readable “apt-cache policy”
- The -d option now defaults to fetching manpages from manpages.debian.org. This is a
rewrite of dman from the debian-goodies package. debmany integration is still available.
- showsrc (-R option) now emulates --no-all-versions (show only the highest version unless
the -a switch is used).
updated why-pkg from v.0.11a to v.0.11b
- some improvements
===========================
note: there is currently a bug in Bash in testing and unstable that affects printf.
It is used in schow-pkg to detect the decimal separator in the current locale. Although it is not
used for actual calculation, it seriously affects the presentation of package sizes.
This is how it should work:
Code: Select all
$> printf '%.1f'
0,0
$> DECSEP="$(LANG="fr_FR.utf8" printf '%.1f')"; echo "${DECSEP//0}"
,
$> DECSEP="$(LANG="en_US.utf8" printf '%.1f')"; echo "${DECSEP//0}"
.
DECSEP="$(printf '%.1f')"
with yourfavorite decimal separator:
DECSEP="."
Hopefully this bug will be fixed soon.Share your Debian SCRIPTS
There will be neither barrier nor walls, neither official nor guard, there will be no more desert and the entire world will become a garden. — Anacharsis Cloots
There will be neither barrier nor walls, neither official nor guard, there will be no more desert and the entire world will become a garden. — Anacharsis Cloots
Re: Share your Debian SCRIPTS
Apt-recent.
A small program to quickly view recent updates.
It shows if it was an ‘unattended-upgrade’, Install or a Command
Requested-By: user (nnnn). Includes start/end date & time.
Covers case where history file has just been cleared to history.log.n.gz
We have 2 identical laptops, either may be used 1 of 4 persons.
Sometimes if they are away a user will load a new kernel to get a game or
some other program to work. This then gets forgotten when the LT is
returned.
Have been using it since Debian 10.
Script saved to /usr/bin.
Run from Xfce Application finder, type an 'a' click on the highlight - it runs.
NOTE: user needs to be in the adm group.
Add .temp folder to users home directory.
---------
Edit change save location because of possible problem mentioned by CwF
A small program to quickly view recent updates.
It shows if it was an ‘unattended-upgrade’, Install or a Command
Requested-By: user (nnnn). Includes start/end date & time.
Covers case where history file has just been cleared to history.log.n.gz
We have 2 identical laptops, either may be used 1 of 4 persons.
Sometimes if they are away a user will load a new kernel to get a game or
some other program to work. This then gets forgotten when the LT is
returned.
Have been using it since Debian 10.
Script saved to /usr/bin.
Run from Xfce Application finder, type an 'a' click on the highlight - it runs.
NOTE: user needs to be in the adm group.
Add .temp folder to users home directory.
---------
Code: Select all
#!/bin/bash
# =====================================================================
# The following lines of code reads the Debian APT history log
# and reformats, what can be, very long single lines to extract
# Sub Headings and split remaining items to be on their own line.
# Thus making it much more readable. Also checks for empty log file and
# shows if recent changes were made by Update/Upgrade or a User
#
# Uses sed (stream editor) to transform text.
# see www.gnu.org/software/sed/manual/
#
# NOTE: user needs to be in the adm group.
# Add .temp folder to each users home directory.
# Put script in /usr/bin
# =====================================================================
# define Paths & files
PFa=~/.temp/hlog-tmp.txt
PFb=~/.temp/apt_history.txt
# Text $
Tstr=" File is empty, probably just gzipped. Run after next update."
#-------------------------------------------------------------------
# Read n (32) lines of log file & write out to new temp file.
tail -n 32 /var/log/apt/history.log > $PFa
# add # to 'tail' line start above & remove # from 'touch to create
# empty file for testing.
# touch ~/.temp/hlog-tmp.txt
# Put New Line after Upgrade, nstall (covers Install & Reinstall),
# Purge and Remove. Then add a New Line after every ")," found.
sed 's/Upgrade: /&\n/; s/nstall: /&\n/; s/Purge: /&\n/;
s/Remove: /&\n/; s/),/&\n/g' \
$PFa > $PFb # Copy modified temp file to final output file.
# Check for empty log, print $Tstr text if 0 bytes.
find $PFb -size 0c -exec echo "$Tstr" >> $PFb \;
# No further use for tmp file so delete it.
rm $PFa
# view latest log entries & let user save if required.
l3afpad $PFb
rm $PFb # Clean up
# Don't leave txt files around let user save.
# atp-recent
# save to /usr/bin
Last edited by Theuthr on 2024-11-11 13:12, edited 2 times in total.
-
- Global Moderator
- Posts: 3140
- Joined: 2018-06-20 15:16
- Location: Colorado
- Has thanked: 63 times
- Been thanked: 268 times
Re: Share your Debian SCRIPTS
Note when using /usr/local/bin, users in the group ‘staff’ can create and mark executable the script directly to be shared by all users.
Mottainai
Re: Share your Debian SCRIPTS
@CwF
There is an even worse problem with /user/local/bin.
In the Debian Wiki under “Groups without an associated user”;-
“(note that executables in /usr/local/bin are in the PATH variable of any user, and they may "override" the executables in /bin and /usr/bin with the same name)
So a user could create serious problems by an accidental naming clash.
As a result I have edited the post to save the script in /usr/bin, (and moved it there )
I was considering deleting the Group ‘staff’ as we don’t use it and there are no users in the group.
However, I have yet to find out how to be sure that no files are linked to ‘staff’.
With Linux, the day one stops learning about it one has probably died!
Many thanks CwF for pointing that out.Note when using /usr/local/bin, users in the group ‘staff’ can create and mark executable the script directly to be shared by all users.]
There is an even worse problem with /user/local/bin.
In the Debian Wiki under “Groups without an associated user”;-
“(note that executables in /usr/local/bin are in the PATH variable of any user, and they may "override" the executables in /bin and /usr/bin with the same name)
So a user could create serious problems by an accidental naming clash.
As a result I have edited the post to save the script in /usr/bin, (and moved it there )
I was considering deleting the Group ‘staff’ as we don’t use it and there are no users in the group.
However, I have yet to find out how to be sure that no files are linked to ‘staff’.
With Linux, the day one stops learning about it one has probably died!
-
- Global Moderator
- Posts: 3140
- Joined: 2018-06-20 15:16
- Location: Colorado
- Has thanked: 63 times
- Been thanked: 268 times
Re: Share your Debian SCRIPTS
None. Staff is the group for /usr/local/bin/. Files created within are owned by the creator.Theuthr wrote: 2024-11-11 12:49 However, I have yet to find out how to be sure that no files are linked to ‘staff’.
Don't delete the group.
I'm in a minority I'm sure, but I use staff, and also use the group to substitute sudo via polkit. 'staff' could be considered the debianized 'wheel' group. It all fits together to minimize a users need for root and permission jacking.
Mottainai