Forums

[script] Octgn

Auteur Réponses
gotsanity Lundi 3 Mars 2014 à 7:05
gotsanityAnonymous

Description: Installs and configures Octgn (virtual card/board game tabletop) on linux and Mac machines. This is my first script and could use a good proof-reading from you all. Constructive criticism welcome.

Installation Notes: This requires you to manually download the octgn install file (http://www.octgn.net)

[code language=playonlinux]
#!/bin/bash

# Date : 2014-03-02
# Last revision : 2014-03-02
# Wine version used : 1.7.12
# Distribution used to test : Ubuntu 13.10
# Author : GotSanity

[ "$PLAYONLINUX" = "" ] && exit 0
source "$PLAYONLINUX/lib/sources"

TITLE="Install OCTGN"
 
POL_SetupWindow_Init
POL_Debug_Init

# Get user input on prefix name
POL_SetupWindow_textbox "Please select a simple name for the winebottle? (octgn is fine)" "$TITLE"
PREFIX=$APP_ANSWER

# introduce the user
POL_SetupWindow_presentation "Octgn" "Octgn.net" "http://www.octgn.net" "GotSanity"

# Setup the prefix and start the installation
POL_Wine_SelectPrefix "$PREFIX"
POL_Wine_PrefixCreate "1.7.12"
POL_Call POL_Install_PrivateUserDirs
POL_Call POL_Install_dotnet40
POL_Call POL_Install_vcrun2010
POL_SetupWindow_InstallMethod "LOCAL"
if [ "$INSTALL_METHOD" = "LOCAL" ]
then
    POL_SetupWindow_browse "Please select the installation file to run." "$TITLE"
    POL_SetupWindow_message "On the next page installation of Octgn will begin. You MUST launch AND CLOSE Octgn before continuing. If you do not then your install will be broken and need to be reinstalled." "$TITLE"
    POL_SetupWindow_wait "Installation in progress." "$TITLE"
    POL_Wine start /unix "$APP_ANSWER"
    POL_Wine_WaitExit "$TITLE"
fi

# Have user modify settings.json to turn hardware acceleration off.
POL_SetupWindow_message "IMPORTANT! On the next screen notepad will open with a config file. You MUST edit UseHardwareAcceleration to false in order for Octgn to function without crashing. When finished just save and exit and the script will finish processing." "$TITLE"
POL_Wine start "notepad.exe c:/users/$USER/My Documents/OCTGN/Config/settings.json"
POL_Wine_WaitExit "$TITLE"

# Build launchers
POL_Shortcut "OCTGN.exe" "Octgn"

# close up shop
POL_SetupWindow_Close
exit
[/code]

Edité par gotsanity

petch Lundi 3 Mars 2014 à 11:19
petch

Hi gotsanity

This is my first script and could use a good proof-reading from you all. Constructive criticism welcome.

Quote from gotsanity

Let's do that then ;)

[code language=playonlinux]
TITLE="Install OCTGN"
[/code]
That will have to match the script name in the repository, so just "OCTGN" is better.
 
POL_SetupWindow_Init
POL_Debug_Init

[code language=playonlinux]
# Get user input on prefix name
POL_SetupWindow_textbox "Please select a simple name for the winebottle? (octgn is fine)" "$TITLE"
PREFIX=$APP_ANSWER
[/code]
I see no point in having the user choose the prefix name, if "octgn" is fine, just use that. It's also strange to ask questions even before script presentation.

[code language=playonlinux]
POL_SetupWindow_InstallMethod "LOCAL"
[/code]
Either add support for automated download, or drop this statement: asking the user to choose between one option will feel a bit silly...

[code language=playonlinux]
    POL_SetupWindow_browse "Please select the installation file to run." "$TITLE"
[/code]
All user-oriented messages should have support for localization, see http://www.playonmac.com/en/dev-documentation-10.html for the explanation of eval_gettext usage.

[code language=playonlinux]
    POL_SetupWindow_wait "Installation in progress." "$TITLE"
    POL_Wine start /unix "$APP_ANSWER"
    POL_Wine_WaitExit "$TITLE"
[/code]
You can use POL_Wine_WaitBefore "$TITLE" instead of this POL_SetupWindow_wait call, it will display the standard waiting message.
"start /unix" is usually not required (needs testing, but true 95% of the time).
POL_Wine_WaitBefore and POL_Wine_WaitExit shouldn't be both necessary around a single instruction, as one is useful if the instruction is blocking and the other if it is asynchronous. I suspect that after removing "start /unix" the installation will become blocking, and that POL_Wine_WaitBefore will be sufficient.

[code language=playonlinux]
# Have user modify settings.json to turn hardware acceleration off.
POL_SetupWindow_message "IMPORTANT! On the next screen notepad will open with a config file. You MUST edit UseHardwareAcceleration to false in order for Octgn to function without crashing. When finished just save and exit and the script will finish processing." "$TITLE"
POL_Wine start "notepad.exe c:/users/$USER/My Documents/OCTGN/Config/settings.json"
POL_Wine_WaitExit "$TITLE"
[/code]
That's what computers are for, it must be possible to automate that using sed, perl or even awk.
Some more informations about the file format would help.

Regards,
Pierre.

Edité par petch

gotsanity Lundi 3 Mars 2014 à 12:43
gotsanityAnonymous

Lots of good info in this reply. I will dig deep into your comments after I get some sleep. In the mean time, the file format info you requested is plain text. It appears to just be a json object loaded into a text file and after experimenting I could easily just replace with a backed up copy of the defaults needed but when trying to hack it together I was running into issues with file paths (I believe the issue I was running into was due to the spaces in the path). I wasn't able to figure it out so went with an alternative method till I had more time to work on it.

On another note. One of the people I have testing the script for Macs ran into an issue with the installation of dotnet40 and vcrun2010. According to them the installer complained that both dotnetfx and vcredist installers abort with "fatal error in setup.exe"

Any idea what that might be about?
petch Lundi 3 Mars 2014 à 13:10
petch

Maybe something like
cp settings.json settings.json.bak
sed -e 's/"UseHardwareAcceleration": true/"UseHardwareAcceleration": false/' settings.json.bak > settings.json

will be sufficient...
gotsanity Mardi 4 Mars 2014 à 11:02
gotsanityAnonymous

Here is the updated version of the script now with 100% more awesomesauce

I tried to address all of the previous concerns and with the exception of the POL_Wine_WaitExit "$TITLE" I believe i got them all. I left in a couple of the WaitExit because of the fact that timing wasn't working quite right without them around the sed modifications.

On another note: I am curious how to handle the situation of finding the latest version of the program from their site. I put in a request for them to package an octgn-latest.exe on their site but was curious what others have done to get around these limitations? I would like to submit this script for signing once the mac issues are ironed out and from what I understand the script wont be able to be edited after being signed so it will become obsolete on their next update.

#!/bin/bash

# Date : 2014-03-02
# Last revision : 2014-03-03
# Wine version used : 1.7.12
# Distribution used to test : Ubuntu 13.10
# Author : GotSanity

# CHANGELOG
# 
#  --- 2014-03-03 ---
# Automated modification of settings.json
# Added direct download from octgn.net
# Simplified Prefix selection - Now hardcoded as octgn
# Added support for multiple languages.
# Cleaned up some basic code
#
#  --- 2014-03-02 ---
# Woke up full of awesomesauce so I wrote a beta script...

[ "$PLAYONLINUX" = "" ] && exit 0
source "$PLAYONLINUX/lib/sources"

TITLE="Octgn"
PREFIX="octgn"
CURVERSION="OCTGN-Setup-3.1.129.298.exe"
INSTALLDIR="$REPERTOIRE/wineprefix/$PREFIX/drive_c/users/$USER/My Documents/OCTGN"
 
POL_SetupWindow_Init
POL_Debug_Init

# introduce the user
POL_SetupWindow_presentation "Octgn" "Octgn.net" "http://www.octgn.net" "GotSanity"

# Setup the prefix and start the installation
POL_Wine_SelectPrefix "$PREFIX"
POL_Wine_PrefixCreate "1.7.12"
POL_Call POL_Install_PrivateUserDirs
POL_Call POL_Install_dotnet40
POL_Call POL_Install_vcrun2010
POL_System_TmpCreate "$PREFIX"

# Choose install method and start install
POL_SetupWindow_InstallMethod "LOCAL, DOWNLOAD"
if [ "$INSTALL_METHOD" = "LOCAL" ]
then
    POL_SetupWindow_browse "$(eval_gettext 'Please select the installation file to run.')" "$TITLE"
    POL_SetupWindow_message "$(eval_gettext 'On the next page installation of Octgn will begin. You MUST launch AND CLOSE Octgn before continuing. If you do not then your install will be broken and need to be reinstalled.')" "$TITLE"
    POL_Wine_WaitBefore "$TITLE"
    POL_Wine "$APP_ANSWER"
    POL_Wine_WaitExit "$TITLE"
elif [ "$INSTALL_METHOD" = "DOWNLOAD" ]
then
    cd "$POL_System_TmpDir"
    POL_Download "https://s3.amazonaws.com/octgn/releases/live/$CURVERSION"
    POL_Wine_WaitBefore "$TITLE"
    POL_Wine "$POL_System_TmpDir/$CURVERSION"
    POL_Wine_WaitExit "$TITLE"
fi

# modify settings.json to turn hardware acceleration off.
cd "$INSTALLDIR/Config/"
cp settings.json settings.json.bak
sed -e 's/"UseHardwareRendering": true/"UseHardwareRendering": false/' settings.json.bak > settings.json
POL_Wine_WaitExit "$TITLE"

# Build launchers
POL_Shortcut "OCTGN.exe" "Octgn"

# close up shop
POL_System_TmpDelete
POL_SetupWindow_Close
exit

petch Mercredi 5 Mars 2014 à 20:31
petch


If they don't have a fixed URL, that may require some web scraping (analyze the web page to get the current URL)
That can be done with the same kind of tools, once the page source has been fetched with wget or curl. I can't think of many scripts doing that though, it's a bit advanced (and brittle).
Among "function" scripts I can think of POL_GoG_download
lines 52 and 55, but that's probably not the simplest example...
gotsanity Vendredi 7 Mars 2014 à 6:57
gotsanityAnonymous

I have the latest version detection coded. After talking with the devs for the octgn project they mentioned they have a static file on github that posts the versioning information in an easy to scrape manner. Version control is 100% a go now.

I am running into a major issue with mac compatability however. It seems that for mac users there is an issue with installing the dotnet40 and vcrun2010 libraries. Both libraries crash with "Fatal Error in setup.exe" during their respective install step of the script. The rest of the script installs without error but the program will crash on startup (debug info shows a crash due to missing dotnet libraries). Any ideas as to whats going on? I don't have a mac to test this on personaly so its a bit hard for me to debug. So far its been 100% crashing on mac users (ive had 7 users all report the same results)
thehexer Jeudi 1 Mai 2014 à 21:42
thehexerAnonymous

Does not work for me. I just see a black window after OCTGN checks for updates.

Edit: Fixed by setting "IgnoreSSLCertificates" to true in setting.json.

Edité par thehexer

markingdude Samedi 3 Mai 2014 à 0:17
markingdudeAnonymous


I am running into a major issue with mac compatability however. It seems that for mac users there is an issue with installing the dotnet40 and vcrun2010 libraries. Both libraries crash with "Fatal Error in setup.exe" during their respective install step of the script. The rest of the script installs without error but the program will crash on startup (debug info shows a crash due to missing dotnet libraries). Any ideas as to whats going on? I don't have a mac to test this on personaly so its a bit hard for me to debug. So far its been 100% crashing on mac users (ive had 7 users all report the same results)

Quote from gotsanity

See if putting this in before installing vcrun2010 and dotnet40 will help for Mac users:

[code language=playonlinux]POL_Call POL_Install_msxml3[/code]

I ran into this issue when installing Steins;Gate, which requires vcrun2010 in order to install the VN. I had a feeling this issue is exclusive to Mac users for some reason. I would also like to note that this started with Wine version 1.7.12 when Mac Driver (the native video graphics feature) started being supported.

Edité par markingdude

geppoz Mardi 16 September 2014 à 11:44
geppozAnonymous

Hello everybody,

anyone succesfull installed latest version of Octgn?

Thanks

Vous êtes ici: Index > Your creations. > [script] Octgn

This site allows content generated by members, and we promptly remove any content that infringes copyright according to our Terms of Service. To report copyright infringement, please send a notice to dmca-notice@playonlinux.com