inst-resources/kickstart.nsh
changeset 0 67e1cc6cd929
child 3 0cce88c7cf7c
equal deleted inserted replaced
-1:000000000000 0:67e1cc6cd929
       
     1 ; Now we're going to put the kickstart code into a separate file and try to keep it
       
     2 ; as clean and human-readable as possible.
       
     3 
       
     4 !macro kickstart_var Var Value
       
     5   ${str_replace} $1 "$$" "\$$" "${Value}"
       
     6   FileWrite $0 "$$${Var} = <<<EOF$\r$\n$1$\r$\nEOF;$\r$\n$\r$\n"
       
     7 !macroend
       
     8 !macro kickstart_int Var Value
       
     9   FileWrite $0 "$$${Var} = ${Value};$\r$\n"
       
    10 !macroend
       
    11 !define "kickstart_var" "!insertmacro kickstart_var"
       
    12 !define "kickstart_int" "!insertmacro kickstart_int"
       
    13 
       
    14 Function enano_write_kickstart_script
       
    15   CreateDirectory "$INSTDIR\apps\enanocms\scripts"
       
    16   ClearErrors
       
    17   FileOpen $0 "$INSTDIR\apps\enanocms\scripts\kickstart.php" "w"
       
    18   IfErrors 0 +4
       
    19     Push "open the kickstart file"
       
    20     Call ks_error
       
    21     Return
       
    22 
       
    23   FileWrite $0 "<?php$\r$\n// Automatically generated kickstart script.$\r$\n$\r$\n"
       
    24 
       
    25   ${kickstart_int} "silent" "true"
       
    26   ${kickstart_var} "lang_id" "eng"
       
    27   ${kickstart_var} "scriptpath" "/${PRODUCT_SHORTNAME}"
       
    28 
       
    29   ${kickstart_var} "driver" "$db_driver"
       
    30   ${kickstart_var} "dbhost" "localhost"
       
    31   ${kickstart_int} "dbport" "$db_port"
       
    32   ${kickstart_var} "dbuser" "$db_user"
       
    33   ${kickstart_var} "dbpasswd" "$db_password"
       
    34   ${kickstart_var} "dbname" "$db_name"
       
    35   ${kickstart_var} "db_prefix" "enano_"
       
    36   ${kickstart_var} "user" "$enano_user"
       
    37   ${kickstart_var} "pass" "$enano_password"
       
    38   ${kickstart_var} "email" "$admin_email"
       
    39   ${kickstart_var} "sitename" "$site_name"
       
    40   ${kickstart_var} "sitedesc" "$site_desc"
       
    41   ${kickstart_var} "copyright" "$site_copyright"
       
    42   ${kickstart_var} "urlscheme" "$url_scheme"
       
    43   ${kickstart_var} "start_with" "$start_with"
       
    44   
       
    45   FileWrite $0 "$\r$\nrequire(dirname(__FILE__) . '/../htdocs/install/includes/cli-core.php');"
       
    46   FileClose $0
       
    47 
       
    48 FunctionEnd
       
    49 
       
    50 Function enano_run_kickstart_script
       
    51   ; Debug :)
       
    52   ; ExecWait '"$SYSDIR\notepad.exe" "$INSTDIR\apps\enanocms\scripts\kickstart.php"'
       
    53   DetailPrint "Installing $(^Name) database"
       
    54   nsExec::ExecToLog '"$INSTDIR\php\php.exe" "$INSTDIR\apps\enanocms\scripts\kickstart.php"'
       
    55 FunctionEnd
       
    56 
       
    57 Function ks_error
       
    58   Pop $0
       
    59   MessageBox MB_OK|MB_ICONEXCLAMATION "Setup failed to $0. You will need to install $(^Name) manually. To do this, navigate to:$\r$\n$\r$\n    http://localhost/apps/${PRODUCT_SHORTNAME}/$\r$\n$\r$\nYou will be presented with a screen that will allow you to continue the $(^Name) installation.$\r$\n$\r$\nYour database information is:$\r$\n$\r$\n  Server type: $db_dbmsname$\r$\n  Hostname: localhost$\r$\n  Port: $db_port$\r$\n  Database name: $db_name$\r$\n  Database user: $db_user$\r$\n  Database password: $db_password"
       
    60   Abort "Could not $0!"
       
    61 FunctionEnd