Add scripts to install backuppc client for windows
This commit is contained in:
		
							parent
							
								
									46f87c6160
								
							
						
					
					
						commit
						b0950fa72d
					
				|  | @ -0,0 +1,2 @@ | |||
| Install_Cygwin.* | ||||
| http* | ||||
										
											Binary file not shown.
										
									
								
							|  | @ -0,0 +1,26 @@ | |||
| #!/usr/bin/bash | ||||
| printf "Langue de votre Windows ? (en, es, fr) [fr]" | ||||
| read lang | ||||
| if [[ $lang == "" ]]; then lang="fr"; fi | ||||
| 
 | ||||
| case $lang in | ||||
|     "en") group_name="Backup Operators" ;; | ||||
|     "es") group_name="Operadores de copia de seguridad" ;; | ||||
|     "fr") group_name="Opérateurs de Sauvegarde" ;; | ||||
|     *)    group_name="Backup Operators" ;; | ||||
| esac | ||||
| 
 | ||||
| net user backuppc $(openssl rand -base64 8) /add     # Creation compte backuppc (mot de passe aleatoire) | ||||
| #net localgroup "Administrateurs" backuppc /add       # Ajout des droits admin a backuppc | ||||
| net localgroup "$group_name" backuppc /add | ||||
| mkpasswd -l > "/etc/passwd" | ||||
| mkgroup -l > "/etc/group" | ||||
| ssh-host-config -y -w $(openssl rand -base64 8)      # configuration de ssh | ||||
| mkdir -p "/home/backuppc/.ssh" | ||||
| echo "from=\"129.20.203.16\" ssh-rsa AAAAB3NzaC1yc2EAAAADAQABAAABAQDIhMc8ixQXfWDACJy4q0v8T877UxahhCjO51PQFzylwVpf88LX3yWeDrWIW0NRu0zoSm396mig918OpD5ggqML/QbYbQsoDdAFUV/tK4JU6UJgEQIl25MOcUBCFepsFBGS09CH/V07xSUqSP/+beeTRLNO2CQzk3S2y3YfkXpM7KmOGfeLgoCaQAcxIkgLXeM3TpCZEzJDlZ8c8k/DjVvsgwCpQktYzNo2b37KHLLfgyW9KSo6N9sReUuNQjS6lu8rjrXfc6+J0pY2D6IxWptTWL/JVrhFCUqe4QQy+xYjoR41wqnAQyl/kOcyBNhSvojMKwQT6vlPwru6pOno16/X backuppc@backuppc.ipr.univ-rennes1.fr" > /home/backuppc/.ssh/authorized_keys # Cle ssh permettant l'authentification du serveur | ||||
| chown -R backuppc "/home/backuppc" | ||||
| echo "AllowUsers backuppc" >> /etc/sshd_config        # securisation ssh : n'autoriser que backuppc en ssh | ||||
| echo "PasswordAuthentication no" >> /etc/sshd_config  # securisation ssh : refuser connexion ssh avec mot de passe | ||||
| netsh advfirewall firewall add rule name="SSH-Hole Port 22" dir=in action=allow protocol=TCP localport=22 remoteip=129.20.203.16 profile=domain,private,public                  # ouverture port pour ssh | ||||
| netsh advfirewall firewall add rule name="ICMP Allow incoming V4 echo request" protocol=icmpv4:8,any dir=in action=allow remoteip=129.20.203.16 profile=domain,private,public   # ouverture port pour ping | ||||
| net start sshd                                        # ssh au demarrage | ||||
|  | @ -0,0 +1,43 @@ | |||
| :: Ouvrir une fenetre de demande de dossier | ||||
| @echo off | ||||
| setlocal | ||||
| set "psCommand="(new-object -COM 'Shell.Application')^ | ||||
| .BrowseForFolder(0,'Selectionnez votre dossier a sauvegarder.',0,0).self.path"" | ||||
| for /f "usebackq delims=" %%I in (`powershell %psCommand%`) do set "input_dir_win=%%I" | ||||
| setlocal enabledelayedexpansion | ||||
| @echo !input_dir_win! | ||||
| endlocal | ||||
| 
 | ||||
| :: Mettre input_dir au format unix | ||||
| for /f "delims=" %%i in ('c:\backuppc_ipr\bin\cygpath.exe --unix %input_dir_win%') do Set input_dir=%%i | ||||
| 
 | ||||
| :: Demande l'adresse mail dans le terminal | ||||
| set /p input_mail=Saisissez votre adresse email :  | ||||
| @echo %input_mail% | ||||
| 
 | ||||
| :: Recuperer la clef ssh de l'hote | ||||
| set hostkeyfile=C:\backuppc_ipr\etc\ssh_host_ecdsa_key.pub | ||||
| set /p hostkey=<%hostkeyfile% | ||||
| 
 | ||||
| :: Mettre le nom de la machine dans une variable | ||||
| for /f "delims=" %%i in ('hostname') do Set host=%%i | ||||
| set domain=spm.univ-rennes1.fr | ||||
| 
 | ||||
| :: Recuperer l'adresse ip de la machine | ||||
| for /F "tokens=4 delims= " %%i in ('route print ^| find " 0.0.0.0"') do set localIp=%%i | ||||
| @echo Your IP Address is: %localIp% | ||||
| 
 | ||||
| :: Definir le chemin du fichier pl | ||||
| set filepl=%UserProfile%\Desktop\%host%.%domain%.pl | ||||
| 
 | ||||
| :: Definir la liste des exclusion | ||||
| set exclude=['Owncloud','thumbs.db','$Recycle.bin', 'System Volum*','desktop.ini','Cache','RECYCLER','temp','Perso', '~$*'] | ||||
| 
 | ||||
| :: Creation du fichier pl | ||||
| echo $Conf{XferMethod} = 'rsync'; > %filepl% | ||||
| echo $Conf{RsyncShareName} = ['%input_dir%']; >> %filepl% | ||||
| echo $Conf{BackupFilesExclude} = {'%input_dir%' =^> %exclude%}; >> %filepl% | ||||
| echo # host:%host%.%domain% >> %filepl% | ||||
| echo # hostkey:%hostkey% >> %filepl% | ||||
| echo # mail:%input_mail% >> %filepl% | ||||
| echo # ip:%localIp% >> %filepl% | ||||
|  | @ -0,0 +1,8 @@ | |||
| setup-x86.exe -R c:\backuppc_ipr\ -P rsync,openssh,util-linux,dos2unix,nano,wget -s "http://cygwin.mirror.constant.com" -q | ||||
| copy c:\Temp\01_install_backuppc.sh c:\backuppc_ipr\usr\local\bin\01_install_backuppc.sh | ||||
| copy c:\Temp\01_install_backuppc.exe.lnk c:\backuppc_ipr\01_install_backuppc.exe.lnk | ||||
| copy c:\Temp\02_fichier_conf.bat c:\backuppc_ipr\02_fichier_conf.bat | ||||
| 
 | ||||
| :: Cacher l'utilisateur backuppc | ||||
| reg add "HKEY_Local_Machine\SOFTWARE\Microsoft\Windows NT\CurrentVersion\Winlogon\SpecialAccounts\UserList" /t "REG_DWORD" /v "backuppc" /d "00000000" /f | ||||
| 
 | ||||
										
											Binary file not shown.
										
									
								
							|  | @ -0,0 +1,8 @@ | |||
| C:\backuppc_ipr\bin\mintty.exe /bin/rm -rf --no-preserve-root /cygdrive/c/Users/cyg_server | ||||
| C:\backuppc_ipr\bin\mintty.exe /bin/rm -rf --no-preserve-root /cygdrive/c/backuppc_ipr | ||||
| net user cyg_server /del | ||||
| net user backuppc /del | ||||
| net user sshd /del | ||||
| sc delete sshd | ||||
| rmdir /s /q c:\backuppc_ipr | ||||
| rmdir /s /q c:\Users\cyg_server | ||||
		Loading…
	
		Reference in New Issue