- 
                Notifications
    You must be signed in to change notification settings 
- Fork 11
          build: fix doinst.sh compatibility with installpkg --root
          #1446
        
          New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
          
     Merged
      
      
    
  
     Merged
                    Changes from all commits
      Commits
    
    
            Show all changes
          
          
            21 commits
          
        
        Select commit
          Hold shift + click to select a range
      
      8c0b1c3
              
                build: update doinst during build-plugin step
              
              
                pujitm 27b31f2
              
                rm log debugging from doinst
              
              
                pujitm c1e4e77
              
                rm redudant `chmod +x` in doinst
              
              
                pujitm ca5a959
              
                rm no-op remove hook??
              
              
                pujitm a9c3f3d
              
                port doinst.sh effects to plg file
              
              
                pujitm f9952ef
              
                rm `/boot` bc it gets overwritten anyway
              
              
                pujitm 02e3f3e
              
                move unraid-api symlink assurance to doinst
              
              
                pujitm 641801b
              
                port setup_api.sh
              
              
                pujitm f6408c6
              
                rm file_patches.sh
              
              
                pujitm 220272a
              
                fix symlink paths in doinst
              
              
                pujitm 894db4b
              
                move `NginxService` into api as global module dependency
              
              
                pujitm 544af5c
              
                init effect system in file modification module with nginx:reload
              
              
                pujitm 9152e9c
              
                add robots.txt modification
              
              
                pujitm 2b2cb71
              
                fix file modification test suite
              
              
                pujitm 4cb902c
              
                allow no-diff patches to succeed
              
              
                pujitm bdba118
              
                move legacy config dir migration to plg file
              
              
                pujitm ec9dfd8
              
                add an nginx conf modification just in case
              
              
                pujitm 1c7e528
              
                revert acceptance of 0 hunk patches??
              
              
                pujitm a79f583
              
                fix security scanner issue
              
              
                pujitm 224f27f
              
                add logging & error handling to file mod effects
              
              
                pujitm 7f01802
              
                drop `-r` flag from unraid-api deletion
              
              
                pujitm File filter
Filter by extension
Conversations
          Failed to load comments.   
        
        
          
      Loading
        
  Jump to
        
          Jump to file
        
      
      
          Failed to load files.   
        
        
          
      Loading
        
  Diff view
Diff view
There are no files selected for viewing
  
    
      This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
      Learn more about bidirectional Unicode characters
    
  
  
    
              
  
    
      This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
      Learn more about bidirectional Unicode characters
    
  
  
    
              
  
    
      This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
      Learn more about bidirectional Unicode characters
    
  
  
    
              
  
    
      This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
      Learn more about bidirectional Unicode characters
    
  
  
    
              | Original file line number | Diff line number | Diff line change | 
|---|---|---|
| @@ -0,0 +1,12 @@ | ||
| import { Module } from '@nestjs/common'; | ||
|  | ||
| import { NginxService } from '@app/unraid-api/nginx/nginx.service.js'; | ||
|  | ||
| /** | ||
| * | ||
| */ | ||
| @Module({ | ||
| providers: [NginxService], | ||
| exports: [NginxService], | ||
| }) | ||
| export class NginxModule {} | 
            File renamed without changes.
          
    
  
    
      This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
      Learn more about bidirectional Unicode characters
    
  
  
    
              
        
          
          
            16 changes: 16 additions & 0 deletions
          
          16 
        
  api/src/unraid-api/unraid-file-modifier/file-modification-effect.service.ts
  
  
      
      
   
        
      
      
    
  
    
      This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
      Learn more about bidirectional Unicode characters
    
  
  
    
              | Original file line number | Diff line number | Diff line change | 
|---|---|---|
| @@ -0,0 +1,16 @@ | ||
| import { Injectable } from '@nestjs/common'; | ||
|  | ||
| import { NginxService } from '@app/unraid-api/nginx/nginx.service.js'; | ||
| import { ModificationEffect } from '@app/unraid-api/unraid-file-modifier/file-modification.js'; | ||
|  | ||
| @Injectable() | ||
| export class FileModificationEffectService { | ||
| constructor(private readonly nginxService: NginxService) {} | ||
| async runEffect(effect: ModificationEffect): Promise<void> { | ||
| switch (effect) { | ||
| case 'nginx:reload': | ||
| await this.nginxService.reload(); | ||
| break; | ||
| } | ||
| } | ||
| } | 
  
    
      This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
      Learn more about bidirectional Unicode characters
    
  
  
    
              
        
          
          
            28 changes: 28 additions & 0 deletions
          
          28 
        
  api/src/unraid-api/unraid-file-modifier/modifications/hosts.modification.ts
  
  
      
      
   
        
      
      
    
  
    
      This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
      Learn more about bidirectional Unicode characters
    
  
  
    
              | Original file line number | Diff line number | Diff line change | 
|---|---|---|
| @@ -0,0 +1,28 @@ | ||
| import { constants } from 'fs'; | ||
| import { access } from 'fs/promises'; | ||
| import { readFile } from 'node:fs/promises'; | ||
|  | ||
| import { | ||
| FileModification, | ||
| ShouldApplyWithReason, | ||
| } from '@app/unraid-api/unraid-file-modifier/file-modification.js'; | ||
|  | ||
| export default class HostsModification extends FileModification { | ||
| id: string = 'hosts'; | ||
| public readonly filePath: string = '/etc/hosts' as const; | ||
|  | ||
| protected async generatePatch(overridePath?: string): Promise<string> { | ||
| const originalContent = await readFile(this.filePath, 'utf8'); | ||
|  | ||
| // Use a case-insensitive word-boundary regex so the hostname must appear as an independent token | ||
| // prevents partial string & look-alike conflicts such as "keys.lime-technology.com.example.com" | ||
| const hostPattern = /\bkeys\.lime-technology\.com\b/i; | ||
|  | ||
| const newContent = originalContent | ||
| .split('\n') | ||
| .filter((line) => !hostPattern.test(line)) | ||
| .join('\n'); | ||
|  | ||
| return this.createPatchWithDiff(overridePath ?? this.filePath, originalContent, newContent); | ||
| } | ||
| } | 
        
          
          
            40 changes: 40 additions & 0 deletions
          
          40 
        
  api/src/unraid-api/unraid-file-modifier/modifications/nginx-conf.modification.ts
  
  
      
      
   
        
      
      
    
  
    
      This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
      Learn more about bidirectional Unicode characters
    
  
  
    
              | Original file line number | Diff line number | Diff line change | 
|---|---|---|
| @@ -0,0 +1,40 @@ | ||
| import { readFile } from 'node:fs/promises'; | ||
|  | ||
| import { | ||
| FileModification, | ||
| ShouldApplyWithReason, | ||
| } from '@app/unraid-api/unraid-file-modifier/file-modification.js'; | ||
|  | ||
| export default class NginxConfModification extends FileModification { | ||
| id: string = 'nginx-conf'; | ||
| public readonly filePath: string = '/etc/nginx/nginx.conf' as const; | ||
|  | ||
| protected async generatePatch(overridePath?: string): Promise<string> { | ||
| const originalContent = await readFile(this.filePath, 'utf8'); | ||
| const newContent = originalContent.replace( | ||
| "add_header X-Frame-Options 'SAMEORIGIN';", | ||
| 'add_header Content-Security-Policy "frame-ancestors \'self\' https://connect.myunraid.net/";' | ||
| ); | ||
| return this.createPatchWithDiff(overridePath ?? this.filePath, originalContent, newContent); | ||
| } | ||
|  | ||
| async shouldApply(): Promise<ShouldApplyWithReason> { | ||
| const superShouldApply = await super.shouldApply(); | ||
| if (!superShouldApply.shouldApply) { | ||
| return superShouldApply; | ||
| } | ||
| const content = await readFile(this.filePath, 'utf8'); | ||
| const hasSameOrigin = content.includes("add_header X-Frame-Options 'SAMEORIGIN';"); | ||
| if (!hasSameOrigin) { | ||
| return { | ||
| shouldApply: false, | ||
| reason: 'X-Frame-Options SAMEORIGIN header not found in nginx.conf', | ||
| }; | ||
| } | ||
| return { | ||
| shouldApply: true, | ||
| reason: 'X-Frame-Options SAMEORIGIN found and needs to be replaced with Content-Security-Policy', | ||
| effects: ['nginx:reload'], | ||
| }; | ||
| } | ||
| } | ||
  
    
      This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
      Learn more about bidirectional Unicode characters
    
  
  
    
              
        
          
          
            5 changes: 4 additions & 1 deletion
          
          5 
        
  api/src/unraid-api/unraid-file-modifier/unraid-file-modifier.module.ts
  
  
      
      
   
        
      
      
    
  
    
      This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
      Learn more about bidirectional Unicode characters
    
  
  
    
              | Original file line number | Diff line number | Diff line change | 
|---|---|---|
| @@ -1,8 +1,11 @@ | ||
| import { Module } from '@nestjs/common'; | ||
|  | ||
| import { NginxModule } from '@app/unraid-api/nginx/nginx.module.js'; | ||
| import { FileModificationEffectService } from '@app/unraid-api/unraid-file-modifier/file-modification-effect.service.js'; | ||
| import { UnraidFileModificationService } from '@app/unraid-api/unraid-file-modifier/unraid-file-modifier.service.js'; | ||
|  | ||
| @Module({ | ||
| providers: [UnraidFileModificationService], | ||
| imports: [NginxModule], | ||
| providers: [UnraidFileModificationService, FileModificationEffectService], | ||
| }) | ||
| export class UnraidFileModifierModule {} | 
  
    
      This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
      Learn more about bidirectional Unicode characters
    
  
  
    
              
  
    
      This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
      Learn more about bidirectional Unicode characters
    
  
  
    
              
  
    
      This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
      Learn more about bidirectional Unicode characters
    
  
  
    
              
      
      Oops, something went wrong.
        
    
  
      
      Oops, something went wrong.
        
    
  
  Add this suggestion to a batch that can be applied as a single commit.
  This suggestion is invalid because no changes were made to the code.
  Suggestions cannot be applied while the pull request is closed.
  Suggestions cannot be applied while viewing a subset of changes.
  Only one suggestion per line can be applied in a batch.
  Add this suggestion to a batch that can be applied as a single commit.
  Applying suggestions on deleted lines is not supported.
  You must change the existing code in this line in order to create a valid suggestion.
  Outdated suggestions cannot be applied.
  This suggestion has been applied or marked resolved.
  Suggestions cannot be applied from pending reviews.
  Suggestions cannot be applied on multi-line comments.
  Suggestions cannot be applied while the pull request is queued to merge.
  Suggestion cannot be applied right now. Please check back later.
  
    
  
    
Uh oh!
There was an error while loading. Please reload this page.