Skip to content

Commit 9576cd4

Browse files
committed
Add sed commands to automatically fix forge paths
1 parent 161514c commit 9576cd4

File tree

1 file changed

+35
-20
lines changed
  • docs/mscs/adjusting-world-server-properties

1 file changed

+35
-20
lines changed

docs/mscs/adjusting-world-server-properties/forge.md

Lines changed: 35 additions & 20 deletions
Original file line numberDiff line numberDiff line change
@@ -100,7 +100,21 @@ is the name of your world.
100100
## Forge 1.17.1 and later
101101
Please note that forge for Minecraft 1.17.1 will be used in the examples. If you named the server directory `forge-1.17.1` in the first step with the `mkdir` command, the installer should install a bash script to `/opt/mscs/server/forge-1.17.1` and a bunch of library files in `/opt/mscs/server/forge-1.17.1/libraries/`.
102102

103-
In the `/opt/mscs/server/forge-1.17.1 directory`, edit `run.sh`.
103+
### Automatic
104+
105+
In the `/opt/mscs/server/forge-1.17.1` directory, execute these commands:
106+
107+
```bash
108+
sed -i "\|@[^\"]|s|@|@$(pwd)/|" run.sh
109+
sed -i "s|\"\$@|--nogui &|g" run.sh
110+
sed -i "s|libraries|$(pwd)/libraries|g" libraries/net/minecraftforge/forge/*/unix_args.txt
111+
```
112+
113+
Continue below at **<a href="#end-manual">You may also want...</a>**
114+
115+
### Manual
116+
117+
In the `/opt/mscs/server/forge-1.17.1` directory, edit `run.sh`.
104118

105119
(GNU nano is an easy to use command-line text editor if you plan to edit the file from the terminal. Install it with `sudo apt install nano` if you are using a Debian based distro. In the following instructions, to edit a file with GNU nano, replace `editor` with `nano`.)
106120

@@ -122,6 +136,25 @@ The `@user_jvm_args.txt` and the `@libraries/net/minecraftforge/forge/1.17.1-37.
122136
java @/opt/mscs/server/forge-1.17.1/user_jvm_args.txt @/opt/mscs/server/forge-1.17.1/libraries/net/minecraftforge/forge/1.17.1-37.1.1/unix_args.txt --nogui "$@"
123137
```
124138

139+
Now the `unix_args.txt` file mentioned in `run.sh` needs to be edited as well to include the full directory paths. Change the directory to the one containing the `unix_args.txt` file, create a backup in case you mess up the editing, and then edit the original.
140+
141+
```bash
142+
cd /opt/mscs/server/forge-1.17.1/libraries/net/minecraftforge/forge/1.17.1-37.1.1/
143+
cp unix_args.txt unix_args_backup.txt
144+
editor unix_args.txt
145+
```
146+
147+
Every path that includes `libraries/[...]` has to be replaced with their full directory path: `/opt/mscs/server/forge-1.17.1/libraries/[...]`. If your editor of choice is GNU nano, this can be done by pressing `<Ctrl-\>`, typing `libraries` and pressing enter, then typing the full path name. In this case it would be `/opt/mscs/server/forge-1.17.1/libraries`, then press enter, then press `<a>` to replace all.
148+
149+
If you mess this up, you can always delete the `unix_args.txt` file and make another one using the backup, and start editing again.
150+
151+
```bash
152+
rm unix_args.txt
153+
cp unix_args_backup.txt unix_args.txt
154+
editor unix_args.txt
155+
```
156+
<a id="end-manual"></a>
157+
125158
You may also want to increase the initial RAM and possibly even the maximum RAM. To do this, edit the `user_jvm_args.txt` file.
126159

127160
```bash
@@ -143,24 +176,6 @@ Now add all the java arguments you wish. For example, to allocate a minimum of 4
143176
-Xms4G -Xmx6G
144177
```
145178

146-
Now the `unix_args.txt` file mentioned in `run.sh` needs to be edited as well to include the full directory paths. Change the directory to the one containing the `unix_args.txt` file, create a backup in case you mess up the editing, and then edit the original.
147-
148-
```bash
149-
cd /opt/mscs/server/forge-1.17.1/libraries/net/minecraftforge/forge/1.17.1-37.1.1/
150-
cp unix_args.txt unix_args_backup.txt
151-
editor unix_args.txt
152-
```
153-
154-
Every path that includes `libraries/[...]` has to be replaced with their full directory path: `/opt/mscs/server/forge-1.17.1/libraries/[...]`. If your editor of choice is GNU nano, this can be done by pressing `<Ctrl-\>`, typing `libraries` and pressing enter, then typing the full path name. In this case it would be `/opt/mscs/server/forge-1.17.1/libraries`, then press enter, then press `<a>` to replace all.
155-
156-
If you mess this up, you can always delete the `unix_args.txt` file and make another one using the backup, and start editing again.
157-
158-
```bash
159-
rm unix_args.txt
160-
cp unix_args_backup.txt unix_args.txt
161-
editor unix_args.txt
162-
```
163-
164179
Create a new server (if necessary):
165180

166181
```bash
@@ -208,7 +223,7 @@ mscs stop forge
208223
mscs start forge
209224
```
210225

211-
The server should start up and run
226+
The server should start up and run.
212227

213228
The server startup can be monitored by running:
214229

0 commit comments

Comments
 (0)