-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathwin-cloud-sync.ps1
96 lines (75 loc) · 3.44 KB
/
win-cloud-sync.ps1
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
#requires -version 3
<#
.SYNOPSIS
Installs the win-cloud-sync service to synchronize a local path with the cloud.
.DESCRIPTION
This script will install a service called win-cloud-sync on your system."
There are two required components for this setup, namely rcloud and
nssm.
Rcloud is an utility that does the actual synchronizaiton of files
and directories, while nssm (The Non-Sucking Service Manager) installs,
configures, and runs rcloud at regular intervals.
win-cloud-sync is given a base directory and will by default do
the following:
$base\programs\rclone.exe - the rclone binary
$base\programs\nssm.exe - the nssm binary
$base\programs\win-cloud-sync.ps1 - this script
$base\data - data to synchronize
.PARAMETER BasePath
The local path to install to and sync.
.PARAMETER BasePath
The local path to install to and sync.
.INPUTS
-LocalPath to install.
-exeonly If you only want to deal with the exe.
-Temp Location to use for temp.
-beta To download the latest beta
.OUTPUTS
Outputs rclone version for verification
.NOTES
Author:Alexander Kjeldaas
.EXAMPLE
win-cloud-sync -location "d:\directory"
install-rclone -location "c:\rclone" -execonly $true -temp "c:\mytemp" -beta $true
#>
# This
# param ($ComputerName = $(throw "ComputerName parameter is required."))
param (
[string]$location = $(Read-Host "Location where I should put executables [ default: C:\\Hogia\\Queue\\AstoraiProgram ]"),
[ValidateScript({
if( -Not ($_ | Test-Path) ){
throw "File does not exist"
}
return $true
})]
[System.IO.FileInfo]$serviceAccountFile = $(Read-Host "Path to the service_account_file.txt"),
[System.IO.FileInfo]$emiInputFolder = $(Read-Host "EMI input folder (to be processed locally) [ default: C:\\Hogia\\Queue\\AstoraiIn ]""),
[System.IO.FileInfo]$emiOutputFolder = $(Read-Host "EMI output folder (to be processed externally) [ default: C:\\Hogia\\Queue\\AstoraiUt ]"),
[System.IO.FileInfo]$emiGlobalInputFolder = $(Read-Host "EMI global input folder [ default: C:\\Hogia\\Queue\\MobilastMove ]"),
[System.IO.FileInfo]$clientName = $(Read-Host "Short client name representing your company")
)
# write-host "This script will install a service called win-cloud-sync on your system."
# write-host "The win-cloud-sync This script will install a service called win-cloud-sync on your system"
if ($location -eq "") {
$location = [IO.Path]::Combine("C:\\", "Hogia", "Queue", "AstoraiProgram")
}
if ($serviceAccountFile -eq "") {
$serviceAccountFile = Resolve-Path "." "service_account_file.txt"
}
if ($emiInputFolder -eq "") {
$emiInputFolder = [IO.Path]::Combine("C:\\", "Hogia", "Queue", "AstoraiIn")
}
if ($emiOutputFolder -eq "") {
$emiOutputFolder = [IO.Path]::Combine("C:\\", "Hogia", "Queue", "AstoraiUt")
}
if ($emiGlobalInputFolder -eq "") {
$emiGlobalInputFolder = [IO.Path]::Combine("C:\\", "Hogia", "Queue", "MobilastMove")
}
Function install{
$scriptUrl = "https://raw.githubusercontent.com/alexanderkjeldaas/win-cloud-sync/master/lib.ps1"
write-host "Fetching and executing $scriptUrl"
$content = (Invoke-WebRequest -Uri $scriptUrl -Headers @{"Cache-Control"="no-cache"}).content
Invoke-Expression $content
DoIt -location $location -serviceAccountFile $serviceAccountFile -emiInputFolder $emiInputFolder -emiOutputFolder $emiOutputFolder -emiGlobalInputFolder $emiGlobalInputFolder -clientName $clientName
}
install