Silent database import installer

From NSIS Wiki
Jump to navigationJump to search
Author: sunjammer (talk, contrib)


Description

This was an installer I created to import the NSIS Archive database contents into my own local database. Anyone wanting to use the nsExec plugin should find this interesting:

The Script

OutFile importdb.exe
SilentInstall silent
Section
  nsExec::Exec 'plink -ssh -batch sunjammerx@nsis.sourceforge.net "~/dump_mysql > ~/dblocation"'
  nsExec::Exec 'pscp sunjammerx@nsis.sourceforge.net:~/dblocation .'
  FileOpen $0 '$EXEDIR\dblocation' 'r'
  FileRead $0 $1
  FileClose $0
  Delete '$EXEDIR\dblocation'
  StrCpy $1 $1 -1
  nsExec::Exec 'pscp sunjammerx@nsis.sourceforge.net:$1 "$EXEDIR\dbfile.sql"'
  nsExec::Exec 'plink -ssh -batch sunjammerx@nsis.sourceforge.net "rm -f dblocation $1"'
  Delete '$EXEDIR\dbfile.sql.out'
  nsExec::Exec 'bzip2 -d dbfile.sql'
  nsExec::Exec 'c:\mysql\bin\mysql -e "drop database nsisweb"'
  nsExec::Exec 'c:\mysql\bin\mysql -e "create database nsisweb"'
  nsExec::Exec 'cmd /C c:\mysql\bin\mysql -D nsisweb < dbfile.sql.out'
  nsExec::Exec 'c:\mysql\bin\mysql -D nsisweb -e "delete from nsisweb_sessions"'
  Delete 'e:\src\sunjammer.net\archive\engine\sessions\*.*';
  Delete '$EXEDIR\dbfile.sql'
  Delete '$EXEDIR\dbfile.sql.out'
SectionEnd