bbqsystool
Forum rules
Your own work only.
Your own work only.
-
- Baconator
- Posts: 10253
- Joined: Thu Sep 16, 2010 11:03 am
- Location: Pfälzerwald
- Contact:
Re: Software Development wish list.
Me again :nerve: - the forth screen doesn't clear previous messages, is this on purpose?
..gnutella..
Re: Software Development wish list.
uhhhhhhh.....
..........
..............
..
fixing that now. ;)
Edit: Okay, pushed a hotfix for that and will add correct version of ncurses note to README.
Edit2: Continue to ::nerve:: me, as this is one of the few things that you can generally assume it's something that I've missed up until I can prove otherwise.
..........
..............
..
fixing that now. ;)
Edit: Okay, pushed a hotfix for that and will add correct version of ncurses note to README.
Edit2: Continue to ::nerve:: me, as this is one of the few things that you can generally assume it's something that I've missed up until I can prove otherwise.
-
- Baconator
- Posts: 10253
- Joined: Thu Sep 16, 2010 11:03 am
- Location: Pfälzerwald
- Contact:
-
- Baconator
- Posts: 10253
- Joined: Thu Sep 16, 2010 11:03 am
- Location: Pfälzerwald
- Contact:
Re: bbqsystool
Thanks Joe, all neat.
I'd like to suggest two more points for the menu:
- enable/disable DPMS and/or blanking (in an X environment this could be done with xset -dpms && xset -s off for disabling the screensaver), I guess in TTY we need to use setterm and/or vbetool on/off
- some quicklinks to free -h and htop and stuff, to have them all under one cover
I'd like to suggest two more points for the menu:
- enable/disable DPMS and/or blanking (in an X environment this could be done with xset -dpms && xset -s off for disabling the screensaver), I guess in TTY we need to use setterm and/or vbetool on/off
- some quicklinks to free -h and htop and stuff, to have them all under one cover
..gnutella..
Re: bbqsystool
^^Will do that, with the assumption that those things will be installed.
The 3rd option is the one that I'm really contemplating, as I plan to simply walk the user through options that will hopefully lead to enlightenment about adjusting everything from the shell. It's one thing to give the user a fish, but I want to let the tool TEACH.
So, I want to have it scripted so that kernel modules can be loaded via bash, max/min settings adjusted, and attempt to override BIOS settings, and when the user is done...they type in exit and return to the script's run-level. I've got that part figured out. So, then the question is what all should I include here?
Things on the list:
foobar.ko loading/unloading instructions.
command to set (in MHz and GHz) Max. threshold.
command to set (in MHz and GHz) Min. threshold.
how to read the current threshold for stepping though frequencies.
how to set the threshold to step up or down in frequencies.
...and a minor set of instructions to see if the user can override BIOS options for processor parameters.
Anything else you can think of?
The 3rd option is the one that I'm really contemplating, as I plan to simply walk the user through options that will hopefully lead to enlightenment about adjusting everything from the shell. It's one thing to give the user a fish, but I want to let the tool TEACH.
So, I want to have it scripted so that kernel modules can be loaded via bash, max/min settings adjusted, and attempt to override BIOS settings, and when the user is done...they type in exit and return to the script's run-level. I've got that part figured out. So, then the question is what all should I include here?
Things on the list:
foobar.ko loading/unloading instructions.
command to set (in MHz and GHz) Max. threshold.
command to set (in MHz and GHz) Min. threshold.
how to read the current threshold for stepping though frequencies.
how to set the threshold to step up or down in frequencies.
...and a minor set of instructions to see if the user can override BIOS options for processor parameters.
Anything else you can think of?
-
- Baconator
- Posts: 10253
- Joined: Thu Sep 16, 2010 11:03 am
- Location: Pfälzerwald
- Contact:
Re: bbqsystool
htop is installed, and I think top is even a standard in netinstall. vbetools, setterm are there too, xset comes via x11 tools.
I like the modprobe/rmmod stuff, not bad.
What about
- a kernel remover (siduction's kernel-remover does it, but the user should be able to manually remove unused kernels)
- read CPU info (grep flags /proc/cpuinfo -> lm yields 64bit, Protected Mode is 32bit, real mode 16bit)
- display vmstat (-m for slabinfo etc)
- pmap according to a PID (could be grep'ed via ps -A and/or via lsof)
- print all /proc/*info and /proc/mounts into a file
just leaving ideas here, maybe you can bake something useful from it
I like the modprobe/rmmod stuff, not bad.
What about
- a kernel remover (siduction's kernel-remover does it, but the user should be able to manually remove unused kernels)
- read CPU info (grep flags /proc/cpuinfo -> lm yields 64bit, Protected Mode is 32bit, real mode 16bit)
- display vmstat (-m for slabinfo etc)
- pmap according to a PID (could be grep'ed via ps -A and/or via lsof)
- print all /proc/*info and /proc/mounts into a file
just leaving ideas here, maybe you can bake something useful from it
..gnutella..
Re: bbqsystool
I'll work on at least the Basics of the Verbose Mode for now, and I REALLY like the shift from it being automatically scripted to allow the user to do whatever they want from bash, to reinserting them into scripted mode. I want to allow a very extreme set of variable to be set, and for it to be exactly what they'd need to do from a regular shell. Rather than do it for the user, simply making a teaching tool could really benefit people who aren't used to doing everything manually to learn how...it just feels 'right'. Once I get it to a point where I'm happy with at least how it flows, I'll push it for playing with.
Beyond that, I've got the tool dropping to bash for every prompt which requires them to use 'exit' to return to the script. Should I create a quick bypass for each section?
Beyond that, I've got the tool dropping to bash for every prompt which requires them to use 'exit' to return to the script. Should I create a quick bypass for each section?
-
- Baconator
- Posts: 10253
- Joined: Thu Sep 16, 2010 11:03 am
- Location: Pfälzerwald
- Contact:
Re: bbqsystool
Just pushed changes that show how I mean to use the "Tutor mode".
I'm considering rather than tell the user that you could possible "Create a file", that I simply append the commands to do so without an external editor, by simply using "touch" and "echo >". It seems that if they want to use another method, that's cool...but why not cover how to do it without opening any external tools?
Feel free to check it out and provide formatting and artistic suggestions. It's not done, but I'm tired of of vim for a minute. ;)
I'm considering rather than tell the user that you could possible "Create a file", that I simply append the commands to do so without an external editor, by simply using "touch" and "echo >". It seems that if they want to use another method, that's cool...but why not cover how to do it without opening any external tools?
Feel free to check it out and provide formatting and artistic suggestions. It's not done, but I'm tired of of vim for a minute. ;)
Re: bbqsystool
Okay, for the non-insane testing crew...I'm pretty comfortable with this release now. I'm not saying that it can't bork your system, but I'm 99% sure that if you do...it's your own fault, and there are warnings in place (in RED even) about the potential destructive capacities of doing things such as ignoring BIOS throttling.
As such, I pushed up a version with an included make file. Now, you can just pull the directory through git...or pull and unpack the zip. Then, navigate to the new "bbqsystool" directory, and:
Launch the program with
Please read the above posts regarding the version of libncurses needed to keep the program from crashing out and jacking up your terminal formatting. Enjoy, and report back with suggestions or errors.
...about to add a "make uninstall" option to remove the binary from /usr/bin/.
As such, I pushed up a version with an included make file. Now, you can just pull the directory through git...or pull and unpack the zip. Then, navigate to the new "bbqsystool" directory, and:
Code: Select all
make
sudo make install
Code: Select all
$ sudo bbqsystem
...about to add a "make uninstall" option to remove the binary from /usr/bin/.
Re: bbqsystool
Quick question:
I've got the Kernel checks under "Tutor Mode" right now, and I'm suggesting removing them manually or with apt. I'm looking at how it is possible to remove ALL unused kernels with a single line in bash. Would one of you bash/awk/sed pros be willing to offer the way that you think is best to accomplish this? I'm okay with automating it, but there is glorious wonder in having the user do it manually in one clean line.
I've got the Kernel checks under "Tutor Mode" right now, and I'm suggesting removing them manually or with apt. I'm looking at how it is possible to remove ALL unused kernels with a single line in bash. Would one of you bash/awk/sed pros be willing to offer the way that you think is best to accomplish this? I'm okay with automating it, but there is glorious wonder in having the user do it manually in one clean line.
Re: bbqsystool
Something like this, perhaps? I don't know if this is "best" -- xaos may have an opinion on that.
http://www.unixmen.com/remove-all-unuse ... d-systems/
It is possible to include the first "egrep" as part of the awk expression, so this also appears to work:
Please test the dpkg -l call (everything inside the $( ) ) on your system; it appears to work on both of the systems I tested here. It's probably also possible to add the ending "grep" to the awk but I don't know how to do that yet.
Just don't use the monstrosity on this page: http://markmcb.com/2013/02/04/cleanup-u ... in-ubuntu/
http://www.unixmen.com/remove-all-unuse ... d-systems/
It is possible to include the first "egrep" as part of the awk expression, so this also appears to work:
Code: Select all
sudo apt-get remove $(dpkg -l|awk '/^ii linux-(im|he)/{print $2}'|grep -v $(uname -r))
Just don't use the monstrosity on this page: http://markmcb.com/2013/02/04/cleanup-u ... in-ubuntu/
Re: bbqsystool
dpkg -l|awk '/^ii linux-(im|he)/{print $2}'|grep -v $(uname -r) comes back with both headers and image as you have said.
I'll make sure that it works across a few different builds, but I do really appreciate the input. If there is no better way offered, I'll add this line into tutor mode.
Thank you.
I'll make sure that it works across a few different builds, but I do really appreciate the input. If there is no better way offered, I'll add this line into tutor mode.
Thank you.
Re: bbqsystool
You're welcome. I can't tell in the line you posted, but there should be two spaces between the "ii" and "linux" (but if it's working for you there must be) :)
Re: bbqsystool
Comparing versions is tricky, what with rc versions etc...
Use Debiantools to do the compare.
This seems to work
OK. This returns the most recent kernel on the system, and it is not exactly one line, is it.
Your solution is better if you are sure you want to remove all installed kernels except the one that you are booted into now - which is not necessarily the most recent one.
should give images only.
Use Debiantools to do the compare.
This seems to work
Code: Select all
#!/bin/bash
declare -a VERSIONS
VERSIONS=( $(ls -1 /mnt/sid/lib/modules) )
echo $VERSIONS
# Use dpkg --compare-versions to ... compare VERSIONS
RESULT=1.0
for VERSION in "${VERSIONS[@]}"; do
if $(dpkg --compare-versions "$VERSION" gt "$RESULT"); then
RESULT="$VERSION"
fi
done
echo $RESULT
Your solution is better if you are sure you want to remove all installed kernels except the one that you are booted into now - which is not necessarily the most recent one.
Code: Select all
dpkg -l|awk '/^ii linux-im/{print $2}'|grep -v $(uname -r)
Connected. Take this REPL, brother, and may it serve you well.
Re: bbqsystool
You guys are far more talented at this particular part than I am. Keep in mind, this part of the program assumes that the user is going to manually enter in what is to be done. So, if we'd like to leave it up to them to double-check that the image/headers they wish to remove are the ones listed, then that's fine.
Even with a proper listing, I'd be likely to double-check output and then remove each item one at a time...but I'm paranoid of automation. ;)
Edit: My mistake...I just realized the difference between what Pids had posted and what you did Xaos. I was under the impression that you were saying that the original would not include headers, but missed out on the difference.
2nd edit: I did push these additions to the development repo. I understand that there might be some issues with getting the correct versions with oddly named kernels. Still, with the option to bail out left up to the user, I see no issues that couldn't be prevented by reading a little. A special thanks again to the both of you for your assistance has been added to the README. I can do it automagically in C, but I don't write bash very well at all.
Even with a proper listing, I'd be likely to double-check output and then remove each item one at a time...but I'm paranoid of automation. ;)
Edit: My mistake...I just realized the difference between what Pids had posted and what you did Xaos. I was under the impression that you were saying that the original would not include headers, but missed out on the difference.
2nd edit: I did push these additions to the development repo. I understand that there might be some issues with getting the correct versions with oddly named kernels. Still, with the option to bail out left up to the user, I see no issues that couldn't be prevented by reading a little. A special thanks again to the both of you for your assistance has been added to the README. I can do it automagically in C, but I don't write bash very well at all.
-
- Baconator
- Posts: 10253
- Joined: Thu Sep 16, 2010 11:03 am
- Location: Pfälzerwald
- Contact:
Re: bbqsystool
FYI the kernel remover tool does something with sed for /boot/vmlinuz-* (check the get_KernelList function)
Code: Select all
#!/bin/sh
#
# we need gettext (is loaded in ssft.sh or cloned...)
if [ -f /usr/bin/gettext.sh ]; then
. /usr/bin/gettext.sh || exit 1
else
exit 1
fi
#---------------------------------------------------------------------
# we need root rights
#---------------------------------------------------------------------
if [ "$(id -u)" -ne 0 ]; then
if [ -x "$(which su-to-root)" ]; then
[ -n "$DISPLAY" ] && exec su-to-root -X -c "${0} $@"
exec su-to-root -c "${0} $@"
fi
printf "ERROR: $0 needs root capabilities, please start it as root.\n\n" >&2
exit 1
else
if test -n "$DISPLAY" && ! xset q > /dev/null 2>&1 ; then unset DISPLAY; fi
fi
TEXTDOMAIN="kernel-remover"
export TEXTDOMAIN
TEXTDOMAINDIR=/usr/share/locale
export TEXTDOMAINDIR
#---------------------------------------------------------------------
usage()
{
echo "$(basename $0)"
echo " -F parameter use parameter as the graphical frontend"
echo " one of text | dialog | kdialog | zenity "
echo " -f proceed without asking, do complete cleanup"
echo " -h show this usage"
exit 1
}
#---------------------------------------------------------------------
force=0
xtra=0
unset frontend
while getopts fhxF: name
do
case $name in
f) force=1;;
F) frontend="$OPTARG";;
h) usage;;
x) xtra=1;;
*) usage;;
esac
done
shift $(($OPTIND - 1))
#---------------------------------------------------------------------
prepare()
{
if [ "$force" -eq 0 ]; then
# we need ssft
if [ -f /usr/bin/ssft.sh ]; then
. /usr/bin/ssft.sh || exit 1
else
echo "Please install the package \"ssft\"."
exit 1
fi
fi
if [ -n "${frontend}" ]; then
case $frontend in
text) SSFT_FRONTEND="${frontend}";;
dialog) SSFT_FRONTEND="${frontend}";;
kdialog) SSFT_FRONTEND="${frontend}";;
zenity) SSFT_FRONTEND="${frontend}";;
*) echo unknown frontend && exit 1;;
esac
fi
if [ -z "$DISPLAY" ] && ! /usr/bin/xdpyinfo >/dev/null 2>&1 ; then
unset DISPLAY
fi
if [ -z "$DISPLAY" ]; then
[ -x /usr/bin/dialog ] && SSFT_FRONTEND=${SSFT_FRONTEND:-"dialog"} || \
SSFT_FRONTEND=${SSFT_FRONTEND:-"text"}
else
if [ -n "$DISPLAY" ] && [ ! -x /usr/bin/zenity ]; then
if [ -x /usr/bin/dialog ]; then
SSFT_FRONTEND="dialog"
else
SSFT_FRONTEND="text"
fi
DISPLAY=""
else
SSFT_FRONTEND=${SSFT_FRONTEND:-"zenity"}
fi
fi
# the current one will not be shown in the list ....
ACTUAL=$(uname -r)
TITLE="$(gettext "Removing installed kernels")"
PAD="======="
[ "${SSFT_FRONTEND}" = "dialog" -o -z "${SSFT_FRONTEND}" ] && \
CURRENT="$(eval_gettext "The actual (active) kernel is ${PAD}$(uname -r)${PAD}")
CURRENT="$(eval_gettext "The actual (active) kernel is $(uname -r)")"
}
#---------------------------------------------------------------------
# some useful functions
#---------------------------------------------------------------------
inputbox()
{
# inputbox Title Text dummy default
Title="$1"
Text="$2"
# $3 not used
# The default value if used
SSFT_DEFAULT=$4
ssft_read_string "${Title}" "${Text}";
}
#---------------------------------------------------------------------
msgbox()
{
# msgbox title text
Title="$1"
Text="$2"
ssft_display_message "${Title}" "${Text}"
}
#---------------------------------------------------------------------
select_more()
{
# select one of a list
Title=$1
Text=$2
shift 2
if ssft_select_multiple "$Title" "$Text" $@ ; then
Selected=$SSFT_RESULT
return 0
else
return 1
fi
}
#---------------------------------------------------------------------
yesno()
{
# yesno title text width
Title=$1
Text=$2
ssft_yesno "${Title}" "${Text}"
return $?
}
#---------------------------------------------------------------------
remove_one_kernel()
{
Kernel=$1
if [ "${Kernel}" != "${ACTUAL}" ]; then
apt-get remove --purge --yes $(dpkg -l | awk "/${Kernel}/{print \$2}")
dpkg -l "linux-headers-${Kernel}-common" >/dev/null 2>&1 && \
apt-get remove --purge --yes "linux-headers-${Kernel}-common"
dpkg -l "linux-support-${Kernel}" >/dev/null 2>&1 && \
apt-get remove --purge --yes "linux-support-${Kernel}"
# dispose make install artefacts
if [ ! -e "/boot/vmlinuz-${Kernel}" ]; then
rm -rf /lib/modules/${Kernel}
fi
else
# do not remove active kernel
:
fi
}
#---------------------------------------------------------------------
get_KernelList()
{
for v in /boot/vmlinuz-*; do
Kernel="$(basename $v | sed s/vmlinuz-//)"
if [ "${Kernel}" != "${ACTUAL}" ]; then
meta_package="$(echo $(grep-available \
-F Depends linux-image-${Kernel} \
-s Package) | cut -d: -f 2)"
case $meta_package in
*$Kernel* ) # this is an old style kernel
KernelList="${KernelList} ${Kernel}"
continue
;;
esac
[ -n "${meta_package}" ] && \
meta_status="$(dpkg-query -f='${STATUS}\n' \
-W ${meta_package}|\
cut -d ' ' -f 3)" || \
meta_status="not-installed"
if [ "${meta_status}" = "not-installed" ]; then
[ -z "${KernelList}" ] && KernelList="${Kernel}" ||\
KernelList="${KernelList} ${Kernel}"
# echo KernelList="$KernelList"
else
:
fi
fi
done
}
#---------------------------------------------------------------------
# Main
#---------------------------------------------------------------------
if [ "${xtra}" -eq 1 ]; then
KernelList="$@"
for i in ${KernelList} ; do
removing="$(eval_gettext "removing kernel ${i}")"
echo $removing
remove_one_kernel "$i"
done
MSG="$(eval_gettext "the following kernels have been removed: \"${KernelList}\"")
echo $MSG
exit 0
fi
prepare
get_KernelList
if [ -z "${KernelList}" ]; then
MSG="$(gettext "There is only one kernel installed on this system. Nothing to
if [ "${force}" -eq 1 ]; then
echo "${MSG}"
else
msgbox "${TITLE}" "${MSG}"
fi
exit 0
fi
if [ "${force}" -eq 1 ]; then
current="$(eval_gettext "The actual (active) kernel is $(uname -r)")"
echo ${current}
for i in ${KernelList} ; do
removing="$(eval_gettext "removing kernel ${i}")"
echo $removing
remove_one_kernel "$i"
done
MSG="$(eval_gettext "the following kernels have been removed: \"${KernelList}
echo $MSG
else
select_more "${TITLE}" "${CURRENT}" ${KernelList}
if [ "$?" -ne 0 ]; then
exit 10
fi
if [ -z "${SSFT_RESULT}" ]; then
exit 12
fi
one_removed=false
for i in ${SSFT_RESULT}; do
MSG="$i : $(gettext "Should I remove this kernel?") "
yesno "${TITLE}" "${MSG}"
if [ "$?" -eq 0 ]; then
remove_one_kernel "$i"
one_removed=true
else
msgbox "${TiTLE}" "$(gettext "Kernel not removed:") $i"
fi
done
fi
exit 0
..gnutella..
Re: bbqsystool
If you - DebianJoe - want to use the same logic as kernel-remover, use this help script based on the above script:
To exclude the current running kernel, run
Code: Select all
#!/bin/sh
get_KernelList()
{
for v in /boot/vmlinuz-*; do
Kernel="$(basename $v | sed s/vmlinuz-//)"
if [ "${Kernel}" != "${ACTUAL}" ]; then
meta_package="$(echo $(grep-available \
-F Depends linux-image-${Kernel} \
-s Package) | cut -d: -f 2)"
case $meta_package in
*$Kernel* ) # this is an old style kernel
KernelList="${KernelList} ${Kernel}"
continue
;;
esac
[ -n "${meta_package}" ] && \
meta_status="$(dpkg-query -f='${STATUS}\n' \
-W ${meta_package}|\
cut -d ' ' -f 3)" || \
meta_status="not-installed"
if [ "${meta_status}" = "not-installed" ]; then
[ -z "${KernelList}" ] && KernelList="${Kernel}" ||\
KernelList="${KernelList} ${Kernel}"
# echo KernelList="$KernelList"
else
:
fi
fi
done
}
get_KernelList
for kernel in $KernelList; do
echo $kernel
done
Code: Select all
sh help_script | grep -v $(uname -r)
Connected. Take this REPL, brother, and may it serve you well.
Re: bbqsystool
Edit: NVM, learning bash speak. ;)
Okay, so by | grep'n against vmlinuz, we're able to handle kernel options that are distro agnostic, correct?
So, under testing...notice the difference in the results from the Pidsley method "which does list all kernels, but also the included headers for the current one", and the Xaos script, which when executed raw gives ONLY the current kernel...and when piped through grep, returns nothing.
I included the actual contents of /boot/ for evidence on what's actually there.
Okay, so by | grep'n against vmlinuz, we're able to handle kernel options that are distro agnostic, correct?
So, under testing...notice the difference in the results from the Pidsley method "which does list all kernels, but also the included headers for the current one", and the Xaos script, which when executed raw gives ONLY the current kernel...and when piped through grep, returns nothing.
I included the actual contents of /boot/ for evidence on what's actually there.
Re: bbqsystool
What is the desired behavior? To list all kernels and headers except the installed kernel and headers?
What is the output of "uname -r" on the system where you are testing?
What is the output of "uname -r" on the system where you are testing?