mirror of
https://github.com/clusterio/clusterio.git
synced 2026-11-19 15:33:12 +09:00
Merge pull request #468 from Hornwitser/installer-fixes
Installer fixes
This commit is contained in:
2 files changed
+32
-11
No files matched your search
@@ -105,7 +105,7 @@ Otherwise see below for OS specific instructions.
|
|||||||
wget -qO - https://deb.nodesource.com/setup_14.x | sudo -E bash -
|
wget -qO - https://deb.nodesource.com/setup_14.x | sudo -E bash -
|
||||||
sudo apt install nodejs
|
sudo apt install nodejs
|
||||||
|
|
||||||
2. Create a new directory and run the Clusterio installer:
|
2. Log in as the user you wish to install Clusterio as (do not use root), and then create a new directory and run the Clusterio installer:
|
||||||
|
|
||||||
mkdir clusterio
|
mkdir clusterio
|
||||||
cd clusterio
|
cd clusterio
|
||||||
@@ -113,14 +113,7 @@ Otherwise see below for OS specific instructions.
|
|||||||
|
|
||||||
Make sure to note down the admin authentication token it provides at the end as you will need it later.
|
Make sure to note down the admin authentication token it provides at the end as you will need it later.
|
||||||
|
|
||||||
3. If you chose to use local factorio directory for the Factorio installation then download the headless build of Factorio and unpack it:
|
3. Optionally copy the generated systemd service files in `systemd` folder to `/etc/systemd/system/`.
|
||||||
|
|
||||||
wget -O factorio.tar.xz https://www.factorio.com/get-download/latest/headless/linux64
|
|
||||||
tar -xf factorio.tar.xz
|
|
||||||
|
|
||||||
To specify a version of Factorio to download replace "latest" in the URL with a version number like "1.0.0".
|
|
||||||
|
|
||||||
4. Optionally copy the generated systemd service files in `systemd` folder to `/etc/systemd/system/`.
|
|
||||||
|
|
||||||
|
|
||||||
**Ubuntu with Docker**
|
**Ubuntu with Docker**
|
||||||
|
|||||||
@@ -168,6 +168,19 @@ async function validateInstallDir() {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
async function validateNotRoot(args) {
|
||||||
|
if (args.allowInstallAsRoot) {
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
|
||||||
|
if (os.userInfo().uid === 0) {
|
||||||
|
throw new InstallError(
|
||||||
|
"Refusing to install as root. Create a separate user account for clusterio " +
|
||||||
|
"and then use su/sudo to switch to it before invoking the installer."
|
||||||
|
);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
async function installClusterio(mode, plugins) {
|
async function installClusterio(mode, plugins) {
|
||||||
try {
|
try {
|
||||||
await safeOutputFile("package.json", JSON.stringify({
|
await safeOutputFile("package.json", JSON.stringify({
|
||||||
@@ -225,6 +238,17 @@ async function installClusterio(mode, plugins) {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
async function groupIdToName(gid) {
|
||||||
|
try {
|
||||||
|
let exec = util.promisify(child_process.exec);
|
||||||
|
let { stdout } = await exec(`getent group ${gid}`);
|
||||||
|
return stdout.split(":")[0];
|
||||||
|
} catch (err) {
|
||||||
|
logger.warn(`getent group ${gid} failed: ${err.message}`);
|
||||||
|
return gid;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
async function writeScripts(mode) {
|
async function writeScripts(mode) {
|
||||||
if (["standalone", "master"].includes(mode)) {
|
if (["standalone", "master"].includes(mode)) {
|
||||||
if (process.platform === "win32") {
|
if (process.platform === "win32") {
|
||||||
@@ -245,7 +269,7 @@ Description=Clusterio Master
|
|||||||
|
|
||||||
[Service]
|
[Service]
|
||||||
User=${os.userInfo().username}
|
User=${os.userInfo().username}
|
||||||
Group=nogroup
|
Group=${await groupIdToName(os.userInfo().gid)}
|
||||||
WorkingDirectory=${process.cwd()}
|
WorkingDirectory=${process.cwd()}
|
||||||
KillMode=mixed
|
KillMode=mixed
|
||||||
KillSignal=SIGINT
|
KillSignal=SIGINT
|
||||||
@@ -276,7 +300,7 @@ Description=Clusterio Slave
|
|||||||
|
|
||||||
[Service]
|
[Service]
|
||||||
User=${os.userInfo().username}
|
User=${os.userInfo().username}
|
||||||
Group=nogroup
|
Group=${await groupIdToName(os.userInfo().gid)}
|
||||||
WorkingDirectory=${process.cwd()}
|
WorkingDirectory=${process.cwd()}
|
||||||
KillMode=mixed
|
KillMode=mixed
|
||||||
KillSignal=SIGINT
|
KillSignal=SIGINT
|
||||||
@@ -536,6 +560,9 @@ async function main() {
|
|||||||
|
|
||||||
if (process.platform === "linux") {
|
if (process.platform === "linux") {
|
||||||
args = args
|
args = args
|
||||||
|
.option("allow-install-as-root", {
|
||||||
|
nargs: 0, describe: "(Linux only) Allow installing as root (not recommended)", type: "boolean",
|
||||||
|
})
|
||||||
.option("download-headless", {
|
.option("download-headless", {
|
||||||
nargs: 0,
|
nargs: 0,
|
||||||
describe: "(Linux only) Automatically download and unpack the latest factorio release. " +
|
describe: "(Linux only) Automatically download and unpack the latest factorio release. " +
|
||||||
@@ -552,6 +579,7 @@ async function main() {
|
|||||||
|
|
||||||
if (!dev) {
|
if (!dev) {
|
||||||
await validateInstallDir();
|
await validateInstallDir();
|
||||||
|
await validateNotRoot(args);
|
||||||
}
|
}
|
||||||
|
|
||||||
let answers = await inquirerMissingArgs(args);
|
let answers = await inquirerMissingArgs(args);
|
||||||
|
|||||||
Reference in new issue
Block a user