Linux CD-ROM Game System
|YAMAMORI Takenori <firstname.lastname@example.org>|
Here, we set the system so that a game starts without logging in. For that purpose, modify inittab /etc/inittab and change the default run level to 1 as follows:
id:3:initdefault: V id:1:initdefault:
It is necessary attention in addition to above, though you intend to have set /etc/inittab, the default run level of /etc/inittab will be rewritten as 3 or 5 when you use Xconfigurator later.
In a single user mode, the scripts under the directory /etc/rc.d/rc1.d are executed. So we newly create a shell script named /etc/rc.d/rc1.d/S99game which describes some commands to start the game. Don't forget to turn on the x permission of the S99game.
In addition, rc scripts should check the argument start basically, but the S99game omits it. The list of S99game is the following:
#!/bin/sh /etc/rc.d/init.d/xfs start PATH=/usr/X11R6/bin:/usr/local/bin:"$PATH"; export PATH HOME=/root; export HOME cd mkdir /tmp/gamefd umount /dev/fd0 until mount -t vfat /dev/fd0 /tmp/gamefd do echo echo -n 'Insert game FD and type [ENTER] or q to skip: ' read a if [ X$a != X ]; then break fi done xinit &
With "/etc/rc.d/init.d/xfs start" line of the S99game, a font server is invoked. Note that the X server does not start without a font server because a font setting of an XF86Config file is described to use a font server in case of Vine 2.0. There is another way that we change the XF86Config setting not to use a font server, however, I choose a simple way to invoke xfs.
Next, we set the environment variables PATH and HOME.
Afterwards, it tries to mount a floppy disk and if it failed it tries again with a message.
The last line of S99game executes xinit, and launches the X. Here, we described a game command in /root/.xinitrc as follows so that the game starts as an X application.
exec circuslinux --digital
The /root/.xinitrc is just one line because we don't need even a window manager.
After the setting of S99game and .xinitrc, umount the floppy disk and type the following command to reboot.
# /sbin/init 6
Then the following message will appear on the way of booting:
Insert game FD and type [ENTER] or q to skip:
Insert the floppy disk for the save-data and type [Enter] to proceed, otherwise just type q without a floppy disk.
Now the game should start directly without logging in. Right now we have got the appearance in completion of the CD-ROM game system.
By the way, because the S99game script executes xinit with an "&" which is a shell syntax, the S99game script is finished concurrently with launching X. And the processing returns to S00single and it invokes a single user shell. By this mechanism, we can change a virtual screen during games and do some maintenance work with a single user shell.
Switch the virtual screen as follows:
[Ctrl]+[Alt]+[F1] -- A shell on console [Ctrl]+[Alt]+[F2] -- The game screen
You may need to hit an [Enter] once to see the shell prompt just after switching the screen.
In addition, the number of the virtual screen is two, which is different from a usual multi user mode that has six screens plus an X screen. And note that the PATH and HOME for the single user shell are different from the setting in the S99game.
After the confirmation of the game launching with a single user mode, we can go to a usual multi user mode by typing the following command after finishing the game.
bash# telinit 3
From now on, remember that we finish the game and execute "telinit 3" because the game always starts whenever the system boots from a hard drive.
In addition, when we input exit on the single user shell, the scripts of run level 1 will be executed once more and the game starts again.