Wrote my first install script for PlayOnLinux

I like to play games once in a while, but I don’t have Windows.
So like many other Linux gamers, I use Wine, but I like to have an overlay to keep things neat and organized, and thus I use PlayOnLinux.
PlayOnLinux comes with installation scripts so that the games will work right away without me having to fiddle around with a bunch of hacks to get it working, but as it turns out, the game I wanted to play (Civilization IV: Complete Edition) didn’t have an installation script that worked, so I decided to write my own and try to get it approved by the people at PlayOnLinux, and thus added to the software list of approved and signed scripts 🙂

It hasn’t been approved yet, but it’s getting there.
This is the script so far (fully working in this state).

Go to the link below for the newest development info
http://www.playonlinux.com/en/topic-10740.html

Another interesting thing to note, is that I am hosting the Civ IV patches myself that the script is downloading and installing, since I want to make sure that it’s always being hosted on a fast connection for everyone to use.

If anyone else need the patches for use outside of this script, you can download them below. (The patches below are no longer hosted by me!)

Civilization IV Patch 1.74
Civilization IV – Warlords Patch 2.13
Civilization IV – Beyond The Sword Patch 3.19

#!/bin/bash
# Date : (2013-06-26)
# Last revision : (2013-07-23)
# Wine version used : 1.4.1
# Distribution used to test : xUbuntu 13.10
# Author : Jimmy Ramsmark
# Licence : GPLv3
# Depend : msxml3, d3dx9
 
# This script was tested using the DVD version of `Civilization IV: Complete'
# version 1.74, bought in the Sweden in 2011.
 
[ "$PLAYONLINUX" = "" ] && exit 0
source "$PLAYONLINUX/lib/sources"
 
TITLE="Civilization IV: Complete Edition"
TITLECIV="Civilization IV"
TITLEBTS="Civilization IV - Beyond The Sword"
TITLEW="Civilization IV - Warlords"
TITLECOL="Civilization IV - Colonization"
AUTHOR="Jimmy Ramsmark"
PREFIX="Civilization4"
WORKINGWINEVERSION="1.4.1"
STEAM_ID_CIV="3900"
STEAM_ID_W="3990"
STEAM_ID_BTS="8800"
STEAM_ID_COL="16810"
 
POL_GetSetupImages "http://files.playonlinux.com/resources/setups/$PREFIX/top.jpg" "http://files.playonlinux.com/resources/setups/$PREFIX/left.jpg" "$TITLE"
 
POL_SetupWindow_Init
POL_SetupWindow_SetID 1779
POL_Debug_Init
 
POL_SetupWindow_presentation "$TITLE" "Firaxis Games" "http://www.firaxis.com/" "$AUTHOR" "$PREFIX"
POL_Wine_SelectPrefix "$PREFIX"
 
POL_SetupWindow_InstallMethod "DVD,STEAM"
 
if [ "$INSTALL_METHOD" == "DVD" ]; then
    # Let the user select a DVD
    POL_SetupWindow_cdrom
 
    # Check if this DVD is the Civilization IV DVD
    POL_SetupWindow_check_cdrom "Autorun/Civ4Installer.ico"
fi
 
# Set and install the correct Wine version
POL_Wine_PrefixCreate "$WORKINGWINEVERSION"
 
# Install DirectX9
POL_Call POL_Install_d3dx9
 
if [ "$INSTALL_METHOD" == "DVD" ]; then
    # Run installer
    POL_Wine_WaitBefore "$TITLECIV"
    POL_Wine start /unix "$CDROM/setup.exe"
    POL_Wine_WaitExit "$TITLECIV"
 
    #Patch Civilization IV: Beyond the sword to 3.19
    cd "$POL_USER_ROOT/tmp"
    POL_Download "http://ayu.alcor.se/files/Civ4BeyondTheSwordPatch3.19.exe" "c45f6e028f51db2386120a5861eabe7c"
    POL_Wine_WaitBefore "$TITLECIV"
    POL_Wine Civ4BeyondTheSwordPatch3.19.exe
    POL_Wine_WaitExit "$TITLECIV"
else
    POL_Call POL_Install_steam
 
    # Start steam, update it, and install the games
    cd "$WINEPREFIX/drive_c/$PROGRAMFILES/Steam"
    POL_Wine start /unix "Steam.exe" steam://install/$STEAM_ID_CIV
    POL_SetupWindow_message "$(eval_gettext 'Steam is about to perform an update.nAfter Steam finishes updating and shows you to the login interface, login and then let $TITLE install.nnWhen the installation is finished, press next (Do not close Steam)')" "$TITLECIV"
  
    POL_Wine start /unix "Steam.exe" steam://install/$STEAM_ID_W
    POL_SetupWindow_message "$(eval_gettext 'Steam is installing $TITLEW, press next when the installation is finished')" "$TITLECIV"
 
    POL_Wine start /unix "Steam.exe" steam://install/$STEAM_ID_BTS
    POL_SetupWindow_message "$(eval_gettext 'Steam is installing $TITLEBTS, press next when the installation is finished')" "$TITLECIV"
 
    POL_Wine start /unix "Steam.exe" steam://install/$STEAM_ID_COL
    POL_SetupWindow_message "$(eval_gettext 'Steam is installing $TITLECOL, please quit Steam properly when the installation is finished (make sure Steam is not still in the traybar) and then press next so that the installation script can continue.')" "$TITLECIV"
    POL_Wine_WaitExit "$TITLECIV"
fi
 
# Install msxml3.msi
# Override for msxml3 is needed before the install
# The msvcr71 one is just there so that mods will work later on
 
POL_Wine_OverrideDLL "native" "msxml3"
POL_Wine_OverrideDLL "builtin" "msvcr71"
POL_Call POL_Install_msxml3
 
#Create shortcuts
if [ "$INSTALL_METHOD" == "STEAM" ]; then
    POL_Shortcut "Steam.exe" "$TITLECIV" "$TITLECIV.png" "-applaunch $STEAM_ID_CIV" "Game;StrategyGame;"
    POL_Shortcut "Steam.exe" "$TITLEBTS" "$TITLEBTS.png" "-applaunch $STEAM_ID_BTS" "Game;StrategyGame;"
    POL_Shortcut "Steam.exe" "$TITLEW" "$TITLEW.png" "-applaunch $STEAM_ID_W" "Game;StrategyGame;"
    POL_Shortcut "Steam.exe" "$TITLECOL" "$TITLECOL.png" "-applaunch $STEAM_ID_COL" "Game;StrategyGame;"
    POL_Shortcut "Steam.exe" "Steam - Civ IV" "" "" "Game;"
else
    POL_Shortcut "Civilization4.exe" "$TITLECIV" "$TITLECIV.png" "" "Game;StrategyGame;"
    POL_Shortcut "Civ4BeyondSword.exe" "$TITLEBTS" "$TITLEBTS.png" "" "Game;StrategyGame;"
    POL_Shortcut "Civ4Warlords.exe" "$TITLEW" "$TITLEW.png" "" "Game;StrategyGame;"
fi
 
#Done!
POL_SetupWindow_message "$(eval_gettext 'Installation finishednnThe game might crash on the first attempt, but no worries, just try one more time.')" "$TITLECIV"
POL_SetupWindow_Close
exit 0

Leave a Reply

Fill in your details below or click an icon to log in:

WordPress.com Logo

You are commenting using your WordPress.com account. Log Out /  Change )

Google+ photo

You are commenting using your Google+ account. Log Out /  Change )

Twitter picture

You are commenting using your Twitter account. Log Out /  Change )

Facebook photo

You are commenting using your Facebook account. Log Out /  Change )

Connecting to %s

This site uses Akismet to reduce spam. Learn how your comment data is processed.