Add local user for openvpn

This commit is contained in:
Mario Fetka 2014-02-25 11:03:53 +01:00
parent 5ced041013
commit db38968982
6 changed files with 141 additions and 38 deletions

View File

@ -71,6 +71,25 @@ endif
comment "Delete program shortcuts"
LinkFolder_uninstall
comment "Check if user exists."
set $ResultList2$ = getOutStreamFromSection("DosInAnIcon_checkuser")
set $UserExists$ = takeString(0,$ResultList2$)
set $UserExists$ = takeString(0,splitstring($UserExists$," "))
if $UserExists$ = "yes"
DosInAnIcon_deleteuser
else
LogError "User '" + $local_user$ + "' does not exist!"
isFatalError
endif
[DosInAnIcon_checkuser]
@echo off
net user openvpn >nul 2>&1 && echo yes || echo no
[DosInAnIcon_deleteuser]
NET USER openvpn /DELETE
[Winbatch_uninstall_old_32]
"$UninstallProgramOld32$" /S

View File

@ -25,8 +25,16 @@ DefVar $OLD_VERSION$
DefVar $OLD_CREATOR_TAG$
DefVar $OLD_RELEASE$
DefVar $openvpn_userpasswd$
DefVar $UserExists$
DefStringlist $ResultList$
DefStringlist $ResultList2$
Set $INST_SystemType$ = GetSystemType
set $INST_architecture$ = GetProductProperty("install_architecture","system specific")
Set $openvpn_userpasswd$ = RandomStr
Set $LogDir$ = "%SystemDrive%\tmp"
@ -71,6 +79,29 @@ else
Winbatch_install_cert
Sub_check_exitcode
comment "get the name of the admin group"
comment "using psgetsid from sysinernals pstools"
set $ResultList$ = getOutStreamFromSection("DosInAnIcon_get_admin_group")
set $Group$ = takeString(6,$ResultList$)
set $Group$ = takeString(1,splitstring($Group$,"\"))
comment "Check if user exists."
comment "If user exists, the password will be altered. Otherwise, the user will be created."
set $ResultList2$ = getOutStreamFromSection("DosInAnIcon_checkuser")
set $UserExists$ = takeString(0,$ResultList2$)
setLogLevel=0
comment "create our local user"
if $UserExists$ = "no"
DosInAnIcon_makeadmin
else
DosInAnIcon_alter_pw
endif
setLogLevel=3
comment "installing"
if (($INST_SystemType$ = "x86 System") and ($INST_architecture$ = "system specific")) or ($INST_architecture$ = "both") or ($INST_architecture$ = "32 only")
@ -84,7 +115,7 @@ else
comment "Patch Registry"
Registry_install /32Bit
comment "Create shortcuts"
LinkFolder_install
LinkFolder_install_32
endif
if ($INST_SystemType$ = "64 Bit System") and (($INST_architecture$ = "system specific") or ($INST_architecture$ = "both") or ($INST_architecture$ = "64 only"))
@ -98,16 +129,32 @@ else
comment "Patch Registry"
Registry_install /64Bit
comment "Create shortcuts"
LinkFolder_install
LinkFolder_install_64
endif
endif
[DosInAnIcon_get_admin_group]
@echo off
"%ScriptPath%\ALL\PsGetsid.exe" /accepteula S-1-5-32-544
[DosInAnIcon_checkuser]
@echo off
net user openvpn >nul 2>&1 && echo yes || echo no
[DosInAnIcon_makeadmin]
NET USER openvpn $openvpn_userpasswd$ /ADD /comment:"Local User created by OpenVPN opsi-package" /fullname:"Local User by Opsi OpenVPN" /passwordchg:no /passwordreq:yes /expires:never /active:yes
NET LOCALGROUP $Group$ /ADD openvpn
[DosInAnIcon_alter_pw]
NET USER openvpn $openvpn_userpasswd$
[Winbatch_install_cert]
certutil -addstore "TrustedPublisher" "%ScriptPath%\OpenVPN Certificate.cer"
certutil -addstore "TrustedPublisher" "%ScriptPath%\OpenVPN-Certificate.cer"
[Winbatch_install_32]
"$Install32Exe$" /S
"%ScriptPath%\ALL\CPAU.exe" -u openvpn -p $openvpn_userpasswd$ -ex "$InstallDir32$\bin\openvpn-gui.exe" -enc -file "$InstallDir32$\openvpn.job" -crc "$InstallDir32$\bin\openvpn-gui.exe"
[Files_install_32]
; copy the ini file to the InstallDir
@ -115,10 +162,11 @@ copy "$IniCfgFile$" "$InstallDir32$"
; Example of recursively copying some files into the installation directory:
;
; copy -s "%ScriptPath%\files\*.*" "$InstallDir32$"
copy -s "%ScriptPath%\ALL\CPAU.exe" "$InstallDir32$"
[Winbatch_install_64]
"$Install64Exe$" /S
"%ScriptPath%\ALL\CPAU.exe" -u openvpn -p $openvpn_userpasswd$ -ex "$InstallDir64$\bin\openvpn-gui.exe" -enc -file "$InstallDir64$\openvpn.job" -crc "$InstallDir64$\bin\openvpn-gui.exe"
[Files_install_64]
; copy the ini file to the InstallDir
@ -126,7 +174,7 @@ copy "$IniCfgFile$" "$InstallDir64$"
; Example of recursively copying some files into the installation directory:
;
; copy -s "%ScriptPath%\files\*.*" "$InstallDir64$"
copy -s "%ScriptPath%\ALL\CPAU.exe" "$InstallDir64$"
[Registry_install]
; Example of setting some values of an registry key:
@ -136,39 +184,55 @@ copy "$IniCfgFile$" "$InstallDir64$"
; set "name2" = REG_DWORD:0001
; set "name3" = REG_BINARY:00 af 99 cd
[LinkFolder_install]
; Example of deleting a folder from AllUsers startmenu:
;
; set_basefolder common_programs
; delete_subfolder $ProductId$
;
; Example of creating an shortcut to the installed exe in AllUsers startmenu:
;
; set_basefolder common_programs
; set_subfolder $ProductId$
;
; set_link
; name: $ProductId$
; target: <path to the program>
; parameters:
; working_dir: $InstallDir$
; icon_file:
; icon_index:
; end_link
;
; Example of creating an shortcut to the installed exe on AllUsers desktop:
;
; set_basefolder common_desktopdirectory
; set_subfolder ""
;
; set_link
; name: $ProductId$
; target: <path to the program>
; parameters: <some_param>
; working_dir: $InstallDir$
; icon_file: <path to icon file>
; icon_index: 2
; end_link
[LinkFolder_install_32]
set_basefolder common_programs
set_subfolder OpenVPN
set_link
name: OpenVPN GUI
target: $InstallDir32$/CPAU.exe
parameters: -dec -file $InstallDir32$\openvpn.job
working_dir: $InstallDir32$
icon_file: $InstallDir32$\icon.ico
icon_index:
end_link
set_basefolder common_desktopdirectory
set_subfolder ""
set_link
name: OpenVPN GUI
target: $InstallDir32$/CPAU.exe
parameters: -dec -file $InstallDir32$\openvpn.job
working_dir: $InstallDir32$
icon_file: $InstallDir32$\icon.ico
icon_index:
end_link
[LinkFolder_install_64]
set_basefolder common_programs
set_subfolder OpenVPN
set_link
name: OpenVPN GUI
target: $InstallDir64$/CPAU.exe
parameters: -dec -file $InstallDir64$\openvpn.job
working_dir: $InstallDir64$
icon_file: $InstallDir64$\icon.ico
icon_index:
end_link
set_basefolder common_desktopdirectory
set_subfolder ""
set_link
name: OpenVPN GUI
target: $InstallDir64$/CPAU.exe
parameters: -dec -file $InstallDir64$\openvpn.job
working_dir: $InstallDir64$
icon_file: $InstallDir64$\icon.ico
icon_index:
end_link
[Sub_check_exitcode]
comment "Test for installation success via exit code"

View File

@ -26,6 +26,9 @@ DefVar $OLD_VERSION$
DefVar $OLD_CREATOR_TAG$
DefVar $OLD_RELEASE$
DefVar $UserExists$
DefStringlist $ResultList2$
Set $INST_SystemType$ = GetSystemType
set $INST_architecture$ = GetProductProperty("install_architecture","system specific")

View File

@ -32,6 +32,16 @@ DL_SOURCE[3]="http://nativeex.boot-land.net/Programs/DriverSigning/DriverSigning
DL_ARCH[3]="X86"
DL_WINST_NAME[3]=Driversigning32Exe
DL_FILE[4]="CPAU-${VERSION}.zip"
DL_SOURCE[4]="http://www.joeware.net/downloads/dl.php"
DL_ARCH[4]="ALL"
DL_EXTRACT_FORMAT[4]="unzip"
DL_FILE[5]="PSTools-${VERSION}.zip"
DL_SOURCE[5]="http://download.sysinternals.com/files/PSTools.zip"
DL_ARCH[5]="ALL"
DL_EXTRACT_FORMAT[5]="unzip"
# File array index for the image showing while installing the program
ICON_DL_INDEX=0

View File

@ -23,3 +23,10 @@ function cleanup() {
echo "Cleanup"
builder_cleanup
}
function create() {
echo "Create"
builder_create
find $INST_DIR/CLIENT_DATA/ALL/ -type f ! -name 'PsGet*' ! -name 'CPAU*' -delete
}