Build Linux client installer

This commit is contained in:
Martin 2016-01-20 01:47:08 +01:00
parent 315dd9eecd
commit dff855325e
17 changed files with 259 additions and 37 deletions

View File

@ -69,15 +69,15 @@ if MACOSX
install-data-local: urbackupclient/backup_scripts/list urbackupclient/backup_scripts/mariadb.conf urbackupclient/backup_scripts/mariadb \
client/info.txt client/data/backup-bad.ico client/data/backup-ok.ico client/data/backup-progress.ico \
client/data/backup-progress-pause.ico client/data/backup-no-server.ico client/data/backup-no-recent.ico client/data/backup-indexing.ico \
client/data/logo1.png client/data/lang/*/*.mo client/version.txt
client/data/logo1.png client/data/lang/*/*.mo client/version.txt client/data/urbackup_ecdsa409k1.pub
else
install-data-local: urbackupclient/backup_scripts/list urbackupclient/backup_scripts/mariadb.conf urbackupclient/backup_scripts/mariadb \
client/info.txt client/data/backup-bad.xpm client/data/backup-ok.xpm client/data/backup-progress.xpm \
client/data/backup-progress-pause.xpm client/data/backup-no-server.xpm client/data/backup-no-recent.xpm client/data/backup-indexing.xpm \
client/data/logo1.png client/data/lang/*/*.mo client/version.txt
client/data/logo1.png client/data/lang/*/*.mo client/version.txt client/data/urbackup_ecdsa409k1.pub
endif
else
install-data-local: urbackupclient/backup_scripts/list urbackupclient/backup_scripts/mariadb.conf urbackupclient/backup_scripts/mariadb client/version.txt
install-data-local: urbackupclient/backup_scripts/list urbackupclient/backup_scripts/mariadb.conf urbackupclient/backup_scripts/mariadb client/version.txt client/data/urbackup_ecdsa409k1.pub
endif
$(MKDIR_P) "$(DESTDIR)$(localstatedir)/urbackup/"
@ -91,6 +91,7 @@ endif
chmod 700 "$(DESTDIR)$(datadir)/urbackup/scripts/"*
chmod 700 "$(DESTDIR)$(sysconfdir)/urbackup/"*
$(INSTALL_DATA) "$(srcdir)/client/version.txt" "$(DESTDIR)$(localstatedir)/urbackup/version.txt"
$(INSTALL_DATA) "$(srcdir)/client/data/urbackup_ecdsa409k1.pub" "$(DESTDIR)$(datadir)/urbackup/"
if WITH_GUI_CLIENT
$(MKDIR_P) "$(DESTDIR)$(datadir)/urbackup"
@ -179,4 +180,4 @@ noinst_HEADERS=SessionMgr.h WorkerThread.h Helper_win32.h Database.h defaults.h
EXTRA_DIST_GUI = client/info.txt client/data/backup-bad.xpm client/data/backup-ok.xpm client/data/backup-progress.xpm client/data/backup-progress-pause.xpm client/data/backup-no-server.xpm client/data/backup-no-recent.xpm client/data/backup-indexing.xpm client/data/logo1.png client/data/lang/it/urbackup.mo client/data/lang/pl/urbackup.mo client/data/lang/pt_BR/urbackup.mo client/data/lang/sk/urbackup.mo client/data/lang/zh_TW/urbackup.mo client/data/lang/zh_CN/urbackup.mo client/data/lang/de/urbackup.mo client/data/lang/es/urbackup.mo client/data/lang/fr/urbackup.mo client/data/lang/ru/urbackup.mo client/data/lang/uk/urbackup.mo client/data/lang/da/urbackup.mo client/data/lang/nl/urbackup.mo client/data/lang/fa/urbackup.mo client/data/lang/cs/urbackup.mo client/gui/GUISetupWizard.h client/SetupWizard.h
EXTRA_DIST=docs/urbackupclientbackend.1 init.d_client init.d_client_rh defaults_client $(EXTRA_DIST_GUI) tclap/COPYING tclap/AUTHORS urbackupclientbackend-debian.service urbackupclientbackend-redhat.service urbackupclient/backup_scripts/list urbackupclient/backup_scripts/mariadb.conf urbackupclient/backup_scripts/mariadb client/version.txt
EXTRA_DIST=docs/urbackupclientbackend.1 init.d_client init.d_client_rh defaults_client $(EXTRA_DIST_GUI) tclap/COPYING tclap/AUTHORS urbackupclientbackend-debian.service urbackupclientbackend-redhat.service urbackupclient/backup_scripts/list urbackupclient/backup_scripts/mariadb.conf urbackupclient/backup_scripts/mariadb client/version.txt client/data/urbackup_ecdsa409k1.pub

View File

@ -82,6 +82,7 @@
# include <unistd.h>
# include <sys/types.h>
# include <pwd.h>
# include "config.h"
#endif
#include "StaticPluginRegistration.h"
@ -1311,7 +1312,7 @@ void CServer::createThread(IThread *thread, const std::string& name)
pthread_create(&t, &attr, &thread_helper_f, (void*)thread);
pthread_detach(t);
#ifndef __APPLE__
#ifdef HAVE_PTHREAD_SETNAME_NP
if (!name.empty())
{
std::string thread_name;
@ -1326,7 +1327,7 @@ void CServer::createThread(IThread *thread, const std::string& name)
pthread_setname_np(t, thread_name.c_str());
}
#endif //__APPLE__
#endif //HAVE_PTHREAD_SETNAME_NP
pthread_attr_destroy(&attr);
#endif
@ -1338,7 +1339,7 @@ void CServer::setCurrentThreadName(const std::string& name)
#if defined(_DEBUG)
SetThreadName(-1, name.c_str());
#endif
#elif !defined(__APPLE__)
#elif defined(HAVE_PTHREAD_SETNAME_NP)
if (!name.empty())
{
pthread_t ct = pthread_self();

View File

@ -108,7 +108,8 @@ if os.path.exists("client"):
"client/urbackup_notray.nsi",
"client/build_msi.bat",
"osx_installer/resources/welcome.html",
"create_osx_installer.sh"]
"create_osx_installer.sh",
"install_client_linux.sh"]
for short_file in client_short_files:
replace_in_file(short_file, "$version_short$", version["client"]["short"])

39
create_linux_installer.sh Normal file
View File

@ -0,0 +1,39 @@
#!/bin/bash
set -e
./switch_build.sh client
autoreconf --install
mkdir -p install-data
for arch in i386-linux-eng x86_64-linux-eng arm-linux-engeabihf aarch64-linux-eng
do
echo "Compiling for architecture $arch..."
./configure --enable-headless CPPFLAGS="-target i386-linux-eng" LDFLAGS="-target i386-linux-eng" CXX="ecc++" CC="ecc" --with-crypto-prefix=/usr/local/ellcc/libecc
make clean
make -j4
rm -R install-data/$arch || true
mkdir -p install-data/$arch
cp urbackupclientbackend install-data/$arch/
cp urbackupclientctl install-data/$arch/
done
mkdir -p install-data/backup_scripts
cp urbackupclient/backup_scripts/* install-data/backup_scripts/
cp client/version.txt install-data/
cp client/data/urbackup_ecdsa409k1.pub install-data/
cp urbackupclientbackend-debian.service install-data/
cp urbackupclientbackend-redhat.service install-data/
cp init.d_client install-data/
cp init.d_client_rh install-data/
cp defaults_client install-data/
rm -R linux-installer || true
mkdir -p linux-installer
tar czf linux-installer/install-data.tar.gz install-data/*
cp install_client_linux.sh linux-installer/
makeself --nocomp --nomd5 --nocrc linux-installer "UrBackupUpdateLinux.sh" "UrBackup Client Installer for Linux" ./install_client_linux.sh

View File

@ -63,7 +63,7 @@ mkdir -p update_installer
cp final.pkg update_installer/final.pkg
cp osx_installer/update_install.sh update_installer/update_install.sh
chmod +x update_installer/update_install.sh
makeself update_installer "UrBackupUpdateMac.sh" "UrBackup Client Installer for Mac OS X" ./update_install.sh
makeself --nocomp --nomd5 --nocrc update_installer "UrBackupUpdateMac.sh" "UrBackup Client Installer for Mac OS X" ./update_install.sh
#Uncomment for development
#sudo pkgutil --forget org.urbackup.client.service || true

View File

@ -1,18 +1,29 @@
# Defaults for urbackup_client initscript
# sourced by /etc/init.d/urbackup_client
# installed at /etc/default/urbackup_client by the maintainer scripts
# sourced by /etc/init.d/urbackupclientbackend
# installed at /etc/default/urbackupclientbackend by the maintainer scripts
#
# This is a POSIX shell fragment
# This is parsed as a key=value file
#
# Additional options that are passed to the Daemon.
#logfile name
LOGFILE="/var/log/urbackup_client.log"
#Either debug,warn,info or error
LOGLEVEL="warn"
#Tmp file directory - be carefull this can get very large
#Tmp file directory
DAEMON_TMPDIR="/tmp"
# Valid settings:
#
# "client-confirms": If you have the GUI component the currently active user
# will need to confirm restores from the web interface.
# If you have no GUI component this will cause restores
# from the server web interface to not work
# "server-confirms": The server will ask the user starting the restore on
# the web interface for confirmation
# "disabled": Restores via web interface are disabled.
# Restores via urbackupclientctl still work
#
RESTORE="disabled"

View File

@ -2,24 +2,28 @@
# sourced by /etc/init.d/urbackupsrv and /lib/systemd/system/urbackup-server.service
# installed at /etc/default/urbackupsrv by the maintainer scripts
# Additional options that are passed to the Daemon.
#
# This is parsed as a key=value file
#
#Port for FastCGI requests
FASTCGI_PORT=55413
#Port for the web interface
HTTP_PORT=55414
#Enable internal HTTP server
HTTP_SERVER="true"
#Port for the web interface
#(if internal HTTP server is enabled)
HTTP_PORT=55414
#log file name
LOGFILE="/var/log/urbackup.log"
#Either debug,warn,info or error
LOGLEVEL="warn"
#Temporary file directory - this may get very large
#Temporary file directory
# -- this may get very large depending on the advanced settings
DAEMON_TMPDIR="/tmp"
#Tmp file directory for sqlite temporary tables.
@ -27,6 +31,6 @@ DAEMON_TMPDIR="/tmp"
#Default is the same as DAEMON_TMPDIR
SQLITE_TMPDIR=""
#Interfaces from which to send broadcasts. (Default: all)
#Interfaces from which to send broadcasts. (Default: all).
#Comma separated -- e.g. "eth0,eth1"
BROADCAST_INTERFACES=""

View File

@ -63,6 +63,11 @@
#define fallocate64 fallocate
#else
#include <linux/fs.h>
#if !defined(BLKGETSIZE64) && defined(__i386__) && defined(__x86_64__)
#define BLKGETSIZE64 _IOR(0x12,114,size_t)
#endif
#endif
File::File()
@ -228,7 +233,7 @@ _i64 File::Size(void)
if(rc==0)
{
#ifndef __APPLE__
#if defined(BLKGETSIZE64)
if(S_ISBLK(stat_buf.st_mode))
{
_i64 ret;

View File

@ -25,6 +25,7 @@
#include "../common/data.h"
#include "PipeFile.h"
#include <string>
#include <stdlib.h>
volatile bool PipeSessions::do_stop = false;
IMutex* PipeSessions::mutex = NULL;

139
install_client_linux.sh Normal file
View File

@ -0,0 +1,139 @@
#!/bin/sh
set -e
PREFIX=/usr/local
SILENT=no
if [ "x$1" = "xsilent" ]
then
SILENT=yes
fi
echo "Installation of UrBackup Client $version_short$"
if [ SILENT = no ]
then
read -rsp $'Press any key to continue...\n' -n1 key
fi
tar xzf install-data.tar.gz
DEBIAN=no
if [ -e /etc/debian_version ]
then
DEBIAN=yes
echo "Detected Debian (derivative) system"
mv urbackupclientbackend-debian.service urbackupclientbackend.service
mv init.d_client init.d
else
echo "Assuming RedHat like system"
mv urbackupclientbackend-redhat.service urbackupclientbackend.service
mv init.d_client_rh init.d
fi
SYSTEMD=no
if command -v systemctl >/dev/null 2>&1
then
echo "Detected systemd"
SYSTEMD=yes
fi
TARGET=no
arch=`uname -m`
case "$arch" in
i?86) TARGET=i386-linux-eng ;;
x86_64) TARGET=x86_64-linux-eng ;;
armv6*) TARGET=arm-linux-engeabihf ;;
armv7*) TARGET=arm-linux-engeabihf ;;
armv8*) TARGET=aarch64-linux-eng ;;
esac
if [ TARGET = no ]
then
echo "Cannot run UrBackup client on this server. CPU Architecture/dependency issues. Stopping installation."
exit 1
else
echo "Detected architecture $TARGET"
fi
install -c -m 744 -d "$PREFIX/var/urbackup"
install -c -m 744 -d "$PREFIX/sbin"
install -c -m 744 -d "$PREFIX/bin"
install -c -m 744 -d "$PREFIX/share/urbackup/scripts"
install -c -m 744 -d "$PREFIX/etc/urbackup"
install -c "$TARGET/urbackupclientbackend" "$PREFIX/sbin"
install -c "$TARGET/urbackupclientctl" "$PREFIX/bin"
sed "s|SYSCONFDIR|$PREFIX/etc/urbackup|g" "backup_scripts/list" > "backup_scripts/list.r"
mv "backup_scripts/list.r" "backup_scripts/list"
install -c "backup_scripts/list" "$PREFIX/share/urbackup/scripts"
install -c "backup_scripts/mariadb" "$PREFIX/share/urbackup/scripts"
test -e "$PREFIX/etc/urbackup/mariadb.conf" || install -c "backup_scripts/mariadb.conf" "$PREFIX/etc/urbackup"
chmod 700 "$PREFIX/share/urbackup/scripts"*
chmod 700 "$PREFIX/etc/urbackup/"*
/usr/bin/install -c -m 644 "version.txt" "$PREFIX/var/urbackup"
cat << c71b9d17069d4d03bd7f6b75f36ba5ff > "$PREFIX/var/urbackup/initial_settings.cfg"
#Initial Settings. Changes will not be respected.
#48692563-17e4-4ccb-a078-f14372fdbe20
################################################################################################################################################################################################################################################################################################################################################################################################################################################################################################################################################################################################################################################################################################################################################################################################################################################################################################################################################################################################################################################################################################################################################################################################################################################################################################################################################################################################################################################################################################################################################################################################################################################################################################################################################################################################################################################################################################################################################################################################################################################################################################################################################################################################################################################################################################################################################################################################################################################################################################################################################################################################################################################################################################################################################################################################################################################################################################################################################################################################################################################################################################################################################################################################################################################################################################################################################################################################################################################################################################################################################################################################################################################################################################################################################################################################################################################################################################################################################################################################################################################################################################
#6e7f6ba0-8478-4946-b70a-f1c7e83d28cc
c71b9d17069d4d03bd7f6b75f36ba5ff
if test ! -e "$PREFIX/var/urbackup/server_idents.txt"
then
cat << c71b9d17069d4d03bd7f6b75f36ba5ff > "$PREFIX/var/urbackup/server_idents.txt"
#17460620-769b-4add-85aa-a764efe84ab7
###################################################
#569d42d2-1b40-4745-a426-e86a577c7f1a
c71b9d17069d4d03bd7f6b75f36ba5ff
fi
if [ DEBIAN = yes ]
then
[ ! test -e /etc/defaults ] || install -c defaults_client /etc/defaults/urbackupclientbackend
else
[ ! test -e /etc/sysconfig ] || install -c defaults_client /etc/sysconfig/urbackupclientbackend
fi
if [ SYSTEMD = yes ]
then
echo "Installing systemd unit..."
SYSTEMD_DIR=`pkg-config systemd --variable=systemdsystemunitdir`
if [ "x$SYSTEMD_DIR" = x ]
then
echo "Cannot find systemd unit dir. Assuming /lib/systemd/system"
SYSTEMD_DIR="/lib/systemd/system"
fi
install -c urbackupclientbackend.service $SYSTEMD_DIR
systemctl enable urbackupclientbackend.service
echo "Starting UrBackup Client service..."
systemctl start urbackupclientbackend.service
else
echo "Installing System V init script..."
install -c init.d /etc/init.d/urbackupclientbackend
if [ DEBIAN = yes ]
then
update-rc.d urbackupclientbackend defaults
else
chkconfig --add urbackupclientbackend
chkconfig --level 345 urbackupclientbackend on
fi
echo "Starting UrBackup Client service..."
/etc/init.d/urbackupclientbackend start
fi

View File

@ -253,6 +253,9 @@ if test "x$ax_pthread_ok" = xyes; then
if test "x$flag" != xno; then
PTHREAD_CFLAGS="$flag $PTHREAD_CFLAGS"
fi
AC_TRY_LINK([#include <pthread.h>], [pthread_t ct = pthread_self();pthread_setname_np(ct, "test");],
[AC_DEFINE([HAVE_PTHREAD_SETNAME_NP], [1], [pthread has GNU extension thread_setname_np])])
LIBS="$save_LIBS"
CFLAGS="$save_CFLAGS"

View File

@ -2,11 +2,14 @@
set -e
cp "$1.cfg" "$2/Contents/MacOS/var/initial_settings.cfg"
if test ! -e "$2/Contents/MacOS/var/urbackup/server_idents.txt"
if test -e "$1.cfg"
then
cp "$1.ident" "$2/Contents/MacOS/var/urbackup/server_idents.txt"
cp "$1.cfg" "$2/Contents/MacOS/var/urbackup/initial_settings.cfg"
if test ! -e "$2/Contents/MacOS/var/urbackup/server_idents.txt"
then
cp "$1.ident" "$2/Contents/MacOS/var/urbackup/server_idents.txt"
fi
fi
/bin/launchctl load "/Library/LaunchDaemons/org.urbackup.client.plist"

View File

@ -7,7 +7,7 @@
# include <signal.h>
# include <sys/socket.h>
# include <sys/types.h>
# include <sys/poll.h>
# include <poll.h>
# include <netinet/in.h>
# include <netinet/tcp.h>
# include <arpa/inet.h>

View File

@ -261,10 +261,16 @@ DLLEXPORT void LoadActions(IServer* pServer)
}
#endif
if( !FileExists("urbackup/data/settings.cfg") && FileExists("initial_settings.cfg") )
#ifdef _WIN32
#define INITIAL_SETTINGS_PREFIX ""
#else
#define INITIAL_SETTINGS_PREFIX "urbackup/"
#endif
if( !FileExists("urbackup/data/settings.cfg") && FileExists(INITIAL_SETTINGS_PREFIX "initial_settings.cfg") )
{
copy_file("initial_settings.cfg", "urbackup/data/settings.cfg");
Server->deleteFile("initial_settings.cfg");
copy_file(INITIAL_SETTINGS_PREFIX "initial_settings.cfg", "urbackup/data/settings.cfg");
Server->deleteFile(INITIAL_SETTINGS_PREFIX "initial_settings.cfg");
}
#ifndef _DEBUG

View File

@ -13,7 +13,7 @@
# include <signal.h>
# include <sys/socket.h>
# include <sys/types.h>
# include <sys/poll.h>
# include <poll.h>
# include <netinet/in.h>
# include <netinet/tcp.h>
# include <arpa/inet.h>

View File

@ -39,6 +39,7 @@
#include <fcntl.h>
#include <sys/ioctl.h>
#include <errno.h>
#include <time.h>
#include <sys/time.h>
#ifdef __linux__
#include <sys/resource.h>
@ -54,9 +55,6 @@
#define dirent64 dirent
#endif
#ifdef __APPLE__
#include <sys/time.h>
#endif
void getMousePos(int &x, int &y)
{

View File

@ -2451,6 +2451,16 @@ void ClientMain::run_script( std::string name, const std::string& params, logid_
void ClientMain::log_progress( const std::string& fn, int64 total, int64 downloaded, int64 speed_bps )
{
std::string fn_wo_token = fn;
std::string share = getuntil("/", fn);
if (!share.empty())
{
if (share.find("|") != std::string::npos)
{
fn_wo_token = getafter("|", fn);
}
}
if(total>0 && total!=LLONG_MAX)
{
int pc_complete = 0;
@ -2458,11 +2468,11 @@ void ClientMain::log_progress( const std::string& fn, int64 total, int64 downloa
{
pc_complete = static_cast<int>((static_cast<float>(downloaded)/total)*100.f);
}
ServerLogger::Log(logid, "Loading \""+fn+"\". "+convert(pc_complete)+"% finished "+PrettyPrintBytes(downloaded)+"/"+PrettyPrintBytes(total)+" at "+PrettyPrintSpeed(static_cast<size_t>(speed_bps)), LL_DEBUG);
ServerLogger::Log(logid, "Loading \""+ fn_wo_token +"\". "+convert(pc_complete)+"% finished "+PrettyPrintBytes(downloaded)+"/"+PrettyPrintBytes(total)+" at "+PrettyPrintSpeed(static_cast<size_t>(speed_bps)), LL_DEBUG);
}
else
{
ServerLogger::Log(logid, "Loading \""+fn+"\". Loaded "+PrettyPrintBytes(downloaded)+" at "+PrettyPrintSpeed(static_cast<size_t>(speed_bps)), LL_DEBUG);
ServerLogger::Log(logid, "Loading \""+ fn_wo_token +"\". Loaded "+PrettyPrintBytes(downloaded)+" at "+PrettyPrintSpeed(static_cast<size_t>(speed_bps)), LL_DEBUG);
}
}