Install AquaShell on Ubuntu via Docker

This script installs an AquaShell scripting environment on a Docker container with Ubuntu.

# Install AquaShell on a docker container using Ubuntu and WINE

require "dialog";
require "env";
require "fileio";
require "forms";

const AQUASHELL_VERSION string <= "1.0.2";
const UBUNTU_IMAGE_NAME string <= "ubuntu";

global szCurrentScriptPath string;
global szContainerName string;
global bRunWindow bool;
global bShallInstall bool;
global bIncludeSnippets bool;

getscriptpath szCurrentScriptPath;

function docker_image void(name string, image string)
{
    sys {docker run -dt --name "%name" %image};
};

function docker_exec void(container string, cmd string)
{
    sys {docker exec "%container" %cmd};
};

function docker_copy void(container string, source_file string, dest_file string)
{
    sys {docker cp "%source_file" %container:%dest_file};
};

function create_shellscript bool(container string)
{
    result false;

    local hShellScript int;
    local bFileOpened bool;

    fopen "%szCurrentScriptPath/aquashell.sh" false hShellScript;
    fisopen %hShellScript bFileOpened;
    if (%bFileOpened, -eq, true) {
        fwriteline %hShellScript "#!/bin/bash";
        fwriteline %hShellScript {WINEDEBUG=-all wine /opt/AquaShell/dnyAquaShell.exe "$@"};
        fclose %hShellScript;

        call docker_copy("%container", "%szCurrentScriptPathaquashell.sh", "/usr/local/bin/aquashell") => void;
        call docker_exec("%container", "chmod +x /usr/local/bin/aquashell") => void;
        call docker_exec("%container", "sed -i %QUOT_DOUBLEs/\r$//%QUOT_DOUBLE /usr/local/bin/aquashell") => void;

        fremove "%szCurrentScriptPath/aquashell.sh" void;

        result true;
    };
};

function copy_windows_tool void(container string, tool string)
{
    call docker_copy("%container", "%windir\System32\%tool", "/root/.wine/drive_c/windows/system32/%tool") => void;
};

function pull_snippets void(container string)
{
    call docker_exec("%container", "git clone https://github.com/danielbrendel/aquashell-snippets.git") => void;
    call docker_exec("%container", "cp -r /aquashell-snippets /opt/AquaShell/") => void;
    call docker_exec("%container", "cp /opt/AquaShell/scripts/init.dnys /opt/AquaShell/aquashell-snippets/init.dnys") => void;
    call docker_exec("%container", "cp /opt/AquaShell/scripts/unload.dnys /opt/AquaShell/aquashell-snippets/unload.dnys") => void;
    call docker_exec("%container", "rm -rf /opt/AquaShell/scripts") => void;
    call docker_exec("%container", "mv /opt/AquaShell/aquashell-snippets /opt/AquaShell/scripts") => void;
};

function btnInstall_OnClick void()
{
    set bShallInstall <= true;

    wnd_gettextboxtext frmMain txtContainerName szContainerName;
    wnd_cbischecked frmMain ckIncludeSnippets bIncludeSnippets;

    wnd_freeform frmMain;
};

function btnAbort_OnClick void()
{
    set bShallInstall <= false;

    wnd_freeform frmMain;
};

function CreateWindow void()
{
    local iWndStyles int;
    local bResult bool;
    local iTimestamp int;

    timestamp iTimestamp;
    
    bitop "or" (%WS_OVERLAPPED, %WS_SYSMENU, %WS_VISIBLE) iWndStyles;

    wnd_spawnform frmMain "AquaShell on Ubuntu@Docker" 500 400 635 222 %iWndStyles bResult;
    wnd_setformcentered frmMain;

    wnd_spawnlabel frmMain "lblContainerName" 20 10 550 30 "Container name";
    wnd_spawntextbox frmMain "txtContainerName" 20 40 550 20 "aquashell-docker-ubuntu-%iTimestamp";

    wnd_spawncheckbox frmMain "ckIncludeSnippets" 20 80 550 20 "Include snippet collection" true;

    wnd_spawnbutton frmMain "btnInstall" 20 135 200 30 "Install";
    wnd_spawnbutton frmMain "btnAbort" 400 135 200 30 "Abort";
};

call CreateWindow() => void;
set bRunWindow <= true;
set bShallInstall <= false;

while (%bRunWindow, -eq, true) {
    wnd_process;
    wnd_isformvalid frmMain bRunWindow;

    sleep 1;
};

if (%bShallInstall, -eq, false) {
    print "Aborted by user";
    exit;
};

print "Installing AquaShell: %szContainerName@%UBUNTU_IMAGE_NAME (include snippets = %bIncludeSnippets)";

call docker_image("%szContainerName", "%UBUNTU_IMAGE_NAME") => void;
call docker_exec("%szContainerName", "apt update") => void;
call docker_exec("%szContainerName", "apt install iputils-ping dnsutils net-tools iproute2 curl wget git nano zip unzip cron -y") => void;
call docker_exec("%szContainerName", "apt install wine -y") => void;
call docker_exec("%szContainerName", "dpkg --add-architecture i386 && apt-get update && apt-get install wine32:i386") => void;
call docker_exec("%szContainerName", "winecfg") => void;
call docker_exec("%szContainerName", "wine --version") => void;
call docker_exec("%szContainerName", "wget -O AquaShell.zip https://github.com/danielbrendel/dnyAquaShell/releases/download/v%AQUASHELL_VERSION/AquaShell_v%AQUASHELL_VERSION.zip") => void;
call docker_exec("%szContainerName", "unzip AquaShell.zip") => void;
call docker_exec("%szContainerName", "mkdir -p /opt/AquaShell") => void;
call docker_exec("%szContainerName", "cp -r /AquaShell /opt/") => void;
call docker_exec("%szContainerName", "truncate -s 0 /opt/AquaShell/scripts/init.dnys") => void;
call docker_exec("%szContainerName", "truncate -s 0 /opt/AquaShell/scripts/unload.dnys") => void;
call docker_exec("%szContainerName", "rm -f /opt/AquaShell/scripts/demo.dnys") => void;
call docker_exec("%szContainerName", "rm -f AquaShell.zip") => void;
call create_shellscript("%szContainerName") => void;
call copy_windows_tool("%szContainerName", "curl.exe") => void;

if (%bIncludeSnippets, -eq, true) {
    call pull_snippets("%szContainerName") => void;
};

call docker_exec("%szContainerName", "aquashell -v") => void;

Go back