Ecosyste.ms: Awesome
An open API service indexing awesome lists of open source software.
https://github.com/uditgaurav/windows-service
https://github.com/uditgaurav/windows-service
Last synced: 18 days ago
JSON representation
- Host: GitHub
- URL: https://github.com/uditgaurav/windows-service
- Owner: uditgaurav
- Created: 2024-01-11T10:34:17.000Z (10 months ago)
- Default Branch: master
- Last Pushed: 2024-10-16T08:00:37.000Z (about 1 month ago)
- Last Synced: 2024-10-17T18:45:42.632Z (29 days ago)
- Language: PowerShell
- Size: 173 MB
- Stars: 0
- Watchers: 1
- Forks: 0
- Open Issues: 0
-
Metadata Files:
- Readme: README.md
Awesome Lists containing this project
README
# windows-service
#### Command to run the scripts
- For `install.ps1`
```bash
powershell -Command "& { Invoke-WebRequest -Uri 'https://raw.githubusercontent.com/uditgaurav/windows-service/master/bin/install.ps1' -OutFile 'install.ps1' -UseBasicParsing; .\install.ps1 -AdminPass 'Your Password' -InfraId 'YourInfraId' -AccessKey 'YourAccessKey' -ServerUrl 'YourServerUrl' -LogDirectory 'YourLogDirectory' -TaskPollIntervalSeconds 5 -TaskUpdateIntervalSeconds 5 -UpdateRetries 5 -UpdateRetryIntervalSeconds 5 -ChaosInfraLivenessUpdateIntervalSeconds 5 -ChaosInfraLogFileMaxSizeMb 5 -ChaosInfraLogFileMaxBackups 2 -CustomTlsCertificate 'YourCustomTlsCertificate' -HttpProxy 'YourHttpProxy' -HttpClientTimeout '30s' }"
```
- For `uninstall.ps1````bash
powershell -Command "& { Invoke-WebRequest -Uri 'https://raw.githubusercontent.com/uditgaurav/windows-service/master/bin/uninstall.ps1' -OutFile 'uninstall.ps1' -UseBasicParsing; .\uninstall.ps1 -ServiceName 'WindowsChaosInfrastructure' -TimeoutSeconds 180 -ChaosBaseDirectory 'C:\HCE' -CheckIntervalSeconds 10 }"
```
#### Create Binary```
GOOS=windows GOARCH=amd64 go buildwindows-service.exe*
```#### Launch Service On Windows
- Use Windows Service Control Manager to install the service
- https://learn.microsoft.com/en-us/windows/win32/services/service-control-manager
```
C:\Users\Administrator\Downloads>sc create WindowsChaosAgent binPath= "C:\Users\Administrator\Downloads\windows-chaos-agent.exe"
[SC] CreateService SUCCESSC:\Users\Administrator\Downloads>sc start WindowsChaosAgent
SERVICE_NAME: WindowsChaosAgent
TYPE : 10 WIN32_OWN_PROCESS
STATE : 2 START_PENDING
(NOT_STOPPABLE, NOT_PAUSABLE, IGNORES_SHUTDOWN)
WIN32_EXIT_CODE : 0 (0x0)
SERVICE_EXIT_CODE : 0 (0x0)
CHECKPOINT : 0x0
WAIT_HINT : 0x7d0
PID : 1980
FLAGS :
```#### Get the status of the service
```
C:\Users\Administrator\Downloads>sc query WindowsChaosAgentSERVICE_NAME: WindowsChaosAgent
TYPE : 10 WIN32_OWN_PROCESS
STATE : 4 RUNNING
(STOPPABLE, NOT_PAUSABLE, ACCEPTS_SHUTDOWN)
WIN32_EXIT_CODE : 0 (0x0)
SERVICE_EXIT_CODE : 0 (0x0)
CHECKPOINT : 0x0
WAIT_HINT : 0x0
```#### Delete the service
```
C:\Users\Administrator\Downloads>sc delete WindowsChaosAgent
[SC] DeleteService SUCCESS
```### TBD
- Batch script for installation of the service in Administrator mode.
- Pass flags to the service for input or override the chaos parameters.
- Proper event logging in windows eventviewer.
- Service Management - that is via manual trigger or system trigger.
- Once the agent is running it should be able to run the powershell script in administrator mode.
- Cleanup script.