Powered by Arch ARM, Apache, PHP, cgminer and MinePeon.
Write Arch Linux ARM to SD and use it to boot your rpi.
- Login over ssh with root/root and update the system with
pacman -Syu
- (Optional) Change your hostname with
echo minepeon > /etc/hostname
- (Optional) Set the correct timezone with
tzselect
or set it directly withTZ='UTC'; export TZ
- Replace
UTC
by your timezone identifier, e.g.Europe/Brussels
.
- Replace
- (Optional) setting to avoid permission problems
umask 0
- Time to
shutdown -r now
I happen to prefer nano over vi, this makes nano
the default editor for visudo
and crontab
export VISUAL=nano EDITOR=nano
Add a user that will get just enough permissions to manage everything.
useradd minepeon
passwd minepeon peon
gpasswd -a minepeon http
mkdir /opt/minepeon
chmod 770 /opt/minepeon
chown minepeon.http /opt/minepeon
Because this system is dedicated to one purpose, it's handy to set the home directory to /opt/minepeon. That's where the magic will happen.
nano /etc/passwd
Find the line that starts with minepeon and change the directory to:
minepeon:x:1000:1000::/opt/minepeon:/bin/bash
Install sudo and edit the sudoers file. The second command sets nano as editor, if you want to use vi, skip that command.
pacman -S sudo
export EDITOR=nano
visudo
Find this section and allow user minepeon to use sudo
##
## User privilege specification
##
root ALL=(ALL) ALL
## Uncomment to allow minepeon to execute any command
minepeon ALL=(ALL) ALL
## Same thing without a password
minepeon ALL=(ALL) NOPASSWD: /usr/bin/shutdown,/usr/bin/systemctl
Make sure user minepeon is now able to login and use sudo. Then lock the root account.
- Login as minepeon:
su minepeon
- Check if sudo works:
sudo date
- Disable root:
sudo passwd -l root
- Reboot
sudo shutdown -r now
. - Login as minepeon, notice ssh comes available 15 seconds after all LEDs except the red one went out.
Install the "LAP"-stack
sudo pacman -S apache php php-apache git zip screen
sudo pecl install rrd
- Apache: webserver that will serve the WebUI
- PHP: programming language that plays nice with Apache
- git: tool to fetch minepeon & miners from the web
- zip: tool used by WebUI for config backups
- screen: has nothing todo with it, but is used for cgminer service
- rrd: tool that will make nice graphs
Open the Apache configuration with nano.
mkdir /opt/minepeon/http/
sudo nano /etc/httpd/conf/httpd.conf
Find the following entries and adjust:
DocumentRoot "/opt/minepeon/http"
<Directory "/opt/minepeon/http">
AllowOverride AuthConfig
Include conf/extra/httpd-ssl.conf
Add this somewhere around line 120:
# Use for PHP 5.x:
LoadModule php5_module modules/libphp5.so
AddHandler php5-script php
Include conf/extra/php5_module.conf
Close and save the Apache configuration
First step is to let it run as http instead of root. Therefore, edit this file:
sudo nano /usr/lib/tmpfiles.d/apache.conf
And make it like this:
d /run/httpd 0755 http http -
Enabling the httpd service will only load it in the list. Do not forget to also start the service:
sudo systemctl enable httpd.service
sudo systemctl start httpd.service
Create this ini file sudo nano /etc/php/conf.d/minepeon.ini
; Set timezone in this format or just UTC
date.timezone = Europe/Brussels
; Enable rrdtool for round robin graphs
extension=rrd.so
; Enable sockets to make use of the miner.php supplied with cgminer
extension=sockets.so
; Folders where php might try to open and edit files
; There is too much folders, but that's in case the structure would change in the future
open_basedir = /opt/minepeon/http:/opt/minepeon/conf:/opt/minepeon/backup:/opt/minepeon/include:/opt/minepeon/e$
; Folders where php might try to include files
include_path=".:/opt/minepeon/http/inc:/opt/minepeon/include"
; Temp upload folder
upload_tmp_dir = /opt/minepeon/http
: Temp session folder
session.save_path = "/opt/minepeon/tmp"
mkdir /opt/minepeon
mkdir /opt/minepeon/http
mkdir /opt/minepeon/http/rrd
git clone https://github.com/MineForeman/MinePeon /opt/minepeon
git clone https://github.com/MineForeman/MinePeonWebUI /opt/test
echo '{["pools":{[{"user":"test"}]}]}' > /opt/minepeon/etc/miner.conf
sudo chmod -R 770 /opt/minepeon
sudo chmod -R 777 /opt/minepeon/http/rrd
sudo chown -R minepeon /opt
Use ifconfig
to find your IP and visit it from another computer in the network. It should work but the miner will be down.
If the delivered cgminer doesn't work, you can try compiling it yourself. Here is how:
This takes quite a while. Not sure if all needed packages are in this list
sudo pacman -Syy
sudo pacman -S git base-devel ncurses curl libusbx jre7-openjdk-headless
cgminer in MinePeon is located in /opt/minepeon/bin
. I'd rather leave it there and put it in /opt/cgminer
. This means the systemctl service will look in /opt/cgminer
and not in the minepeon directory.
cd /opt
git clone https://github.com/ckolivas/cgminer.git
cd cgminer
CFLAGS="-g -W -Wall" ./autogen.sh --enable-bflsc --enable-icarus --enable-bitforce --enable-modminer --enable-ztex --enable-avalon
make clean
make
I don't know shit about compiling. But this works. Feedback is welcome.
Make sudo nano /etc/systemd/system/cgminer.service
With this content:
[Unit]
Description=cgminer
After=network.target openntpd.service
[Service]
Type=forking
User=minepeon
ExecStart=/usr/bin/screen -dmS cgminer /opt/cgminer/cgminer --api-listen --api-allow W:127.0.0.1 -c /opt/minepeon/etc/miner.conf
ExecStop=/usr/bin/screen -S cgminer -X quit
Restart=always
[Install]
WantedBy=multi-user.target
Now let it run with this command
systemctl enable cgminer.service
systemctl start cgminer.service
Hit refresh in the upper right on the web interface and smile.
The same or different from cgminer?
I can't get it to compile. Help?
cd /opt
git clone https://github.com/luke-jr/bfgminer.git
cd bfgminer
./autogen.sh
./configure
make
Make folders for scripts that will be run by cron. Then edit crontab, if you are logged in as minepeon, cronjobs will be executed as minepeon. It's also possible to do it as root. But you shouldn't.
mkdir /opt/minepeon/cron
mkdir /opt/minepeon/cron/cron.1min
mkdir /opt/minepeon/cron/cron.5min
mkdir /opt/minepeon/cron/cron.noon
crontab -e
Add these:
# Each 5 minutes
*/5 * * * * run-parts /opt/minepeon/cron/cron.5min
# Daily, two minutes after noon
02 12 * * * run-parts /opt/minepeon/cron/cron.noon
# Extra
# Execute all scripts in this folder
# * * * * * run-parts /opt/minepeon/cron/
# Execute php script
# * * * * * /usr/bin/php /opt/minepeon/cron/cron.php