#!/bin/bash # This creates the conky config file (/etc/conky/conky.conf) based on the hardware of this system. # Being a liveCD we can't assume much about the hardware, so we need to create the # config file on the fly (pun not intended) # Author: Sid (Modified by Pilot) # Contact: sid@criticalsecurity.net # Date: 10/dec/08 # Version 0.0.8 # This is my first ever seious bash script, go easy on me # BUGS: # #1: A mount point will fail to show of the device name is very long and the ouput spans lines (eg a LUKS mapper path is used) # First off we check we're allowed to run what we need to run if ! `ifconfig &> /dev/null`; then echo "We're having issues with running ifconfig commands, try running again as root " exit fi interfaces=`ifconfig -a | grep "Link encap:" | grep -v "lo" | awk '{print $1}'` battery=`ls -1 /proc/acpi/battery/` hive=`/etc/init.d/HiveMind status | grep status | awk '{print $3}'` config='background no\n' config+='default_color '$conky1'\n' config+='draw_shades no\n' config+='cpu_avg_samples 2\n' config+='net_avg_samples 2\n' config+='update_interval 1\n' config+='double_buffer yes\n' config+='stippled_borders 10\n' config+='border_margin 4\n' config+='border_width 1\n' config+='gap_x 4\n' config+='gap_y 50\n' config+='alignment bottom_right\n' config+='no_buffers yes\n' config+='maximum_width 230\n' config+='own_window yes\n' config+='own_window_type desktop\n' config+='\n' config+='TEXT\n' config+='${time %A %B %d %Y %T}\n' config+='Uptime:${color '$conky2'} $uptime$color\n' config+='Load:${color '$conky2'} $loadavg$color\n' config+='Entropy:${color '$conky2'} $entropy_avail/$entropy_poolsize $entropy_bar$color\n' if [ ! "`acpi -b`" = '' ]; then config+='Battery:${color '$conky2'}$alignr$battery ${color red}$battery_time$color\n' config+='AC:${color '$conky2'}$alignr$acpiacadapter$color\n' for i in $battery; do config+="Remaining:\${color $conky2}\$alignr\${exec egrep -o '[[:digit:]]+ mAh' /proc/acpi/battery/$i/state}\$color\n" config+="Last full:\${color $conky2}\$alignr\${exec egrep -o '[[:digit:]]+ mAh' /proc/acpi/battery/$i/info | tail --lines=+2 | head -n 1}\$color\n" done config+='Temp:${color '$conky2'}$alignr$acpitemp C$color\n' fi config+='$stippled_hr\n' config+='CPU Speed:${color '$conky2'}$alignr$freq_g Ghz$color\n' config+='CPU Usage:${color '$conky2'} ${cpu}% ${cpubar}$color\n' config+='RAM Usage:${color '$conky2'} $mem/$memmax - $memperc%\n' config+='$membar$color\n' config+='File systems:\n' config+='${execp /etc/conky/df}\n' config+='$color Disk I/O:${color '$conky2'} $diskio\n' config+='${color}Processes:${color '$conky2'} $processes$color Running:${color '$conky2'} $running_processes\n' config+='$color$hr\n' config+='HiveMind:${color #4010D0}$alignr${if_running HiveMind}${color green}started${else}${color red}stopped${endif}\n' config+='${color}Tor/Privoxy:${color #4010D0}$alignr${if_running tor}${color green}started${else}${color red}stopped${endif}\n' config+='${color}VNCserver:${color #4010D0}$alignr${if_running Xvnc}${color green}started${else}${color red}stopped${endif}\n' config+='${color}SSHd:${color #4010D0}$alignr${if_running sshd}${color green}started${else}${color red}stopped${endif}\n' config+='$color$hr\n' #if [ "$hive" = "started" ]; then # config+='\n' # config+='$color$hr\n' #fi config+='Networking\n' config+=' Public IP: ${color '$conky2'}${if_gw}${execp /etc/conky/whatsmyip}${else}No Address${endif}\n' config+=' ${color}Router IP: ${color '$conky2'}${if_gw}$gw_ip${else}No Address${endif}\n' for i in $interfaces; do config+="\${color}$i: \${color $conky2}\${addr $i}\$color\n" config+=" Down:\${color $conky2} \${downspeed $i} k/s\$color \${offset 60}Up:\${color $conky2} \${upspeed $i} k/s\n" done config+='$color$stippled_hr\n' config+='CPU Usage:${color '$conky2'}\n' config+=' ${top name 1} ${top pid 1} ${top cpu 1}$color\n' config+=' ${top name 2} ${top pid 2} ${top cpu 2}\n' config+=' ${top name 3} ${top pid 3} ${top cpu 3}\n' config+='Mem usage:${color '$conky2'}\n' config+=' ${top_mem name 1} ${top_mem pid 1} ${top_mem mem 1}$color\n' config+=' ${top_mem name 2} ${top_mem pid 2} ${top_mem mem 2}\n' config+=' ${top_mem name 3} ${top_mem pid 3} ${top_mem mem 3}\n' echo -e $config > /etc/conky/conky.conf