Skip to content

Commit

Permalink
Merge branch 'bareos-16.2'
Browse files Browse the repository at this point in the history
  • Loading branch information
Marco van Wieringen committed Sep 1, 2016
2 parents cebc7bc + 21d4924 commit 533b223
Show file tree
Hide file tree
Showing 31 changed files with 2,002 additions and 637 deletions.
59 changes: 56 additions & 3 deletions platforms/win32/winbareos-nsi.spec
Expand Up @@ -13,8 +13,8 @@
# If name contains prevista, build for windows < vista.
%define flavors postvista postvista-debug

%define SIGNCERT ia.p12
%define SIGNPWFILE signpassword
%define SIGNCERT %{_builddir}/ia.p12
%define SIGNPWFILE %{_builddir}/signpassword


#!BuildIgnore: post-build-checks
Expand All @@ -36,6 +36,7 @@ BuildRequires: procps
BuildRequires: sed
BuildRequires: vim

BuildRequires: unzip
# Bareos sources
BuildRequires: mingw-debugsrc-devel = %{version}

Expand Down Expand Up @@ -104,6 +105,13 @@ Source9: databasedialog.ini

%define NSISDLLS KillProcWMI.dll AccessControl.dll LogEx.dll

%define NSSM_VERSION 2.24
%define PHP_VERSION 5.6.25
Source11: http://windows.php.net/downloads/releases/php-%PHP_VERSION-Win32-VC11-x86.zip
Source12: https://nssm.cc/release/nssm-%NSSM_VERSION.zip
Source13: https://github.com/bareos/bareos-webui/archive/master.tar.gz


%description
Bareos Windows NSI installer packages for the different variants.

Expand Down Expand Up @@ -132,11 +140,56 @@ for flavor in %{flavors}; do

mkdir -p $RPM_BUILD_ROOT/$flavor/nsisplugins
for dll in %NSISDLLS; do
cp $dll $RPM_BUILD_ROOT/$flavor/nsisplugins
cp %{_builddir}/$dll $RPM_BUILD_ROOT/$flavor/nsisplugins
done

for BITS in 32 64; do
mkdir -p $RPM_BUILD_ROOT/$flavor/release${BITS}
pushd $RPM_BUILD_ROOT/$flavor/release${BITS}

echo "The installer may contain the following software:" >> %_sourcedir/LICENSE
echo "" >> %_sourcedir/LICENSE

# nssm
unzip %SOURCE12;
cp nssm-%NSSM_VERSION/win${BITS}/nssm.exe $RPM_BUILD_ROOT/$flavor/release${BITS}

echo "" >> %_sourcedir/LICENSE
echo "NSSM - the Non-Sucking Service Manager: https://nssm.cc/" >> %_sourcedir/LICENSE
echo "##### LICENSE FILE OF NSSM START #####" >> %_sourcedir/LICENSE
cat nssm-%NSSM_VERSION/README.txt >> %_sourcedir/LICENSE
echo "##### LICENSE FILE OF NSSM END #####" >> %_sourcedir/LICENSE
echo "" >> %_sourcedir/LICENSE

rm -rvf nssm-%NSSM_VERSION

# bareos-webui
tar xzvf %SOURCE13
mv bareos-webui-* bareos-webui # rename subdirectory bareos-webui-Release-15.2.2 -> bareos-webui
pushd bareos-webui
cp install/directors.ini $RPM_BUILD_ROOT/$flavor/release${BITS}
cp install/*/*.conf $RPM_BUILD_ROOT/$flavor/release${BITS}
echo "" >> %_sourcedir/LICENSE
echo "##### LICENSE FILE OF BAREOS_WEBUI START #####" >> %_sourcedir/LICENSE
cat LICENSE >> %_sourcedir/LICENSE # append bareos-webui license file to LICENSE
echo "##### LICENSE FILE OF BAREOS_WEBUI END #####" >> %_sourcedir/LICENSE
echo "" >> %_sourcedir/LICENSE


# php has no subdir in zipfile
mkdir php;
pushd php;
unzip %SOURCE11
cp php.ini-production $RPM_BUILD_ROOT/$flavor/release${BITS}/php.ini
echo "" >> %_sourcedir/LICENSE
echo "PHP: http://php.net/" >> %_sourcedir/LICENSE
echo "##### LICENSE FILE OF PHP START #####" >> %_sourcedir/LICENSE
cat license.txt >> %_sourcedir/LICENSE
echo "##### LICENSE FILE OF PHP END #####" >> %_sourcedir/LICENSE
echo "" >> %_sourcedir/LICENSE

popd


# copy the sql ddls over
cp -av /etc/$flavor/mingw${BITS}-winbareos/ddl $RPM_BUILD_ROOT/$flavor/release${BITS}
Expand Down
132 changes: 129 additions & 3 deletions platforms/win32/winbareos.nsi
Expand Up @@ -171,11 +171,12 @@ Page custom displayDirconfSnippet

Function LaunchLink
ExecShell "open" "http://www.bareos.com"
ExecShell "open" "http://localhost:9100"
FunctionEnd

!define MUI_FINISHPAGE_RUN
#!define MUI_FINISHPAGE_RUN_NOTCHECKED
!define MUI_FINISHPAGE_RUN_TEXT "Open www.bareos.com"
!define MUI_FINISHPAGE_RUN_TEXT "Open www.bareos.com and bareos-webui"
!define MUI_FINISHPAGE_RUN_FUNCTION "LaunchLink"

!insertmacro MUI_PAGE_FINISH
Expand All @@ -191,7 +192,9 @@ FunctionEnd

; MUI end ------


!macro "CreateURLShortCut" "URLFile" "URLSite" "URLDesc"
WriteINIStr "${URLFile}.URL" "InternetShortcut" "URL" "${URLSite}"
!macroend

# check if postgres is installed and set the postgres variables if so
!macro getPostgresVars
Expand Down Expand Up @@ -459,6 +462,28 @@ Section -SetPasswords

nsExec::ExecToLog '$PLUGINSDIR\sed.exe -f "$PLUGINSDIR\bconsole.sed" -i-template "$PLUGINSDIR\bconsole.conf"'
nsExec::ExecToLog '$PLUGINSDIR\sed.exe -f "$PLUGINSDIR\bconsole.sed" -i-template "$PLUGINSDIR\bat.conf"'

# Configure webui

FileOpen $R1 $PLUGINSDIR\webui.sed w

FileWrite $R1 "s#/etc/bareos-webui/directors.ini#C:/ProgramData/Bareos/directors.ini#g$\r$\n"
FileWrite $R1 "s#/etc/bareos-webui/configuration.ini#C:/ProgramData/Bareos/configuration.ini#g$\r$\n"
FileWrite $R1 "s#;include_path = $\".;c.*#include_path = $\".;c:/php/includes;C:/Program Files/Bareos/bareos-webui/vendor/ZendFramework$\"#g$\r$\n"
FileWrite $R1 "s#; extension_dir = $\"ext$\"#extension_dir = $\"ext$\"#g$\r$\n"
FileWrite $R1 "s#;extension=php_gettext.dll#extension=php_gettext.dll#g$\r$\n"

# set username/password to bareos/bareos
FileWrite $R1 "s#user1#bareos#g$\r$\n"
FileWrite $R1 "s#CHANGEME#bareos#g$\r$\n"

FileClose $R1


nsExec::ExecToLog '$PLUGINSDIR\sed.exe -f "$PLUGINSDIR\webui.sed" -i-template "$PLUGINSDIR\php.ini"'
nsExec::ExecToLog '$PLUGINSDIR\sed.exe -f "$PLUGINSDIR\webui.sed" -i-template "$PLUGINSDIR\global.php"'
nsExec::ExecToLog '$PLUGINSDIR\sed.exe -f "$PLUGINSDIR\webui.sed" -i-template "$PLUGINSDIR\admin.conf"'

SectionEnd

#
Expand Down Expand Up @@ -647,6 +672,85 @@ SubSectionEnd # Storage Daemon Subsection

SubSection "Director" SUBSEC_DIR

Section Webinterface SEC_WEBINTERFACE
SectionIn 2 3
SetShellVarContext all
SetOutPath "$INSTDIR"
SetOverwrite ifnewer
#File /r "php"
File /r "nssm.exe"
File /r "bareos-webui"

# check for Visual C++ Redistributable für Visual Studio 2012 x86 (32 Bit)
ReadRegDword $R1 HKLM "SOFTWARE\Wow6432Node\Microsoft\VisualStudio\11.0\VC\Runtimes\x86" "Installed"
check_for_vc_redist:
${If} $R1 == ""
ExecShell "open" "https://www.microsoft.com/en-us/download/details.aspx?id=30679"
MessageBox MB_OK|MB_ICONSTOP "Visual C++ Redistributable for Visual Studio 2012 x86 was not found$\r$\n\
It is needed by the bareos-webui service.$\r$\n\
Please install vcredist_x86.exe from $\r$\n\
https://www.microsoft.com/en-us/download/details.aspx?id=30679$\r$\n\
and click OK when done." /SD IDOK
${EndIf}
ReadRegDword $R1 HKLM "SOFTWARE\Wow6432Node\Microsoft\VisualStudio\11.0\VC\Runtimes\x86" "Installed"
${If} $R1 == ""
goto check_for_vc_redist
${EndIf}

Rename "$INSTDIR\bareos-webui\config\autoload\global.php" "$INSTDIR\bareos-webui\config\autoload\global.php.orig"
Rename "$PLUGINSDIR\global.php" "$INSTDIR\bareos-webui\config\autoload\global.php"

Rename "$PLUGINSDIR\php.ini" "$APPDATA\${PRODUCT_NAME}\php.ini"
Rename "$PLUGINSDIR\directors.ini" "$APPDATA\${PRODUCT_NAME}\directors.ini"
Rename "$PLUGINSDIR\configuration.ini" "$APPDATA\${PRODUCT_NAME}\configuration.ini"


CreateDirectory "$INSTDIR\defaultconfigs\bareos-dir.d\profile"
Rename "$PLUGINSDIR\webui-admin.conf" "$INSTDIR\defaultconfigs\bareos-dir.d\profile\webui-admin.conf"

CreateDirectory "$INSTDIR\defaultconfigs\bareos-dir.d\console"
Rename "$PLUGINSDIR\admin.conf" "$INSTDIR\defaultconfigs\bareos-dir.d\console\admin.conf"

# Rename "$PLUGINSDIR\webui-admin.conf" "$APPDATA\${PRODUCT_NAME}\bareos-dir.d\profile\webui-admin.conf"
# Rename "$PLUGINSDIR\admin.conf" "$APPDATA\${PRODUCT_NAME}\bareos-dir.d\console\admin.conf"

#!insertmacro InstallConfFile php.ini
#!insertmacro InstallConfFile directors.ini
#!insertmacro InstallConfFile configuration.ini
#!insertmacro InstallConfFile webui-admin.conf
#!insertmacro InstallConfFile admin.conf


#FileOpen $R1 "$PLUGINSDIR\bareos-dir.conf" a
#FileSeek $R1 0 END
#FileWrite $R1 "@$APPDATA\${PRODUCT_NAME}\webui-admin.conf$\n"
#FileWrite $R1 "@$APPDATA\${PRODUCT_NAME}\admin.conf$\n"
FileClose $R1

ExecWait '$INSTDIR\nssm.exe install Bareos-webui $INSTDIR\bareos-webui\php\php.exe'
ExecWait '$INSTDIR\nssm.exe set Bareos-webui AppDirectory \"$INSTDIR\bareos-webui\"'
ExecWait '$INSTDIR\nssm.exe set Bareos-webui Application $INSTDIR\bareos-webui\php\php.exe'
# nssm.exe wants """ """ around parameters with spaces, the executable itself without quotes
# see https://nssm.cc/usage -> quoting issues
ExecWait '$INSTDIR\nssm.exe set Bareos-webui AppParameters \
-S 127.0.0.1:9100 \
-c $\"$\"$\"$APPDATA\${PRODUCT_NAME}\php.ini$\"$\"$\" \
-t $\"$\"$\"$INSTDIR\bareos-webui\public$\"$\"$\"'
ExecWait '$INSTDIR\nssm.exe set Bareos-webui AppStdout $\"$\"$\"$APPDATA\${PRODUCT_NAME}\logs\bareos-webui.log$\"$\"$\"'
ExecWait '$INSTDIR\nssm.exe set Bareos-webui AppStderr $\"$\"$\"$APPDATA\${PRODUCT_NAME}\logs\bareos-webui.log$\"$\"$\"'

WriteRegStr HKLM "SYSTEM\CurrentControlSet\Services\Bareos-webui" \
"Description" "Bareos Webui php service"

nsExec::ExecToLog "net start Bareos-webui"

# Shortcuts
!insertmacro "CreateURLShortCut" "bareos-webui" "http://localhost:9100" "Bareos Backup Server Web Interface"
#CreateShortCut "$DESKTOP\bareos-webui.lnk" "http://localhost:9100"
CreateShortCut "$SMPROGRAMS\${PRODUCT_NAME}\bareos-webui.lnk" "http://localhost:9100"

SectionEnd

Section /o "Director" SEC_DIR
SectionIn 2 3

Expand Down Expand Up @@ -1432,13 +1536,21 @@ done:

File "/oname=$PLUGINSDIR\sqlite3.sql" ".\ddl\creates\sqlite3.sql"

# webui
File "/oname=$PLUGINSDIR\php.ini" ".\bareos-webui\php\php.ini-production"
File "/oname=$PLUGINSDIR\global.php" ".\bareos-webui\config\autoload\global.php"
File "/oname=$PLUGINSDIR\directors.ini" ".\bareos-webui\install\directors.ini"
File "/oname=$PLUGINSDIR\configuration.ini" ".\bareos-webui\install\configuration.ini"
File "/oname=$PLUGINSDIR\webui-admin.conf" ".\bareos-webui/install/bareos/bareos-dir.d/profile/webui-admin.conf"
File "/oname=$PLUGINSDIR\admin.conf" ".\bareos-webui/install/bareos/bareos-dir.d/console/admin.conf.example"

# make first section mandatory
SectionSetFlags ${SEC_FD} 17 # SF_SELECTED & SF_RO
SectionSetFlags ${SEC_TRAYMON} ${SF_SELECTED} # traymon
SectionSetFlags ${SEC_FDPLUGINS} ${SF_SELECTED} # fd plugins
SectionSetFlags ${SEC_FIREWALL_SD} ${SF_UNSELECTED} # unselect sd firewall (is selected by default, why?)
SectionSetFlags ${SEC_FIREWALL_DIR} ${SF_UNSELECTED} # unselect dir firewall (is selected by default, why?)
SectionSetFlags ${SEC_WEBINTERFACE} ${SF_UNSELECTED} # unselect webinterface (is selected by default, why?)

StrCmp $InstallDirector "no" dontInstDir
SectionSetFlags ${SEC_DIR} ${SF_SELECTED} # director
Expand Down Expand Up @@ -1875,6 +1987,8 @@ Section Uninstall
sleep 3000
nsExec::ExecToLog '"$INSTDIR\bareos-dir.exe" /remove'

ExecWait '$INSTDIR\nssm.exe stop Bareos-webui'
ExecWait '$INSTDIR\nssm.exe remove Bareos-webui confirm'

# kill tray monitor
KillProcWMI::KillProc "bareos-tray-monitor.exe"
Expand Down Expand Up @@ -1903,7 +2017,12 @@ Section Uninstall
Delete "$APPDATA\${PRODUCT_NAME}\bconsole.conf"
RMDir /r "$APPDATA\${PRODUCT_NAME}\bconsole.d"
Delete "$APPDATA\${PRODUCT_NAME}\bat.conf"
RMDir /r "$APPDATA\${PRODUCT_NAME}\bat.d"

Delete "$APPDATA\${PRODUCT_NAME}\php.ini"
Delete "$APPDATA\${PRODUCT_NAME}\directors.ini"
Delete "$APPDATA\${PRODUCT_NAME}\configuration.ini"
Delete "$APPDATA\${PRODUCT_NAME}\bareos-dir.d\profile\webui-admin.conf"
Delete "$APPDATA\${PRODUCT_NAME}\bareos-dir.d\console\admin.conf"

ConfDeleteSkip:
# delete config files *.conf.old and *.conf.new, ...
Expand Down Expand Up @@ -1973,6 +2092,9 @@ ConfDeleteSkip:
Delete "$INSTDIR\ssleay32.dll"
Delete "$INSTDIR\libeay32.dll"

# logs
Delete "$INSTDIR\*.log"

RMDir /r "$INSTDIR\Plugins"
RMDir /r "$INSTDIR\defaultconfigs"

Expand Down Expand Up @@ -2005,6 +2127,10 @@ ConfDeleteSkip:
# traymon autostart
Delete "$SMSTARTUP\bareos-tray-monitor.lnk"

Delete "$INSTDIR\nssm.exe"
RMDir /r "$INSTDIR\bareos-webui"


Delete "$SMPROGRAMS\${PRODUCT_NAME}\Website.lnk"
Delete "$SMPROGRAMS\${PRODUCT_NAME}\Uninstall.lnk"
RMDir "$SMPROGRAMS\${PRODUCT_NAME}"
Expand Down
12 changes: 9 additions & 3 deletions src/cats/bvfs.c
Expand Up @@ -215,7 +215,7 @@ static void build_path_hierarchy(JCR *jcr, B_DB *mdb,
bstrncpy(pathid, org_pathid, sizeof(pathid));

/* Does the ppathid exist for this ? we use a memory cache... In order to
* avoid the full loop, we consider that if a dir is allready in the
* avoid the full loop, we consider that if a dir is already in the
* PathHierarchy table, then there is no need to calculate all the
* hierarchy
*/
Expand All @@ -235,14 +235,20 @@ static void build_path_hierarchy(JCR *jcr, B_DB *mdb,
if (sql_num_rows(mdb) > 0) {
ppathid_cache.insert(pathid);
/* This dir was in the db ...
* It means we can leave, the tree has allready been built for
* It means we can leave, the tree has already been built for
* this dir
*/
goto bail_out;
} else {
/* search or create parent PathId in Path table */
mdb->path = bvfs_parent_dir(path);
mdb->pnl = strlen(mdb->path);

/* Don't add an empty path to the db */
if (!mdb->pnl) {
goto bail_out;
}

if (!db_create_path_record(jcr, mdb, &parent)) {
goto bail_out;
}
Expand All @@ -262,7 +268,7 @@ static void build_path_hierarchy(JCR *jcr, B_DB *mdb,
}
} else {
/* It's already in the cache. We can leave, no time to waste here,
* all the parent dirs have allready been done
* all the parent dirs have already been done
*/
goto bail_out;
}
Expand Down
12 changes: 7 additions & 5 deletions src/cats/protos.h
Expand Up @@ -124,8 +124,8 @@ bool db_get_ndmp_environment_string(JCR *jcr, B_DB *mdb, JOB_DBR *jr,
void db_list_pool_records(JCR *jcr, B_DB *db, POOL_DBR *pr,
OUTPUT_FORMATTER *sendit, e_list_type type);
void db_list_job_records(JCR *jcr, B_DB *db, JOB_DBR *jr, const char *range,
const char* clientname, int jobstatus, const char* volumename,
utime_t since_time, int last, int count,
const char *clientname, int jobstatus, const char *volumename,
utime_t since_time, bool last, bool count,
OUTPUT_FORMATTER *sendit, e_list_type type);
void db_list_job_totals(JCR *jcr, B_DB *db, JOB_DBR *jr,
OUTPUT_FORMATTER *sendit);
Expand All @@ -139,8 +139,8 @@ void db_list_jobmedia_records(JCR *jcr, B_DB *mdb, JobId_t JobId,
OUTPUT_FORMATTER *sendit, e_list_type type);
void db_list_joblog_records(JCR *jcr, B_DB *mdb, JobId_t JobId,
OUTPUT_FORMATTER *sendit, e_list_type type);
void db_list_log_records(JCR *jcr, B_DB *mdb, const char *range, bool reverse,
OUTPUT_FORMATTER *sendit, e_list_type type);
void db_list_log_records(JCR *jcr, B_DB *mdb, const char *clientname, const char *range,
bool reverse, OUTPUT_FORMATTER *sendit, e_list_type type);
bool db_list_sql_query(JCR *jcr, B_DB *mdb, const char *query,
OUTPUT_FORMATTER *sendit, e_list_type type,
bool verbose);
Expand All @@ -149,7 +149,9 @@ bool db_list_sql_query(JCR *jcr, B_DB *mdb, const char *query,
const char *description, bool verbose = false);
void db_list_client_records(JCR *jcr, B_DB *mdb, char *clientname,
OUTPUT_FORMATTER *sendit, e_list_type type);
void db_list_copies_records(JCR *jcr, B_DB *mdb, const char *range, char *jobids,
void db_list_storage_records(JCR *jcr, B_DB *mdb,
OUTPUT_FORMATTER *sendit, e_list_type type);
void db_list_copies_records(JCR *jcr, B_DB *mdb, const char *range, const char *jobids,
OUTPUT_FORMATTER *sendit, e_list_type type);
void db_list_base_files_for_job(JCR *jcr, B_DB *mdb, JobId_t jobid,
OUTPUT_FORMATTER *sendit);
Expand Down

0 comments on commit 533b223

Please sign in to comment.