Raspberry Pi 4 + Raspbian Buster

Post Reply
krescenilo
Posts: 3
Joined: Sat Aug 24, 2019 5:02 pm

Raspberry Pi 4 + Raspbian Buster

Post by krescenilo » Sat Aug 24, 2019 6:47 pm

Hey all!

Far from a Linux expert here, but between the excellent Raspberry Pi 3 guide, the Build the Server wiki entry, and a decent amount of searching I was able to get the server going on a Raspberry Pi 4 running Raspbian Buster. So figured I'd share...

First a few housekeeping items...

su vs sudo - I prefer using sudo on individual commands to limit how much I can possibly screw things up, if you prefer switching to a privileged shell (su) instead feel free to su and ignore the sudo's

PASSWORD_HERE / USERNAME_HERE / etc - These are spots where YOU need to insert your own password / username / etc.

OR options - While searching / reading various guides, some things ended up having multiple options. The first / top option is what I ended up using while other options either did not work for me or I just didn't need to use.

cd /path/to/SOMEWHERE - Make sure you are using the correct path for YOUR installation.

1) I recommend a clean install of Buster followed by updating things:

Code: Select all

sudo apt-get update
sudo apt-get upgrade
sudo apt autoremove (only if prompted)
sudo apt-get dist-upgrade
Would suggest rebooting and repeating as needed until there are no more updates to install.

2) Install the DB... MySQL seems to be unavailable in Buster by default. There might be a backport available, but I went with MariaDB as was suggested when "apt-get install mysql" failed:

Code: Select all

sudo apt-get install mariadb-server-10.0
sudo apt-get install mariadb-server-core-10.0
sudo apt-get install mariadb-client-10.0
sudo apt-get install mariadb-client-core-10.0
sudo apt-get install libmariadbclient-dev
sudo apt-get install libmariadb-dev-compat
sudo apt-get install libmariadb-dev
Note - Some of the above items were already installed for me, but I don't remember which specifically.

Important note - I do know that make kept failing on me without something... I suspect it was "libmariadb-dev-compat" as the error had something to do with "mysql.h" but I'm not 100% on that.

3) Recommend running the script to secure the DB installation:

Note - I used default options.

Code: Select all

sudo mysql_secure_installation // INITIALLY I RAN THIS WITHOUT SUDO AND IT FAILED
Because if failed for me, I ended up doing a manual reset of the password. Hopefully that is unnecessary when ran with sudo, but here's what I did just in case...

-----MANUAL RESET-----

Code: Select all

sudo mysql -u root -p
ENTER / Should have an empty password on a clean install
FLUSH PRIVILEGES;
UPDATE mysql.user SET authentication_string = PASSWORD('PASSWORD_HERE') WHERE User = 'root' AND Host = 'localhost';
OR
ALTER USER 'root'@'localhost' IDENTIFIED BY 'PASSWORD_HERE';
exit
sudo systemctl stop mysql
sudo systemctl start mysql
sudo mysql_secure_installation // ONLY IF PASSWORD WAS MANUALLY RESET
-----MANUAL RESET-----

4) Setup remote DB access... this is only necessary if you want to access your DB from another device:

Code: Select all

sudo nano /etc/mysql/mariadb.conf.d/50-server.cnf
Add # in front of bind-address = 127.0.0.1
ctrl+o
ctrl+x
sudo systemctl stop mysql
sudo systemctl start mysql
5) Install some tools necessary for getting / building the server:

Code: Select all

sudo apt-get install git
sudo apt-get install autoconf
sudo apt-get install pkg-config
sudo apt-get install libzmq3-dev
sudo apt-get install luajit-5.1-dev
sudo apt-get install libluajit-5.1-dev
sudo apt-get install build-essential
sudo apt-get install screen
sudo apt-get install g++-7
Note - Again, some of the above items were already installed for me, but I don't remember which specifically.

I'm not sure if this command is necessary... but I ran it anyway, didn't seem to hurt anything:

Code: Select all

sudo update-alternatives --install /usr/bin/g++ g++ /usr/bin/g++-7 90
6) Optional, but I'd once again recommend updating things:

Code: Select all

sudo apt-get update
sudo apt-get upgrade
sudo apt autoremove (only if prompted)
sudo apt-get dist-upgrade
Would suggest rebooting and repeating as needed until there are no more updates to install.

7) Getting / building the server:

Code: Select all

sudo git clone http://github.com/DarkstarProject/darkstar.git/
cd /path/to/darkstar
sudo git checkout stable
sudo sh autogen.sh
sudo ./configure --enable-debug=gdb
sudo make
OR
sudo ./configure LIBS='-lm' // NOT SURE WHAT THE DIFFERENCE IS HERE
sudo make -j2 // THIS APPEARS TO LIMIT THINGS TO TWO "MAKES" AT TIME?
8) Preparing the DB:

Note - In some of the commands below, either use @'%' if you want your DB accessible from other devices OR use @'localhost' to restrict access to the localhost / device.

Code: Select all

sudo mysql -u root -p
CREATE USER 'USERNAME_HERE'@'%' IDENTIFIED BY 'PASSWORD_HERE';
OR
CREATE USER 'USERNAME_HERE'@'localhost' IDENTIFIED BY 'PASSWORD_HERE';
CREATE DATABASE dspdb;
USE dspdb;
GRANT ALL PRIVILEGES ON dspdb.* TO 'USERNAME_HERE'@'%';
OR
GRANT ALL PRIVILEGES ON dspdb.* TO 'USERNAME_HERE'@'localhost';
exit
9) Import data into the DB:

Code: Select all

cd /path/to/darkstar/sql
 for f in *.sql
  do
   echo -n "Importing $f into the database..."
   mysql dspdb -u USERNAME_HERE -pPASSWORD_HERE < $f && echo "Success" // BELIEVE I GOT A WARNING HERE
  done
mysql -u USERNAME_HERE -p
USE dspdb;
UPDATE zone_settings SET zoneip = 'IP_HERE';
exit
Note - For more on the IP_HERE part read this wiki entry.

Short version - Use 127.0.0.1 if your server / client are on the same device OR use your server's public / private IP if the client connects from another device.

10) Edit config files for DB access:

Code: Select all

cd /path/to/darkstar/conf
sudo nano login_darkstar.conf
mysql_login = USERNAME_HERE
mysql_password = PASSWORD_HERE
ctrl+o
ctrl+x
sudo nano map_darkstar.conf
mysql_login = USERNAME_HERE
mysql_password = PASSWORD_HERE
ctrl+o
ctrl+x
sudo nano search_server.conf
mysql_login = USERNAME_HERE
mysql_password = PASSWORD_HERE
ctrl+o
ctrl+x
11) Change the owner of the "darkstar" folder

Note - This is REQUIRED if you DO NOT want to run dsconnect / dsgame as root or a privileged user!

Code: Select all

sudo chown -R USERNAME_HERE:USERNAME_GROUP_HERE /path/to/darkstar
Important note - The USERNAME_GROUP_HERE entry is generally the same as the USERNAME_HERE entry.

12) Creating services:

Code: Select all

cd /lib/systemd/system/
The dsconnect service

Code: Select all

sudo nano dsconnect.service
-----FILE CONTENT-----

Code: Select all

[Unit]
Description=Connect Service
After=multi-user.target

[Service]
User=USERNAME_HERE
Group=USERNAME_GROUP_HERE
Type=simple
WorkingDirectory=/path/to/darkstar
ExecStart=/path/to/darkstar/dsconnect
Restart=always

[Install]
WantedBy=multi-user.target
-----FILE CONTENT-----

Code: Select all

ctrl+o
ctrl+x
sudo chmod 644 dsconnect.service
sudo systemctl daemon-reload
sudo systemctl enable dsconnect.service
sudo systemctl start dsconnect.service
The dsgame service

Code: Select all

sudo nano dsgame.service
-----FILE CONTENT-----

Code: Select all

[Unit]
Description=Game Service
After=multi-user.target

[Service]
User=USERNAME_HERE
Group=USERNAME_GROUP_HERE
Type=simple
WorkingDirectory=/path/to/darkstar
ExecStart=/path/to/darkstar/dsgame
Restart=always

[Install]
WantedBy=multi-user.target
-----FILE CONTENT-----

Code: Select all

ctrl+o
ctrl+x
sudo chmod 644 dsgame.service
sudo systemctl daemon-reload
sudo systemctl enable dsgame.service
sudo systemctl start dsgame.service
The dssearch service

Code: Select all

sudo nano dssearch.service
-----FILE CONTENT-----

Code: Select all

[Unit]
Description=Search Service
After=multi-user.target

[Service]
User=USERNAME_HERE
Group=USERNAME_GROUP_HERE
Type=simple
WorkingDirectory=/path/to/darkstar
ExecStart=/path/to/darkstar/dssearch
Restart=always

[Install]
WantedBy=multi-user.target
-----FILE CONTENT-----

Code: Select all

ctrl+o
ctrl+x
sudo chmod 644 dssearch.service
sudo systemctl daemon-reload
sudo systemctl enable dssearch.service
sudo systemctl start dssearch.service
Important note - I'm not sure how well these services hold up to a crash of dsconnect / dsgame / dssearch while logged in, since I haven't experienced that yet. But I do know that they will start all three during normal startup and after a reboot.

13) Last I recommend changing the "VER_LOCK" setting to "2" that way (and hopefully I'm interpreting this correctly) the currently supported client version PLUS any newer client versions can connect to the server:

Code: Select all

sudo nano version.info
VER_LOCK: 2
ctrl+o
ctrl+x
A few bonus commands and shell alias's that might be useful:

Commands

Code: Select all

sudo systemctl status SERVICE_NAME.service // CHECK SERVICE STATUS
sudo systemctl start SERVICE_NAME.service // START SERVICE
sudo systemctl stop SERVICE_NAME.service // STOP SERVICE
sudo journalctl -f -u SERVICE_NAME.service // VIEW SERVICE LOG - USE ctrl+c TO EXIT
ps -ef | grep ds // CHECK THAT ALL THREE SERVICES ARE RUNNING
Alias's

Code: Select all

alias NAME_HERE='sudo systemctl status dsconnect.service'
alias NAME_HERE='sudo systemctl status dsgame.service'
alias NAME_HERE='sudo systemctl status dssearch.service'
alias NAME_HERE='ps -ef | grep ds'

Bandit
Posts: 12
Joined: Sun Jan 20, 2019 10:53 am

Re: Raspberry Pi 4 + Raspbian Buster

Post by Bandit » Sun Aug 25, 2019 8:45 am

Wonderful Guide! :) Eventually I will eventually get around to trying this out. Buster seems like a pretty smooth OS so far. I still use the Rpi 3B+ and wont be getting a Rpi 4 yet till they come out with a decent case that will keep a 4GB nice and cool :)

krescenilo
Posts: 3
Joined: Sat Aug 24, 2019 5:02 pm

Re: Raspberry Pi 4 + Raspbian Buster

Post by krescenilo » Sun Aug 25, 2019 11:58 am

Had a similar concern when I saw that the official Pi 4 case didn't have any fans and didn't appear to come with any heat sinks. After some searching around I found this kit on Amazon. Comes with heat sinks for the CPU, RAM, and USB3 controller. Also has a small fan that sits above the CPU.

Bandit
Posts: 12
Joined: Sun Jan 20, 2019 10:53 am

Re: Raspberry Pi 4 + Raspbian Buster

Post by Bandit » Wed Aug 28, 2019 1:40 pm

This is what I use as a case but the rpi 3b+ versoion https://www.amazon.com/C4Labs-Zebra-Bra ... r=8-2&th=1

Bandit
Posts: 12
Joined: Sun Jan 20, 2019 10:53 am

Re: Raspberry Pi 4 + Raspbian Buster

Post by Bandit » Mon Sep 02, 2019 4:46 pm

Got my rpi 3b+ running dsp using your guide and able to connect to the server with no issues (havent ran around yet, gotta configure controller first). Just out of curiosity, have you tried to install it on a rpi 3b+ and have the issue of the rpi not fully shutting down? my still has the green light flashing when I select shutdown (i use a USB cruizer fit for a USB drive that Raspbian Buster and the FFXI server run on so the green light constantly flashing is normal) and let the pi shut down, it doesnt fully shut down, the green light still flashes fast instead of it normally shutting down with the flashes and then quits flashing to let me know i can shut it down

Bandit
Posts: 12
Joined: Sun Jan 20, 2019 10:53 am

Re: Raspberry Pi 4 + Raspbian Buster

Post by Bandit » Mon Sep 02, 2019 4:47 pm

and this is the first time i have ever installed the server on a USB thumb drive

krescenilo
Posts: 3
Joined: Sat Aug 24, 2019 5:02 pm

Re: Raspberry Pi 4 + Raspbian Buster

Post by krescenilo » Thu Sep 05, 2019 10:06 pm

Unfortunately my first Pi, so only have the Pi 4 to test with. I'm installed on the SD card and haven't had any problems with shutting down thus far... though I think I've only shut down like 3-4 times since getting it and installing the DSP server.

Maybe try disabling the services, see if they're perhaps hanging up on Pi 3?

Also nice case, probably won't need a Pi farm myself, still it's good to know something like that's available.

Post Reply