Skip to content

Commit

Permalink
Add files via upload
Browse files Browse the repository at this point in the history
  • Loading branch information
WileC committed Mar 4, 2019
1 parent 7ccd005 commit 4c50080
Show file tree
Hide file tree
Showing 3 changed files with 159 additions and 0 deletions.
108 changes: 108 additions & 0 deletions FreetzTheBox.ps1
@@ -0,0 +1,108 @@
<#
.SYNOPSIS
Wrapper-Skript für PeterPawns EVA-Tools PowerShell-Skripte
.DESCRIPTION
PowerShell-Skript zum flashen von FRITZ!Boxen über den Bootloader
mittels der im freetz erstellten *.image.in-memory. oder kernel.image
Dieses Skript benötigt die EVA-Tools aus PeterPawns GitHup-Repository
.NOTES
Filename: FreetzTheBox.ps1
.EXAMPLE
NAND-Boxen
.\FreetzTheBox.ps1 -BoxType 3490 -ImageFile .\example.image.in-memory
NOR-Boxen
.\FreetzTheBox.ps1 -BoxType 4040 -ImageFile .\kernel.image
.PARAMTER BoxType
Der Name der Fritz!Box
.PARAMTER ImageFile
Die image-Datei, welche in den Bootloader der FRITZ!Box geschrieben werden soll. Vgl. hierzu "EXAMPLE"
.LINK
https://github.com/PeterPawn/YourFritz/tree/master/eva_tools
#>

#####################################################################


Param([Parameter(Mandatory = $True, Position = 0, HelpMessage = 'Fritz!Box-Type e.g. 3490')][int]$BoxType,
[Parameter(Mandatory = $True, Position = 1, HelpMessage = 'The imagefile to load in the bootloader')][string]$ImageFile
)

$NAND_Box = @(3390, 3490, 6820);
$NOR_Box = @(4040);
$Box_IP = '169.254.172.1';
$Flash_Type = '';

# Ist der Fritz!Box-Typ übergeben worden?
if (-not $BoxType)
{
Write-Error -Message "Fritz!Box-Typ nicht angegeben, ggf. Hilfe/Readme lesen!" -Category NotSpecified;
Exit 1;
}

# ist die Variable BoxType in den Arrays zu finden?
if (-not ($NAND_Box -match $BoxType) -and -not ($NOR_Box -match $BoxType))
{
Write-Error -Message "Der angegebene Fritz!Box-Typ wird derzeit nicht unterstützt" -Category InvalidData;
exit 1;
}

# Ist die Image-Datei angegeben worden und gibt es sie tatsächlich?
if (-not (Test-Path $ImageFile))
{
Write-Error -Message "Dateiname $ImageFile nicht gefunden!" -Category ObjectNotFound;
Exit 1;
}

# Übergebene Image-Datei in einen absoluten Pfad umwandeln
$ImageFile = Resolve-Path $ImageFile;

#########################################################
#
# Skript-Aufruf von .\EVA-Discover.ps1
#

Write-Output "Bitte die FRITZ!Box nun an den Strom anschliessen...";

if (-not (.\EVA-Discover.ps1 -maxWait 60 $Box_IP -Debug -Verbose))
{
Write-Error -Message "Keine FRITZ!Box gefunden!" -Category DeviceError;
Exit 1;
}


#########################################################
#
# Skript-Aufruf von .\EVA-FTP-Client.ps1
# für NAND-Boxen:

if ($NAND_Box -match $BoxType)
{
if (-not (.\EVA-FTP-Client.ps1 $Box_IP -ScriptBlock { BootDeviceFromImage $ImageFile } -Debug -Verbose))
{
Write-Error -Message "Es ist ein Fehler beim flashen der NAND-Box $BoxType aufgetreten!" -Category InvalidOperation;
Exit 1;
}
}

# für NOR-Boxen:

if ($NOR_Box -match $BoxType)
{
if (-not (.\EVA-FTP-Client.ps1 $Box_IP -ScriptBlock { UploadFlashFile $ImageFile mtd1 } -Debug -Verbose))
{
Write-Error -Message "Es ist ein Fehler beim flashen der NOR-Box $BoxType aufgetreten!" -Category InvalidOperation;
exit 1;
}
.\EVA-FTP-Client.ps1 $Box_IP -ScriptBlock { RebootTheDevice } -Debug -Verbose;
}

# Skript beenden
Exit 0;
33 changes: 33 additions & 0 deletions install.cmd
@@ -0,0 +1,33 @@
@echo off

REM Skript: install.cmd
REM Author: WileC
REM Web: http://www.djwilec.de
REM Infos: getestet mit Windows 10;
REM automatisierte Installation zur einfachen (Erst)-Installation von Freetz auf AVM-FritzBoxen
REM Unterstützte Boxen: 3490, 4040, 6820

REM Verzeichnis anlegen
mkdir FreetzTheBox

REM PowerShell-Skripte von PeterPawns GitHub herunterladen
curl --insecure --location --output FreetzTheBox/EVA-Discover.ps1 "https://github.com/PeterPawn/YourFritz/raw/master/eva_tools/EVA-Discover.ps1"
curl --insecure --location --output FreetzTheBox/EVA-FTP-Client.ps1 "https://github.com/PeterPawn/YourFritz/raw/master/eva_tools/EVA-FTP-Client.ps1"

REM Wrapper-Skript von WileC herunterladen
curl --insecure --location --output FreetzTheBox/FreetzTheBox.ps1 "http://freetz.d-jay.de/FreetzTheBox/FreetzTheBox.ps1

REM Uninstall-Skript von WileC herunterladen
curl --insecure --location --output uninstall.cmd "http://freetz.d-jay.de/FreetzTheBox/uninstall.cmd"

REM PowerShell-Skripte erlauben
powershell -command {Set-ExecutionPolicy -ExecutionPolicy Unrestricted -Scope CurrentUser -Force}
powershell -command {Unblock-File -Path .\FreetzTheBox\*.ps1}

echo.
echo.
echo "Für weitere Infos bitte README.TXT lesen!"
echo "Zur Deinstallation die UNINSTALL.CMD ausführen."
echo.

pause
18 changes: 18 additions & 0 deletions uninstall.cmd
@@ -0,0 +1,18 @@
@echo off

REM Skript: uninstall.cmd
REM Author: WileC
REM Web: http://www.djwilec.de
REM Infos: getestet mit Windows 10;
REM automatisierte Deinstallation der Skripte
REM Unterstützte Boxen: 3490, 4040, 6820

REM PowerShell-Skripte zurücksetzen
powershell -command {Set-ExecutionPolicy -ExecutionPolicy Default -Scope CurrentUser -Force}

REM Verzeichnis und Dateien entfernen
rmdir /S /Q .\FreetzTheBox
del install.cmd
del uninstall.cmd

pause

0 comments on commit 4c50080

Please sign in to comment.