From cdebbbfc8162ab579a18e9afd7ec0bdf2d1649d3 Mon Sep 17 00:00:00 2001 From: GDC-Teknisk Date: Sat, 24 Aug 2024 18:57:10 +0200 Subject: [PATCH] [ADDED] more pages --- wiki/Writerside/in.tree | 5 +- .../topics/Bloker-webside-lokalt.md | 56 ++++++++- wiki/Writerside/topics/Git-setup.md | 3 - wiki/Writerside/topics/Github-repositories.md | 18 +++ wiki/Writerside/topics/Install-Script.md | 3 - .../Setup-af-ny-windows-installation.md | 110 ++++++++++++++++++ wiki/Writerside/topics/Unity-project.md | 4 +- wiki/Writerside/topics/Windows-ISO.md | 6 + 8 files changed, 195 insertions(+), 10 deletions(-) delete mode 100644 wiki/Writerside/topics/Git-setup.md create mode 100644 wiki/Writerside/topics/Github-repositories.md delete mode 100644 wiki/Writerside/topics/Install-Script.md create mode 100644 wiki/Writerside/topics/Setup-af-ny-windows-installation.md create mode 100644 wiki/Writerside/topics/Windows-ISO.md diff --git a/wiki/Writerside/in.tree b/wiki/Writerside/in.tree index 7b0aad8..ba3af2e 100644 --- a/wiki/Writerside/in.tree +++ b/wiki/Writerside/in.tree @@ -8,9 +8,10 @@ + + + - - diff --git a/wiki/Writerside/topics/Bloker-webside-lokalt.md b/wiki/Writerside/topics/Bloker-webside-lokalt.md index b5620ca..665babc 100644 --- a/wiki/Writerside/topics/Bloker-webside-lokalt.md +++ b/wiki/Writerside/topics/Bloker-webside-lokalt.md @@ -1,3 +1,57 @@ # Bloker webside lokalt -Start typing here... \ No newline at end of file +For at kunne køre powershell scripts på en windows computer skal det slås til ved at køre denne kommando med administrator rettigheder. + +```Shell +Set-ExecutionPolicy RemoteSigned -Scope CurrentUser +``` + +Det følgende script har 5 dele: +1. Sti til hosts fil +2. Funktion der tilføjer domæner til hosts filen +3. Liste af domæner som skal blokkeres +4. Ip adresse som domæner skal omdirigeres til +5. Løkke som blokkerer domæner + +```Shell +# Define the path to the hosts file +$hostsFilePath = "$env:SystemRoot\System32\drivers\etc\hosts" + +# Function to add a domain to the hosts file +function Add-DomainToHostsFile { + param ( + [string]$ipAddress, + [string]$domain + ) + + # Check if the entry already exists + $entry = "$ipAddress`t$domain" + $hostsFileContent = Get-Content -Path $hostsFilePath + if ($hostsFileContent -contains $entry) { + Write-Output "Entry '$entry' already exists in the hosts file." + } else { + # Add the new entry + try { + Add-Content -Path $hostsFilePath -Value $entry + Write-Output "Entry '$entry' has been added to the hosts file." + } catch { + Write-Error "Failed to add entry '$entry' to the hosts file. Error: $_" + } + } +} + +# List of domains to block +$domainsToBlock = @( + "www.roblox.com", + "www.netflix.com" +) + +# IP address to redirect the domains to (localhost) +$blockIpAddress = "127.0.0.1" + +# Block each domain +foreach ($domain in $domainsToBlock) { + Add-DomainToHostsFile -ipAddress $blockIpAddress -domain $domain +} +``` +{collapsible="true" collapsed-title="block-domains.ps1"} \ No newline at end of file diff --git a/wiki/Writerside/topics/Git-setup.md b/wiki/Writerside/topics/Git-setup.md deleted file mode 100644 index d9714d6..0000000 --- a/wiki/Writerside/topics/Git-setup.md +++ /dev/null @@ -1,3 +0,0 @@ -# Git setup - -Start typing here... \ No newline at end of file diff --git a/wiki/Writerside/topics/Github-repositories.md b/wiki/Writerside/topics/Github-repositories.md new file mode 100644 index 0000000..4e320c0 --- /dev/null +++ b/wiki/Writerside/topics/Github-repositories.md @@ -0,0 +1,18 @@ +# Git repositories + +Deltagernes repositories har følgende struktur, se evt [repositories](https://github.com/UNFDanmark) fra tidligere år + + +```Bash +GDC2024-GR1 +├── 2D +│   └── Ting fra 2D +├── 3D +│   └── Ting fra 3D +├── Lyd +│   └── Ting fra lyd +├── README.md +└── TheUnityProject + ├── .gitignore + └── Unity filer og mapper +``` diff --git a/wiki/Writerside/topics/Install-Script.md b/wiki/Writerside/topics/Install-Script.md deleted file mode 100644 index 8a4b01b..0000000 --- a/wiki/Writerside/topics/Install-Script.md +++ /dev/null @@ -1,3 +0,0 @@ -# Install Script - -Start typing here... \ No newline at end of file diff --git a/wiki/Writerside/topics/Setup-af-ny-windows-installation.md b/wiki/Writerside/topics/Setup-af-ny-windows-installation.md new file mode 100644 index 0000000..a90b58d --- /dev/null +++ b/wiki/Writerside/topics/Setup-af-ny-windows-installation.md @@ -0,0 +1,110 @@ +# Setup af ny windows installation + +Dette dokument indeholder PowerShell-scripts til at opsætte en ny bruger, installere nødvendige programmer og konfigurere Git for GDC-deltagere. + +## Oprettelse af ny bruger + +Dette script opretter en ny standardbruger med navnet "Deltager" uden administratorrettigheder og uden kodeord. + +```Bash +# Create new user account without admin privileges and no password +try { + $username = "Deltager" + New-LocalUser -Name $username -FullName "Deltager" -Description "Standard user for GDC" + + # Add the new user to the 'Users' group (standard user, not admin) + Add-LocalGroupMember -Group "Brugere" -Member $username + + Write-Host "User $username created and configured successfully." +} catch { + Write-Host "Error creating user: $_" +} +``` +{collapsible="true" collapsed-title="create-limited-user.ps1"} + +## Installér nødvendige programmer + +Dette script installerer de programmer, der er nødvendige for GDC ved brug af winget. + +```Bash +# Function to install applications +function Install-App($appName, $appSource) { + try { + $listApp = winget list --exact -q $appName + if (![String]::Join("", $listApp).Contains($appName)) { + Write-Host "Installing: $appName" + if ($appSource -ne $null) { + winget install --exact --silent $appName --source $appSource --accept-package-agreements + } else { + winget install --exact --silent $appName --accept-package-agreements + } + } else { + Write-Host "Skipping Install of $appName" + } + } catch { + Write-Host "Error installing $appName: $_" + } +} + +# List of apps to install +$apps = @( + @{name = "Unity.Unity.2022"}, + @{name = "Unity.UnityHub"}, + @{name = "JetBrains.Rider"}, + @{name = "BlenderFoundation.Blender"}, + @{name = "KDE.Krita"}, + @{name = "Audacity.Audacity"}, + @{name = "Git.Git"}, + @{name = "GitHub.GitHubDesktop"}, + @{name = "GitHub.cli"}, + @{name = "BrunoBanelli.PCI-Z"}, + @{name = "Google.Chrome"} +) + +# Install new apps +foreach ($app in $apps) { + Install-App -appName $app.name -appSource $null +} +``` + +{collapsible="true" collapsed-title="install-apps.ps1"} + +## Git Setup + +Dette script opsætter Git for deltageren ved at klone nødvendige repositories og konfigurere Git-brugeren. +```Bash +# Define constants +$year = "2024" +$githubAccountName = "GDC-Teknisk" +$githubKey = "ghp_xxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxx" # Generate a new key each year + +# Prompt for group number +Write-Host -NoNewline "Enter group number: " +$key_pressed = ([System.Management.Automation.Host.KeyInfo]$Host.UI.RawUI.ReadKey([System.Management.Automation.Host.ReadKeyOptions]::IncludeKeyDown)).Character; +Write-Host "" + +# Clone repositories +try { + Set-Location C:\Users\GDC\Desktop + $git_repo = "https://github.com/UNFDanmark/GDC$year-GR" + $key_pressed + git clone $git_repo + git clone "https://github.com/UNFDanmark/GDC$year-TeachingProgramming" + Write-Host "Repositories cloned successfully" +} catch { + Write-Host "Error cloning repositories: $_" +} + +# Configure git user +$mail = "teknisk+GDC$year-GR" + $key_pressed + "@game.unf.dk" +try { + git config --global user.email $mail + git config --global user.name "Deltager" + git credential-manager configure + git config --global url."https://$githubAccountName:$githubKey@github.com".insteadOf "https://github.com" + Write-Host "Git user configured successfully" +} catch { + Write-Host "Error configuring git: $_" +} + +``` +{collapsible="true" collapsed-title="setup-git.ps1"} \ No newline at end of file diff --git a/wiki/Writerside/topics/Unity-project.md b/wiki/Writerside/topics/Unity-project.md index 7e9484d..518243e 100644 --- a/wiki/Writerside/topics/Unity-project.md +++ b/wiki/Writerside/topics/Unity-project.md @@ -1,3 +1,5 @@ # Unity project -Start typing here... \ No newline at end of file +Start typing here... + +Daniel help :( \ No newline at end of file diff --git a/wiki/Writerside/topics/Windows-ISO.md b/wiki/Writerside/topics/Windows-ISO.md new file mode 100644 index 0000000..9670cab --- /dev/null +++ b/wiki/Writerside/topics/Windows-ISO.md @@ -0,0 +1,6 @@ +# Windows ISO + +Den windows ISO som bruges under opsætning af computere skal gerne have en _ExecutionPolicy_ som tillader at man kan køre powershell scripts. +derudover skal winget være installeret og initialiseret hvis muligt. + +Dette vil gøre det meget nemmere at installere og opsætte programmerne \ No newline at end of file