I have been wanting to make this setup for many years (sob), but always there were obstacles in my way.
Sometimes it were laziness
or I just had no free time for it.
But recently , one of my
colleagues showed me his setup of media streaming box, and I was hooked on this
idea again.
So here goes specs :
Old „HP VECTRA” case.
Intel E5300 CPU
MB ASUS P5LD2-VM
1Gb RAM
250Gb HDD
200W original „HP VECTRA”
PSU
Wifi stick A-Link WL54USB
Technically speaking , it’s
a junk-box. But in the end, this junk-box uses 37W of power (Yayy!).
It’s around + 4 Eur to
electricity bill per month.
Comparing to VPS hosting, I’m
getting better stuff, for less money.
As OS I used Ubuntu 13.10
LAMP.Why? Because Debian systems seems easier to me.
I won’t show all Ubuntu server install process, that
would be lame..
OK. System is installed, all
is fine.
We will need SSH for further
work with system.
sudo apt-get install openssh-server
Now we need to configure
connection to WiFi AP. Obviously (dooh) it won’t connect by itself.
There’s no way to enter
password for AP in a regular GUI way.
After pluging in a WiFi
stick , we need to check, if it’s recognized by system.
janis@box:~$ lsusb
Bus 001 Device 002: ID 0ace:1215 ZyDAS ZD1211B 802.11g
Device is connected and can
be configured.
Further we need to :
- Disable eth0 , or LAN. I even disabled it in BIOS, so it won’t be
using extra power.
- Configure wlan0 to connect to AP and send DHCP request on system startup.
To disable eth0 :
sudo nano /etc/network/interfaces
In config file uncomment or
remove all config lines about eth0.
My config is like that :
# The loopback network interface
auto lo
iface lo inet loopback
# wlan0 connection.
ifconfig wlan0 up
iwlist wlan0 scan
iwconfig wlan0 essid Policija
iwconfig wlan0 rate 54M
iwconfig wlan0 rate 54M
dhclient wlan0
As you may noticed , I have no
Secret key or AP password.That’s because I have set up on my router allowed MAC
address list.
Further we test if wlan0 is
turned on after restart.
sudo shutdown -r now
Here I ran into a problem.
My PC just turned off, instead or restarting.
After some digging I found ,
that It may be a problem with Intel drivers.
This is specific to my
motherboard and a few others (Ohh lucky me..).
sudo nano /etc/modprobe.d/blacklist.conf
Add at the end of config :
#This sh** Make system reboot
blacklist mei
Now everything was fine, my
box did reboot fine and was connecting to AP on startup.
Also I installed sensors, so
I can get information about CPU temps etc..
sudo apt-get install lm-sensors
sudo sensors-detect
sensors
! You can run watch sensors to see temperature values updating
each second
! Or just watch temperature
sensors sensors | grep °C
There is also a need to
check HDD temp sometimes.
sudo apt-get install hddtemp
sudo hddtemp /dev/sda
To display all usable
information on SSH login banner :
cd /etc/cron.hourly
sudo nano system_stats
Copy in a following code and save (or write your own) :
!/bin/bash
CPUTIME=$(ps
-eo pcpu | awk 'NR>1' | awk '{tot=tot+$1} END {print tot}')
CPUCORES=$(cat
/proc/cpuinfo | grep -c processor)
echo "
System
Summary (collected `date`)
- CPU Usage (average) = `echo $CPUTIME / $CPUCORES | bc`%
- Memory free (real) = `free -m | head -n 2 | tail -n 1 | awk
{'print $4'}` Mb
- Memory free (cache) = `free -m | head -n 3 | tail -n 1 | awk
{'print $3'}` Mb
- Swap in use = `free -m | tail -n 1 | awk {'print $3'}` Mb
- System Uptime = `uptime`
- Public IP = `dig +short myip.opendns.com
@resolver1.opendns.com`
- Local IP
= `ifconfig wlan0 | grep 'inet addr:' | cut
-d: -f2 | awk '{ print $1}'`
- Disk Space Used = `df / | awk '{ a = $4 } END { print a
}'`
- CPU Temperature =
`sensors | grep 'Core 0' | awk -F: ' { print $2 } '| cut -c8-10`
" >
/etc/motd
Set up a cronjob :
Run cronjob:
run-parts /etc/cron.hourly
To test
configuration :
ssh localhost
Output :
System
Summary (collected Sat Feb 15 20:29:03 EET 2014)
- CPU Usage (average) = 0%
- Memory free (real) = 814 Mb
- Memory free (cache) = 34 Mb
- Swap in use = 0 Mb
- System Uptime =
20:29:03 up 3:33, 1 user,
load average: 0.00, 0.01, 0.05
- Public IP = xx.xx.xx.xx
- Local IP = 192.168.1.4
- Disk Space Used =
226056860
- CPU Temperature =
+41
Last login:
Sat Feb 15 20:18:55 2014 from localhost
! Just for info about grep usage:
The grep
'Core 0' command searches for a pattern matching "Core 0" and prints
the whole
line.
Core 0: +41.0°C
(high = +100.0°C, crit = +100.0°C)
Then it's
piped ("|") to awk '{print $3}' which prints the third grouping.
(Continuous
characters without a space)
Core 0: +41.0°C
(high = +100.0°C, crit = +100.0°C)
--1---2---------3-------4--5-----6--------7--8------9
+41.0°C
Links :
https://help.ubuntu.com/10.04/serverguide/network-configuration.html
0 comments :
Post a Comment
Comment: