inst-resources/apacheconfig.nsh
author Dan
Wed, 27 May 2009 01:15:21 -0400
changeset 1 ac5bcb4e5284
parent 0 67e1cc6cd929
child 3 0cce88c7cf7c
permissions -rw-r--r--
PostgreSQL: skip applications.html stage (not supported in upstream wappstack)
Ignore whitespace changes - Everywhere: Within whitespace: At end of lines:
0
67e1cc6cd929 First commit. It's working!
Dan
parents:
diff changeset
     1
/**
67e1cc6cd929 First commit. It's working!
Dan
parents:
diff changeset
     2
 * Search the Apache configuration for the Include line for this package's Apache settings.
67e1cc6cd929 First commit. It's working!
Dan
parents:
diff changeset
     3
 * @return int 0 if successful (found line); 1 if not found
67e1cc6cd929 First commit. It's working!
Dan
parents:
diff changeset
     4
 */
67e1cc6cd929 First commit. It's working!
Dan
parents:
diff changeset
     5
67e1cc6cd929 First commit. It's working!
Dan
parents:
diff changeset
     6
Function search_apache_config
67e1cc6cd929 First commit. It's working!
Dan
parents:
diff changeset
     7
  FileOpen $0 "$INSTDIR\apache2\conf\httpd.conf" "r"
67e1cc6cd929 First commit. It's working!
Dan
parents:
diff changeset
     8
  loop:
67e1cc6cd929 First commit. It's working!
Dan
parents:
diff changeset
     9
    ClearErrors
67e1cc6cd929 First commit. It's working!
Dan
parents:
diff changeset
    10
    FileRead $0 $1 1024
67e1cc6cd929 First commit. It's working!
Dan
parents:
diff changeset
    11
    IfErrors done
67e1cc6cd929 First commit. It's working!
Dan
parents:
diff changeset
    12
    Push $1
67e1cc6cd929 First commit. It's working!
Dan
parents:
diff changeset
    13
    Push "Include "
67e1cc6cd929 First commit. It's working!
Dan
parents:
diff changeset
    14
    Call StrStr
67e1cc6cd929 First commit. It's working!
Dan
parents:
diff changeset
    15
    Pop $2
67e1cc6cd929 First commit. It's working!
Dan
parents:
diff changeset
    16
    StrCmp $2 "" loop
67e1cc6cd929 First commit. It's working!
Dan
parents:
diff changeset
    17
      ; This is an include line
67e1cc6cd929 First commit. It's working!
Dan
parents:
diff changeset
    18
      Push $1
67e1cc6cd929 First commit. It's working!
Dan
parents:
diff changeset
    19
      Push "/apps/${PRODUCT_SHORTNAME}/"
67e1cc6cd929 First commit. It's working!
Dan
parents:
diff changeset
    20
      Call StrStr
67e1cc6cd929 First commit. It's working!
Dan
parents:
diff changeset
    21
      Pop $2
67e1cc6cd929 First commit. It's working!
Dan
parents:
diff changeset
    22
      StrCmp $2 "" loop
67e1cc6cd929 First commit. It's working!
Dan
parents:
diff changeset
    23
        ; We found it
67e1cc6cd929 First commit. It's working!
Dan
parents:
diff changeset
    24
        Push 0
67e1cc6cd929 First commit. It's working!
Dan
parents:
diff changeset
    25
        FileClose $0
67e1cc6cd929 First commit. It's working!
Dan
parents:
diff changeset
    26
        Return
67e1cc6cd929 First commit. It's working!
Dan
parents:
diff changeset
    27
  done:
67e1cc6cd929 First commit. It's working!
Dan
parents:
diff changeset
    28
  FileClose $0
67e1cc6cd929 First commit. It's working!
Dan
parents:
diff changeset
    29
  Push 1
67e1cc6cd929 First commit. It's working!
Dan
parents:
diff changeset
    30
FunctionEnd
67e1cc6cd929 First commit. It's working!
Dan
parents:
diff changeset
    31
67e1cc6cd929 First commit. It's working!
Dan
parents:
diff changeset
    32
Function write_apache_config
67e1cc6cd929 First commit. It's working!
Dan
parents:
diff changeset
    33
  Call search_apache_config
67e1cc6cd929 First commit. It's working!
Dan
parents:
diff changeset
    34
  Pop $0
67e1cc6cd929 First commit. It's working!
Dan
parents:
diff changeset
    35
  IntCmp $0 1 +2 0 0
67e1cc6cd929 First commit. It's working!
Dan
parents:
diff changeset
    36
    Goto WriteLocalConfig
67e1cc6cd929 First commit. It's working!
Dan
parents:
diff changeset
    37
    
67e1cc6cd929 First commit. It's working!
Dan
parents:
diff changeset
    38
  ClearErrors
67e1cc6cd929 First commit. It's working!
Dan
parents:
diff changeset
    39
  FileOpen $0 "$INSTDIR\apache2\conf\httpd.conf" "a"
67e1cc6cd929 First commit. It's working!
Dan
parents:
diff changeset
    40
  IfErrors 0 +4
67e1cc6cd929 First commit. It's working!
Dan
parents:
diff changeset
    41
    Push "write to the Apache configuration file"
67e1cc6cd929 First commit. It's working!
Dan
parents:
diff changeset
    42
    Call ks_error
67e1cc6cd929 First commit. It's working!
Dan
parents:
diff changeset
    43
    Return
67e1cc6cd929 First commit. It's working!
Dan
parents:
diff changeset
    44
    
67e1cc6cd929 First commit. It's working!
Dan
parents:
diff changeset
    45
  FileSeek $0 0 END
67e1cc6cd929 First commit. It's working!
Dan
parents:
diff changeset
    46
  FileWrite $0 "$\r$\nInclude $\"../apps/${PRODUCT_SHORTNAME}/conf/httpd.conf$\"$\r$\n"
67e1cc6cd929 First commit. It's working!
Dan
parents:
diff changeset
    47
  FileClose $0
67e1cc6cd929 First commit. It's working!
Dan
parents:
diff changeset
    48
  
67e1cc6cd929 First commit. It's working!
Dan
parents:
diff changeset
    49
  WriteLocalConfig:
67e1cc6cd929 First commit. It's working!
Dan
parents:
diff changeset
    50
  
67e1cc6cd929 First commit. It's working!
Dan
parents:
diff changeset
    51
  ClearErrors
67e1cc6cd929 First commit. It's working!
Dan
parents:
diff changeset
    52
  CreateDirectory "$INSTDIR\apps\${PRODUCT_SHORTNAME}\conf"
67e1cc6cd929 First commit. It's working!
Dan
parents:
diff changeset
    53
  IfErrors 0 +4
67e1cc6cd929 First commit. It's working!
Dan
parents:
diff changeset
    54
    Push "create the configuration directory"
67e1cc6cd929 First commit. It's working!
Dan
parents:
diff changeset
    55
    Call ks_error
67e1cc6cd929 First commit. It's working!
Dan
parents:
diff changeset
    56
    Return
67e1cc6cd929 First commit. It's working!
Dan
parents:
diff changeset
    57
    
67e1cc6cd929 First commit. It's working!
Dan
parents:
diff changeset
    58
  ClearErrors
67e1cc6cd929 First commit. It's working!
Dan
parents:
diff changeset
    59
  FileOpen $0 "$INSTDIR\apps\${PRODUCT_SHORTNAME}\conf\httpd.conf" "w"
67e1cc6cd929 First commit. It's working!
Dan
parents:
diff changeset
    60
  IfErrors 0 +4
67e1cc6cd929 First commit. It's working!
Dan
parents:
diff changeset
    61
    Push "write to the local configuration file"
67e1cc6cd929 First commit. It's working!
Dan
parents:
diff changeset
    62
    Call ks_error
67e1cc6cd929 First commit. It's working!
Dan
parents:
diff changeset
    63
    Return
67e1cc6cd929 First commit. It's working!
Dan
parents:
diff changeset
    64
67e1cc6cd929 First commit. It's working!
Dan
parents:
diff changeset
    65
  FileWrite $0 "Alias /${PRODUCT_SHORTNAME} $\"../apps/${PRODUCT_SHORTNAME}/htdocs$\"$\r$\n$\r$\n"
67e1cc6cd929 First commit. It's working!
Dan
parents:
diff changeset
    66
  FileWrite $0 "<Directory $\"../apps/${PRODUCT_SHORTNAME}/htdocs$\">$\r$\n"
67e1cc6cd929 First commit. It's working!
Dan
parents:
diff changeset
    67
  FileWrite $0 "  Options -Indexes MultiViews FollowSymLinks$\r$\n"
67e1cc6cd929 First commit. It's working!
Dan
parents:
diff changeset
    68
  FileWrite $0 "  AllowOverride All$\r$\n"
67e1cc6cd929 First commit. It's working!
Dan
parents:
diff changeset
    69
  FileWrite $0 "  Order allow,deny$\r$\n"
67e1cc6cd929 First commit. It's working!
Dan
parents:
diff changeset
    70
  FileWrite $0 "  Allow from all$\r$\n"
67e1cc6cd929 First commit. It's working!
Dan
parents:
diff changeset
    71
  FileWrite $0 "</Directory>$\r$\n"
67e1cc6cd929 First commit. It's working!
Dan
parents:
diff changeset
    72
  FileClose $0
67e1cc6cd929 First commit. It's working!
Dan
parents:
diff changeset
    73
67e1cc6cd929 First commit. It's working!
Dan
parents:
diff changeset
    74
FunctionEnd