Skip to content

Instantly share code, notes, and snippets.

@tedivm
Last active January 28, 2019 23:26
Show Gist options
  • Save tedivm/c390913852475852ea2364b93b9eb660 to your computer and use it in GitHub Desktop.
Save tedivm/c390913852475852ea2364b93b9eb660 to your computer and use it in GitHub Desktop.
Screeps Private Server Setup (Ubuntu, Mongo, Redis)
  1. Download setup.sh and replace STEAM_KEY with your key and update any versions you want.
  2. Run setup.sh.
  3. Replace mods.json with one provided here.
  4. Create service file by copying file here to /etc/systemd/system/screeps-world.service.
  5. Enable and run service (systemctl enable screeps-world && systemctl start screeps-world).
  6. Log into the cli (su screeps && cd ~/world && ./node_modules/screeps/bin/screeps.js cli).
  7. Reset memory (system.resetAllData()) and restart (systemctl restart screeps-world.
{
"mods": [
"node_modules/screepsmod-mongo/index.js",
"node_modules/screepsmod-auth/index.js",
"node_modules/screepsmod-tickrate/index.js",
"node_modules/screepsmod-admin-utils/index.js",
"node_modules/screepsmod-features/index.js"
],
"bots": {
"simplebot": "node_modules/@screeps/simplebot/src"
}
}
[Unit]
Description=Screeps Server (world)
Wants=network-online.target
After=network-online.target
[Service]
Type=simple
WorkingDirectory=/home/screeps/world
ExecStart=/home/screeps/world/node_modules/screeps/bin/screeps.js start
User=screeps
Group=screeps
[Install]
WantedBy=multi-user.target
#!/usr/bin/env bash
STEAM_KEY=fillthisin
WORLD=world
MONGO_VERSION=3.6
MONGO_PUBLIC_KEY=2930ADAE8CAF5059EE73BB4B58712A2291FA4AD5
NODE_VERSION=8
UBUNTU_VERSION=xenial
# Install prerequisites
apt install -y build-essential tcl software-properties-common
# Install Node
curl -sL https://deb.nodesource.com/setup_${NODE_VERSION}.x | sudo -E bash -
apt install -y nodejs
# Install Mongo
apt-key adv --keyserver hkp://keyserver.ubuntu.com:80 --recv $MONGO_PUBLIC_KEY
echo "deb http://repo.mongodb.org/apt/ubuntu ${UBUNTU_VERSION}/mongodb-org/${MONGO_VERSION} multiverse" | sudo tee /etc/apt/sources.list.d/mongodb-org-${MONGO_VERSION}.list
apt update
apt-get install -y mongodb-org
systemctl start mongod
systemctl enable mongod
# Install redis
add-apt-repository ppa:chris-lea/redis-server
apt update
apt install redis-server
# Create screeps user and setup server
adduser --disabled-password --gecos "" screeps
su -m screeps -c "
mkdir ~/${WORLD};
cd ~/${WORLD};
npm install screeps;
yes ${STEAM_KEY} | ./node_modules/screeps/bin/screeps.js init;
npm install screepsmod-mongo screepsmod-auth screepsmod-tickrate screepsmod-admin-utils screepsmod-features;
"
@stevetrov
Copy link

Thanks for this its helped a lot.
A couple of points that didnt work for me.

  1. the su lines just opened a shell of that user without running the commands as intended. - I ran them manually.
  2. your mod.json includes screepsmod-features that you dont install in setup.sh
    But overall very helpful.

@ErikMuir
Copy link

Thanks, this is great! Two problems though:

  1. I'm not sure why, but when I install all the mods packages, it removes the screeps package itself, forcing me to have to reinstall the screeps package again.
  2. The service won't actually start. The screeps.js start command is throwing an error saying that it can't call mkdir.
Jan 28 17:20:56 zilbot screeps.js[647]:     at Promise.promise.promiseDispatch (/home/screeps/world/node_modules/q/q.js:816:13)
Jan 28 17:20:56 zilbot screeps.js[647]:     at /home/screeps/world/node_modules/q/q.js:624:44
Jan 28 17:20:56 zilbot screeps.js[647]:     at runSingle (/home/screeps/world/node_modules/q/q.js:137:13)
Jan 28 17:20:56 zilbot screeps.js[647]:     at flush (/home/screeps/world/node_modules/q/q.js:125:13)
Jan 28 17:20:56 zilbot screeps.js[647]:     at _combinedTickCallback (internal/process/next_tick.js:132:7)
Jan 28 17:20:56 zilbot screeps.js[647]:     at process._tickCallback (internal/process/next_tick.js:181:9)
Jan 28 17:20:56 zilbot screeps.js[647]:   errno: -13,
Jan 28 17:20:56 zilbot screeps.js[647]:   code: 'EACCES',
Jan 28 17:20:56 zilbot screeps.js[647]:   syscall: 'mkdir',
Jan 28 17:20:56 zilbot screeps.js[647]:   path: '/home/screeps/world/logs/1548717656041' }

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment