inst-resources/apacheconfig.nsh
author Dan
Tue, 08 Dec 2009 02:25:33 -0500
changeset 6 6016fd9e848f
parent 3 0cce88c7cf7c
permissions -rw-r--r--
A couple minor fixes: more flexible version numbering; added a CreateDirectory before uninstaller generation (whoops)
Ignore whitespace changes - Everywhere: Within whitespace: At end of lines:
0
67e1cc6cd929 First commit. It's working!
Dan
parents:
diff changeset
     1
/**
3
0cce88c7cf7c Added Makefile
Dan
parents: 0
diff changeset
     2
 * Search the Apache configuration for the Include line for Apache settings.
0
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"
3
0cce88c7cf7c Added Makefile
Dan
parents: 0
diff changeset
    47
FileClose $0
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
3
0cce88c7cf7c Added Makefile
Dan
parents: 0
diff changeset
    74
FunctionEnd
0cce88c7cf7c Added Makefile
Dan
parents: 0
diff changeset
    75
0cce88c7cf7c Added Makefile
Dan
parents: 0
diff changeset
    76
; Remove from Apache config upon uninstall
0cce88c7cf7c Added Makefile
Dan
parents: 0
diff changeset
    77
Function un.disable_in_apache_config
0cce88c7cf7c Added Makefile
Dan
parents: 0
diff changeset
    78
  StrCpy $0 "$stack_instdir\apache2\conf\httpd.conf"
0cce88c7cf7c Added Makefile
Dan
parents: 0
diff changeset
    79
  ClearErrors
0cce88c7cf7c Added Makefile
Dan
parents: 0
diff changeset
    80
  FileOpen $1 $0 "r"
0cce88c7cf7c Added Makefile
Dan
parents: 0
diff changeset
    81
  
0cce88c7cf7c Added Makefile
Dan
parents: 0
diff changeset
    82
  ; input file
0cce88c7cf7c Added Makefile
Dan
parents: 0
diff changeset
    83
  IfErrors 0 +3
0cce88c7cf7c Added Makefile
Dan
parents: 0
diff changeset
    84
    Push 1
0cce88c7cf7c Added Makefile
Dan
parents: 0
diff changeset
    85
    Return
0cce88c7cf7c Added Makefile
Dan
parents: 0
diff changeset
    86
  
0cce88c7cf7c Added Makefile
Dan
parents: 0
diff changeset
    87
  ; output file
0cce88c7cf7c Added Makefile
Dan
parents: 0
diff changeset
    88
  FileOpen $2 $0.tmp "w"
0cce88c7cf7c Added Makefile
Dan
parents: 0
diff changeset
    89
  IfErrors 0 +3
0cce88c7cf7c Added Makefile
Dan
parents: 0
diff changeset
    90
    Push 1
0cce88c7cf7c Added Makefile
Dan
parents: 0
diff changeset
    91
    Return
0cce88c7cf7c Added Makefile
Dan
parents: 0
diff changeset
    92
  
0cce88c7cf7c Added Makefile
Dan
parents: 0
diff changeset
    93
  ; read each line, if nothing to do with enano, pass through
0cce88c7cf7c Added Makefile
Dan
parents: 0
diff changeset
    94
  loop:
0cce88c7cf7c Added Makefile
Dan
parents: 0
diff changeset
    95
    ClearErrors
0cce88c7cf7c Added Makefile
Dan
parents: 0
diff changeset
    96
    FileRead $1 $3 1024
0cce88c7cf7c Added Makefile
Dan
parents: 0
diff changeset
    97
    IfErrors done
0cce88c7cf7c Added Makefile
Dan
parents: 0
diff changeset
    98
    Push $3
0cce88c7cf7c Added Makefile
Dan
parents: 0
diff changeset
    99
    Push "/apps/${PRODUCT_SHORTNAME}/"
0cce88c7cf7c Added Makefile
Dan
parents: 0
diff changeset
   100
    Call un.StrStr
0cce88c7cf7c Added Makefile
Dan
parents: 0
diff changeset
   101
    Pop $4
0cce88c7cf7c Added Makefile
Dan
parents: 0
diff changeset
   102
    StrCmp $4 "" 0 loop
0cce88c7cf7c Added Makefile
Dan
parents: 0
diff changeset
   103
      ; no mention of Enano, ok to write it
0cce88c7cf7c Added Makefile
Dan
parents: 0
diff changeset
   104
      FileWrite $2 $3
0cce88c7cf7c Added Makefile
Dan
parents: 0
diff changeset
   105
      Goto loop
0cce88c7cf7c Added Makefile
Dan
parents: 0
diff changeset
   106
    
0cce88c7cf7c Added Makefile
Dan
parents: 0
diff changeset
   107
  done:
0cce88c7cf7c Added Makefile
Dan
parents: 0
diff changeset
   108
    
0cce88c7cf7c Added Makefile
Dan
parents: 0
diff changeset
   109
  FileClose $1
0cce88c7cf7c Added Makefile
Dan
parents: 0
diff changeset
   110
  FileClose $2
0cce88c7cf7c Added Makefile
Dan
parents: 0
diff changeset
   111
  Delete "$0"
0cce88c7cf7c Added Makefile
Dan
parents: 0
diff changeset
   112
  Rename "$0.tmp" "$0"
0cce88c7cf7c Added Makefile
Dan
parents: 0
diff changeset
   113
  
0cce88c7cf7c Added Makefile
Dan
parents: 0
diff changeset
   114
  Push 0
0cce88c7cf7c Added Makefile
Dan
parents: 0
diff changeset
   115
FunctionEnd
0cce88c7cf7c Added Makefile
Dan
parents: 0
diff changeset
   116
0cce88c7cf7c Added Makefile
Dan
parents: 0
diff changeset
   117
; Remove from applications.html upon uninstall
0cce88c7cf7c Added Makefile
Dan
parents: 0
diff changeset
   118
Function un.disable_in_applications_html
0cce88c7cf7c Added Makefile
Dan
parents: 0
diff changeset
   119
  StrCpy $0 "$stack_instdir\apache2\htdocs\applications.html"
0cce88c7cf7c Added Makefile
Dan
parents: 0
diff changeset
   120
  ClearErrors
0cce88c7cf7c Added Makefile
Dan
parents: 0
diff changeset
   121
  FileOpen $1 $0 "r"
0cce88c7cf7c Added Makefile
Dan
parents: 0
diff changeset
   122
  
0cce88c7cf7c Added Makefile
Dan
parents: 0
diff changeset
   123
  ; State variable: are we in the Enano section or not?
0cce88c7cf7c Added Makefile
Dan
parents: 0
diff changeset
   124
  StrCpy $5 0
0cce88c7cf7c Added Makefile
Dan
parents: 0
diff changeset
   125
  
0cce88c7cf7c Added Makefile
Dan
parents: 0
diff changeset
   126
  ; input file
0cce88c7cf7c Added Makefile
Dan
parents: 0
diff changeset
   127
  IfErrors 0 +3
0cce88c7cf7c Added Makefile
Dan
parents: 0
diff changeset
   128
    Push 1
0cce88c7cf7c Added Makefile
Dan
parents: 0
diff changeset
   129
    Return
0cce88c7cf7c Added Makefile
Dan
parents: 0
diff changeset
   130
  
0cce88c7cf7c Added Makefile
Dan
parents: 0
diff changeset
   131
  ; output file
0cce88c7cf7c Added Makefile
Dan
parents: 0
diff changeset
   132
  FileOpen $2 $0.tmp "w"
0cce88c7cf7c Added Makefile
Dan
parents: 0
diff changeset
   133
  IfErrors 0 +3
0cce88c7cf7c Added Makefile
Dan
parents: 0
diff changeset
   134
    Push 1
0cce88c7cf7c Added Makefile
Dan
parents: 0
diff changeset
   135
    Return
0cce88c7cf7c Added Makefile
Dan
parents: 0
diff changeset
   136
  
0cce88c7cf7c Added Makefile
Dan
parents: 0
diff changeset
   137
  ; read each line, if nothing to do with enano, pass through
0cce88c7cf7c Added Makefile
Dan
parents: 0
diff changeset
   138
  loop:
0cce88c7cf7c Added Makefile
Dan
parents: 0
diff changeset
   139
    ClearErrors
0cce88c7cf7c Added Makefile
Dan
parents: 0
diff changeset
   140
    FileRead $1 $3 1024
0cce88c7cf7c Added Makefile
Dan
parents: 0
diff changeset
   141
    IfErrors done
0cce88c7cf7c Added Makefile
Dan
parents: 0
diff changeset
   142
    Push $3
0cce88c7cf7c Added Makefile
Dan
parents: 0
diff changeset
   143
    StrCmp $5 1 0 outsideblock
0cce88c7cf7c Added Makefile
Dan
parents: 0
diff changeset
   144
      ; inside of the block - don't write
0cce88c7cf7c Added Makefile
Dan
parents: 0
diff changeset
   145
      StrCpy $6 0
0cce88c7cf7c Added Makefile
Dan
parents: 0
diff changeset
   146
      Push "END BitNami ${PRODUCT_NAME} Module ${PRODUCT_SHORTNAME}"
0cce88c7cf7c Added Makefile
Dan
parents: 0
diff changeset
   147
      Call un.StrStr
0cce88c7cf7c Added Makefile
Dan
parents: 0
diff changeset
   148
      Pop $4
0cce88c7cf7c Added Makefile
Dan
parents: 0
diff changeset
   149
      StrCmp $4 "" +2
0cce88c7cf7c Added Makefile
Dan
parents: 0
diff changeset
   150
        ; found it - don't write this line, but set $5 to 0 so we write the next one
0cce88c7cf7c Added Makefile
Dan
parents: 0
diff changeset
   151
        StrCpy $5 0
0cce88c7cf7c Added Makefile
Dan
parents: 0
diff changeset
   152
      Goto loop
0cce88c7cf7c Added Makefile
Dan
parents: 0
diff changeset
   153
      outsideblock:
0cce88c7cf7c Added Makefile
Dan
parents: 0
diff changeset
   154
      Push "START BitNami ${PRODUCT_NAME} Module ${PRODUCT_SHORTNAME}"
0cce88c7cf7c Added Makefile
Dan
parents: 0
diff changeset
   155
      Call un.StrStr
0cce88c7cf7c Added Makefile
Dan
parents: 0
diff changeset
   156
      Pop $4
0cce88c7cf7c Added Makefile
Dan
parents: 0
diff changeset
   157
      StrCmp $4 "" +3
0cce88c7cf7c Added Makefile
Dan
parents: 0
diff changeset
   158
        ; found the start of the block - disable writes
0cce88c7cf7c Added Makefile
Dan
parents: 0
diff changeset
   159
        StrCpy $5 1
0cce88c7cf7c Added Makefile
Dan
parents: 0
diff changeset
   160
        Goto loop
0cce88c7cf7c Added Makefile
Dan
parents: 0
diff changeset
   161
        
0cce88c7cf7c Added Makefile
Dan
parents: 0
diff changeset
   162
      FileWrite $2 $3
0cce88c7cf7c Added Makefile
Dan
parents: 0
diff changeset
   163
      Goto loop
0cce88c7cf7c Added Makefile
Dan
parents: 0
diff changeset
   164
      
0cce88c7cf7c Added Makefile
Dan
parents: 0
diff changeset
   165
  done:
0cce88c7cf7c Added Makefile
Dan
parents: 0
diff changeset
   166
    
0cce88c7cf7c Added Makefile
Dan
parents: 0
diff changeset
   167
  FileClose $1
0cce88c7cf7c Added Makefile
Dan
parents: 0
diff changeset
   168
  FileClose $2
0cce88c7cf7c Added Makefile
Dan
parents: 0
diff changeset
   169
  Delete "$0"
0cce88c7cf7c Added Makefile
Dan
parents: 0
diff changeset
   170
  Rename "$0.tmp" "$0"
0cce88c7cf7c Added Makefile
Dan
parents: 0
diff changeset
   171
  
0cce88c7cf7c Added Makefile
Dan
parents: 0
diff changeset
   172
  Delete "$stack_instdir\apache2\htdocs\img\${PRODUCT_SHORTNAME}-module.png"
0cce88c7cf7c Added Makefile
Dan
parents: 0
diff changeset
   173
  
0cce88c7cf7c Added Makefile
Dan
parents: 0
diff changeset
   174
  Push 0
0
67e1cc6cd929 First commit. It's working!
Dan
parents:
diff changeset
   175
FunctionEnd