====== Use DOS Doors with Synchronet on Linux ======

Instructions for using DOSEMU to run DOS doors on Synchronet-Linux.

:!:
DOSEMU has been discontinued for more than a decade. However, it is the only viable solution for most distributions to run DOS doors, and is supported in Synchronet. However, there is [[howto:dosemu2|a guide]] to installing DOSEMU2.  There is also [[https://gitlab.synchro.net/main/sbbs/-/issues/433|a Synchronet issue]] with some suggestions on how to get DOSEMU2 working with Synchronet.



===== What is this? =====

Using DOSEMU, you can run DOS external programs inside of your Linux Synchronet BBS. 


===== Getting Started =====

==== Install DOSEMU ====

Install DOSEMU into your system. For Debian and others, you will need to find a repository for an older version in order to get the DOSEMU package. For other systems, you may be able to compile it or obtain it in other ways.

For Debian, once you install a prior repository, simply:	 
   apt-get install dosemu dosemu-freedos	  	 
For other distributions,​ you will need to first install and configure dosemu, and then install FreeDOS (or your DOS of choice) and set it up to work with dosemu. Ensure that you can at least get to a DOS prompt through standalone DOSEMU before even trying to use it with Synchronet.

==== Edit sbbs.ini ====

Modify the ''[BBS]'' section of your ''[[dir:ctrl]]/sbbs.ini'' to set/add ''UseDOSemu = true''.

You can also modify the ''DOSemuPath'' and ''DOSemuConfPath'' values if you need something other than the defaults. However, normally, the Synchronet-provided ''dosemu.conf'' will be in your Synchronet ''[[dir:ctrl]]'' dir and ''dosemu.bin'' will be in your system ''bin'' directory, so the default values should work fine.

==== Install DOS Utils ====

Make a ''dosutils'' directory, preferably in your ''[[dir::exec]]'' dir but you can also put it in your ''[[dir::xtrn]]'' dir. (Note: if you put in your ''[[dir::xtrn]]'' dir, you can use it for external editors).

Inside the ''dosutils'' directory, you'll need a FOSSIL driver (''x00.exe'' works well, but you can also use ''bnu.com'', etc.).

If you aren't sure what to use, go with [[https://vert.synchro.net/files/main/comm/x00150.zip|X00]]. You may need to rename ''x00.sys'' to ''x00.exe'' if you use this archive.
Alternatively, you can use [[https://vert.synchro.net/files/main/comm/bnu189h.zip|BNU]] instead.

You may also need ''share.com'' if it is not found in your dosemu drive.

You can install additional utilities here that your doors may need, but the above is all you will normally need.

==== Modify external.bat ====

The ''external.bat'' file found in your ''[[dir:exec]]'' dir is the template used to build the batch file which executes each external program. Inside this file is where you will place your call to your FOSSIL driver, within the '':NOEMU'' section, like this:
<file>
IF "$RUNTYPE" == "FOSSIL" x00.exe eliminate >NUL
</file>
And you will also have share:

<file>
@share >NUL
</file>

==== Setup External Programs ====

Proceed to setup your external program using the [[howto:door:index|normal Installation methods]].
====== Advanced Usage ======


==== emusetup.bat ====

Historically, the integration used ''emusetup.bat'' in your ''[[dir:ctrl]]'' directory to setup the fossil drivers, etc. This is still supported for existing users, but it is no longer required. Just put what you need in the :NOEMU section of ''[[dir:ctrl]]''/''external.bat''. This batch file configures the DOS environment, and can be used to load additional TSRs, change drive letters around, or make any other last minute changes to the environment before the door is loaded. It is required to at least load a FOSSIL driver in this batch file. 

The file looked like:

<file emusetup.bat>
set PATH=%PATH%;e:\dosutils

REM fossil driver, such as x00, bnu, or dosemu fossil.com
fossil.com
rem bnu.com /P1 /L0=11520
rem x00.exe
REM share.exe for multinode file locking
share.exe
REM ansi.com for console i/o programs
ansi.com
</file>

NOTE: append "eliminate" to x00.exe to skip the 5 second commercial ad when it is invoked (ie; "x00.exe eliminate" instead of just x00.exe). This will prevent a 5 second delay when starting doors and invoking external dos editors. 

==== DOSEmu Path ====

The default dosemu binary is /usr/bin/dosemu.bin. If you have a different one that you would like all DOS programs that Synchronet launches to use, configure DOSemuPath in ''[[config:sbbs.ini]]''.

Example:

  DOSemuPath=/usr/local/bin/dosemu.bin 
 
 
NOTE: Be sure to point to ''dosemu.bin'' and not the ''dosemu'' wrapper script. 

==== DOSEmu Conf ====

By default, it will check for dosemu.conf in your startup/external program directory, and then look at the path you configured as ''DOSemuConfPath'' in ''[[config:sbbs.ini]]''. If neither is found, it will look at ''/etc/dosemu/dosemu.conf'' and ''/etc/dosemu.conf''
 
==== DOSEMU.ini ====

The file ''[[dir:exec]]/dosemu.ini'' is used to determine the command line execution of dosemu. You should not normally need to edit this file, but you can if you need to. The global ''cmd'' entry is used for FOSSIL, COM, and UART programs. The ''[stdio]'' ''cmd'' entry is used for intercept I/O programs.

See the file comments for which variable names you can use in the file to be substituted at run-time. These are used instead of environment variables due to the limited amount of memory available inside the batch file during execution. For example, the text ''$CTRLDIR'' will be expanded to point to your actual ctrl directory.


You can also place a copy of this file in the external program's startup directory to override it for that external program.

==== Drive Letters ====

Assuming you are using the default remapped drive letters and haven't changed them around in ''emusetup.bat'' or ''external.bat'', they are: 

  * D: - The Synchronet node directory, where the dropfile should probably be put. In door configurations, specify this drive (D:\) as the path to the dropfile. 
  * E: - Under this drive, the parent of the door's startup directory will be mounted. Example: ''E:\LORD''
  * F: - The Synchronet ''[[dir:ctrl]]'' directory 
  * G: - The Synchronet ''[[dir:data]]'' directory 
  * H: - The Synchronet ''[[dir:exec]]'' directory 

==== Troubleshooting ====

If a door will not run or has problems:

  * Try to capture any output in the BBS. In Syncterm, you can do this with Alt-C
  * Cat /sbbs/node(#)/external.bat and look at the bottom REM line. Try running that command and see what happens
  * Manually enter dosemu. Map your drive (lredir E: linux\fs\sbbs\xtrn). Switch to drive E and run "external.bat TEST". The "TEST" simply keeps it from running "exitemu". 

Check your syslog, your SBBS error log, as well as the dosemu_boot.log in your node dir.

Make sure the door's directory conforms to the DOS 8.3 file format! /usr/local/games/tw2002 would be okay, but /usr/local/games/TradeWars2002 would not. The symptom of a non-conforming directory is a "file not found" when Synchronet tries to change to the DOS door's directory inside DOSEMU. 

If the door doesn't start, it's probably a configuration problem of some kind that has left DOSEMU sitting at a DOS prompt. If you have what you think is a hung session, the first thing to try is blindly typing 'exitemu' to see if the session can be exited. 

Make SURE that if the door is started with a .bat batch file, that you explicitly name it as such in the "Program Name" field. For instance, LORD's "start.bat" command would be entered as "start.bat %#", not just "start %#". Failure to do this will cause the session to be hung inside DOSEMU when the user exits the door. (You can still exit by blindly typing exitemu when this happens.) 

Make sure your terminal is 80 chars wide, especially for configuration programs.
==== Setting up a non-door DOS program as a door ====

For the most part, setting up a non-door DOS program is done following the same procedure as a door. The key difference is that you set Redirect STDIO to Yes for a program that is not designed specifically to run as a BBS door. 

==== Timed Events ====

You can also set up timed events (e.g. door daily maintenance programs) in this same manner. Just make sure Native Program is set to "No" and it will work fine. 
  Startup Directory: /path/to/the/door (or ../xtrn/mydoor) 
  Program name: program.exe %params 
  Multiuser: Yes/No depending on the program 
  Redirect STDIO: Yes 
  Native Program: No 
  Dropfile: pick something if the program wants/needs it. 
  Use Lowercase: Yes 
  Dropfile Dir: Place in Node Directory 

==== Per-Program Configuration Files ====

You can override the default system files used by placing a customized version in the external program's startup directory. Files that can be overridden in this manner are:

** external.bat ** used instead of ''[[dir:exec]]/external.bat''

** dosemu.conf ** used instead of configured dosemu.conf

** dosemu.ini ** used instead of ''[[dir:exec]]/dosemu.ini''

==== Alternate DOS ====

The most up-to-date freedos distribution can be found [[http://web.archive.org/web/20120513002754/http://www.freedos.org/freedos/files/|here]] -- this is known to fix problems with Tradewars 2002. You might consider trying DR-DOS if you have problems with FreeDOS. However, be certain that you use the autoexec.bat from the FreeDOS distribution, as the Synchronet integration depends on it (specifically, it depends on the DOSDRIVE_D and unix -e behavior from it). Also remember to copy the DOSEMU support files (usually located in /usr/lib/dosemu/commands) into c:\dosemu in the DR-DOS hdimage. 




==== Files ====

  * [[http://www.icequake.net/bbs/syncmods/emusetup.bat|emusetup.bat]]
  * [[https://web.archive.org/web/20191007163940/http://www.icequake.net/bbs/syncmods/dosutils.tar.gz|A collection of essential DOS BBS utils, such as ANSI drivers and FOSSIL drivers]]


 

===== See Also =====
  * [[:howto:door:index|Install Doors]]
  * [[:howto:|How-To Pages]]
  * [[https://web.archive.org/web/20191007163940/http://www.icequake.net/bbs/syncmods/|Ryan Underwood's original Synchronet-DOSEMU patch]]
  * [[http://synchro.net/docs/linux-dosemu-howto.txt|DOSEMU Synchronet DOORS HOWTO by Michael Capp circa 2003]] (does not use the methods described on this page)

{{tag>linux doors dosemu}}
