- All scripts are again `sh` compatible. - Binbox overhaul, symlinks finally work just like `busybox`. - Error checking to some files like `sw` and `own`. TODO: Make it pretty and make `short` already.
41 lines
830 B
Bash
Executable file
41 lines
830 B
Bash
Executable file
#!/bin/sh
|
|
# Calm a process down
|
|
# NEEDS_WORK: cleanup
|
|
# calm <pid> == only one process
|
|
# calm <bin> == all processes that match query
|
|
# calm * == if used in proc or a folder with just PID files, if not you will get an error
|
|
# calm <pid> <bin> .... OK
|
|
# set's NICE value to 0
|
|
# need sudo
|
|
|
|
DAISY_INTERNAL=1
|
|
. $(dirname $(realpath $0))/daisy.source
|
|
|
|
PIDS=$@
|
|
|
|
errorFn()
|
|
{
|
|
echo calm: Invalid operation or no such PID/process \(\"$(echo "$PIDS" | tr '\n' ' ' | cut -c -20)...\"\)
|
|
exit
|
|
}
|
|
|
|
for pid in $PIDS
|
|
do
|
|
# Process to PID in elegant way
|
|
NEWPIDS=$(pidof "$pid")
|
|
if [ "$NEWPIDS" ]
|
|
then
|
|
BINNY=$pid
|
|
pid=$NEWPIDS
|
|
else
|
|
NEWBINS=$pid
|
|
BINNY=$(ps -p "$pid" -o comm= 2>/dev/null )
|
|
if [ $? != 0 ]
|
|
then
|
|
errorFn
|
|
fi
|
|
fi
|
|
|
|
echo Calming down $pid \("$BINNY"\)...
|
|
sudo renice -n 0 -p $pid;
|
|
done
|