release systemback for hamonikr 3.0
30
README.md
Normal file
@@ -0,0 +1,30 @@
|
|||||||
|

|
||||||
|

|
||||||
|
|
||||||
|
## systemback
|
||||||
|
|
||||||
|
Upstream : https://code.launchpad.net/~nemh/systemback/stable
|
||||||
|
|
||||||
|
systemback 프로그램을 하모니카에서 사용할 수 있도록 새롭게 빌드한 프로젝트.
|
||||||
|
|
||||||
|
- 초보자도 쉽게 자신만의 ISO 이미지를 만들어서 배포할 수 있는 프로그램
|
||||||
|
- 사용중인 자신의 PC 환경을 라이브 이미지로 제작할 수 있는 기능 제공
|
||||||
|
- 자신이 수정한 자신만의 환경으로 다른 PC에 설치할수 있는 ISO 이미지를 쉽게
|
||||||
|
제작가능
|
||||||
|
- 한글 인터페이스를 지원하도록 기능 추가
|
||||||
|
- 하모니카 3.0 에서 빌드하고 검증완료 (Ubuntu 18.04, LinuxMint 19.01 지원)
|
||||||
|
|
||||||
|
|
||||||
|

|
||||||
|

|
||||||
|
|
||||||
|
## 설치
|
||||||
|
```
|
||||||
|
# 하모니카 SUN 저장소 추가
|
||||||
|
curl -sL https://apt.hamonikr.org/setup_hamonikr.sun | sudo -E bash -
|
||||||
|
|
||||||
|
sudo apt install systemback
|
||||||
|
```
|
||||||
|
|
||||||
|
## 이슈 또는 버그
|
||||||
|
사용 중 문제를 발견하시면 root@hamonikr.org 또는 https://hamonikr.org 에서 알려주세요.
|
||||||
60
debian/changelog
vendored
Normal file
@@ -0,0 +1,60 @@
|
|||||||
|
systemback (1.8.402hamonikr1) release; urgency=low
|
||||||
|
|
||||||
|
* Rebuild for HamoniKR OS
|
||||||
|
* Added Korean translation
|
||||||
|
|
||||||
|
-- Kevin Kim <chaeya@gmail.com> Sun, 04 Oct 2020 15:10:11 +0900
|
||||||
|
|
||||||
|
systemback (1.8.402) release; urgency=low
|
||||||
|
|
||||||
|
* 1.8.402
|
||||||
|
* Fix Live creation when the '/snap' directory is missing
|
||||||
|
|
||||||
|
* 1.8.400
|
||||||
|
* Add support to installed Snap packages
|
||||||
|
* Remove support to old (version 1.5 and below) restore points
|
||||||
|
* Fix possible segmentation fault when checking directory mount status
|
||||||
|
* Fix translation files detection in DBGLEV=3 mode
|
||||||
|
* Fix source code compilation under Ubuntu 14.04
|
||||||
|
* Import new Romanian translations
|
||||||
|
|
||||||
|
* 1.8.300
|
||||||
|
* Fix the possible conflict with the APT when updating the package index files
|
||||||
|
* Import new EFI boot files from the Ubuntu 16.04 LTS
|
||||||
|
* Import new Czech, English (United Kingdom), Hungarian, Romanian and Spanish
|
||||||
|
translations
|
||||||
|
|
||||||
|
* 1.8.202
|
||||||
|
* Improve compatibility with apt 1.2
|
||||||
|
* Update EFI boot files
|
||||||
|
* Import new Spanish, Danish and Chinese (Simplified) translations
|
||||||
|
|
||||||
|
* 1.8.201
|
||||||
|
* Fix restore point creation when the storage dir path contains symbolic link
|
||||||
|
* Fix some directory date and time settings when creating restore points
|
||||||
|
|
||||||
|
* 1.8.200
|
||||||
|
* Fix line breaking when printing the mounted filesystems in DBGLEV=3 mode
|
||||||
|
* Fix error messages printing when upgrading the system
|
||||||
|
* Fix the GRUB menu height on the Live when the system contains xorg.conf
|
||||||
|
file(s)
|
||||||
|
* Detect and takes into account the configuration file(s) in the
|
||||||
|
/etc/X11/xorg.conf.d directory
|
||||||
|
* Update EFI boot files
|
||||||
|
* Import new Czech translations
|
||||||
|
|
||||||
|
* 1.8.102
|
||||||
|
* Fix possible segmentation fault when try to minimize the window with the
|
||||||
|
button
|
||||||
|
|
||||||
|
* 1.8.101
|
||||||
|
* Fix partition information reading on Ubuntu 16.04
|
||||||
|
|
||||||
|
* 1.8.100
|
||||||
|
* Fix incorrect symlink following when creating a new incremental restore
|
||||||
|
point (TeamViewer global.conf bug)
|
||||||
|
* Add a new debug level (DBGLEV=3) for more debug information
|
||||||
|
* Some minor fixes and improvements
|
||||||
|
* Import new Hungarian translations
|
||||||
|
|
||||||
|
-- Kende Krisztián <nemh@freemail.hu> Mon, 16 May 2016 13:04:46 +0200
|
||||||
1
debian/compat
vendored
Normal file
@@ -0,0 +1 @@
|
|||||||
|
9
|
||||||
177
debian/control
vendored
Normal file
@@ -0,0 +1,177 @@
|
|||||||
|
Source: systemback
|
||||||
|
Section: admin
|
||||||
|
Priority: optional
|
||||||
|
Maintainer: Kende Krisztián <nemh@freemail.hu>
|
||||||
|
Build-Depends: debhelper (>= 9),
|
||||||
|
libblkid-dev,
|
||||||
|
libmount-dev,
|
||||||
|
libncursesw5-dev,
|
||||||
|
libparted0-dev,
|
||||||
|
qtbase5-dev,
|
||||||
|
qttools5-dev-tools
|
||||||
|
Standards-Version: 3.9.7
|
||||||
|
|
||||||
|
Package: systemback
|
||||||
|
Architecture: amd64 i386
|
||||||
|
Depends: ${misc:Depends},
|
||||||
|
${shlibs:Depends},
|
||||||
|
casper | live-boot,
|
||||||
|
dosfstools,
|
||||||
|
fonts-freefont-ttf | ttf-freefont,
|
||||||
|
genisoimage,
|
||||||
|
squashfs-tools,
|
||||||
|
syslinux,
|
||||||
|
syslinux (<< 3:5) | isolinux (>> 3:6),
|
||||||
|
syslinux (<< 3:5) | syslinux-common (>> 3:6),
|
||||||
|
syslinux (<< 3:5) | syslinux-utils (>> 3:6),
|
||||||
|
systemback-efiboot-amd64 (= ${source:Version}) [amd64],
|
||||||
|
systemback-scheduler (= ${binary:Version}),
|
||||||
|
upstart | sysvinit (>= 2.88) | systemd,
|
||||||
|
xterm,
|
||||||
|
zenity | kde-baseapps-bin | kdebase-bin
|
||||||
|
Recommends: grub2-common,
|
||||||
|
grub-efi-amd64-bin,
|
||||||
|
grub-pc-bin,
|
||||||
|
lupin-casper [amd64],
|
||||||
|
systemback-cli (= ${binary:Version}),
|
||||||
|
systemback-locales (= ${source:Version}),
|
||||||
|
ttf-ubuntu-font-family
|
||||||
|
Suggests: btrfs-tools,
|
||||||
|
jfsutils,
|
||||||
|
reiserfsprogs,
|
||||||
|
xfsprogs,
|
||||||
|
unionfs-fuse
|
||||||
|
Conflicts: live-config,
|
||||||
|
live-config-systemd
|
||||||
|
Breaks: systemback-gui-common (<< 1.0.0)
|
||||||
|
Replaces: systemback-gui-common (<< 1.0.0)
|
||||||
|
Description: Simple system backup and restore application with extra features
|
||||||
|
Systemback makes it easy to create backups of the system and the users
|
||||||
|
configuration files. In case of problems you can easily restore the previous
|
||||||
|
state of the system. There are extra features like system copying, system
|
||||||
|
installation and Live system creation.
|
||||||
|
.
|
||||||
|
This package contain a Qt5 graphical user interface for Systemback.
|
||||||
|
|
||||||
|
Package: systemback-dbg
|
||||||
|
Architecture: amd64 i386
|
||||||
|
Section: debug
|
||||||
|
Priority: extra
|
||||||
|
Depends: ${misc:Depends},
|
||||||
|
systemback (= ${binary:Version})
|
||||||
|
Description: Debug symbols for systemback
|
||||||
|
Systemback makes it easy to create backups of the system and the users
|
||||||
|
configuration files. In case of problems you can easily restore the previous
|
||||||
|
state of the system. There are extra features like system copying, system
|
||||||
|
installation and Live system creation.
|
||||||
|
.
|
||||||
|
This package contains the debug symbols for systemback.
|
||||||
|
|
||||||
|
Package: systemback-cli
|
||||||
|
Architecture: amd64 i386
|
||||||
|
Depends: ${misc:Depends},
|
||||||
|
${shlibs:Depends},
|
||||||
|
upstart | sysvinit (>= 2.88) | systemd
|
||||||
|
Recommends: grub2-common,
|
||||||
|
grub-efi-amd64-bin | grub-pc-bin
|
||||||
|
Description: Systemback command line interface
|
||||||
|
Systemback makes it easy to create backups of the system and the users
|
||||||
|
configuration files. In case of problems you can easily restore the previous
|
||||||
|
state of the system. There are extra features like system copying, system
|
||||||
|
installation and Live system creation.
|
||||||
|
.
|
||||||
|
This package contain a command line interface for Systemback.
|
||||||
|
|
||||||
|
Package: systemback-cli-dbg
|
||||||
|
Architecture: amd64 i386
|
||||||
|
Section: debug
|
||||||
|
Priority: extra
|
||||||
|
Depends: ${misc:Depends},
|
||||||
|
systemback-cli (= ${binary:Version})
|
||||||
|
Description: Debug symbols for systemback-cli
|
||||||
|
Systemback makes it easy to create backups of the system and the users
|
||||||
|
configuration files. In case of problems you can easily restore the previous
|
||||||
|
state of the system. There are extra features like system copying, system
|
||||||
|
installation and Live system creation.
|
||||||
|
.
|
||||||
|
This package contains the debug symbols for systemback-cli.
|
||||||
|
|
||||||
|
Package: systemback-scheduler
|
||||||
|
Architecture: amd64 i386
|
||||||
|
Depends: ${misc:Depends},
|
||||||
|
${shlibs:Depends}
|
||||||
|
Breaks: systemback (<< 1.0.0)
|
||||||
|
Replaces: systemback (<< 1.0.0)
|
||||||
|
Description: Systemback scheduler daemon
|
||||||
|
Systemback makes it easy to create backups of the system and the users
|
||||||
|
configuration files. In case of problems you can easily restore the previous
|
||||||
|
state of the system. There are extra features like system copying, system
|
||||||
|
installation and Live system creation.
|
||||||
|
.
|
||||||
|
This package contain a scheduler daemon for Systemback.
|
||||||
|
|
||||||
|
Package: systemback-scheduler-dbg
|
||||||
|
Architecture: amd64 i386
|
||||||
|
Section: debug
|
||||||
|
Priority: extra
|
||||||
|
Depends: ${misc:Depends},
|
||||||
|
systemback-scheduler (= ${binary:Version})
|
||||||
|
Description: Debug symbols for systemback-scheduler
|
||||||
|
Systemback makes it easy to create backups of the system and the users
|
||||||
|
configuration files. In case of problems you can easily restore the previous
|
||||||
|
state of the system. There are extra features like system copying, system
|
||||||
|
installation and Live system creation.
|
||||||
|
.
|
||||||
|
This package contains the debug symbols for systemback-scheduler.
|
||||||
|
|
||||||
|
Package: libsystemback
|
||||||
|
Architecture: amd64 i386
|
||||||
|
Section: libs
|
||||||
|
Depends: ${misc:Depends},
|
||||||
|
${shlibs:Depends},
|
||||||
|
apt,
|
||||||
|
procps
|
||||||
|
Description: Systemback shared library
|
||||||
|
Systemback makes it easy to create backups of the system and the users
|
||||||
|
configuration files. In case of problems you can easily restore the previous
|
||||||
|
state of the system. There are extra features like system copying, system
|
||||||
|
installation and Live system creation.
|
||||||
|
.
|
||||||
|
This package contain a shared library for Systemback binaries.
|
||||||
|
|
||||||
|
Package: libsystemback-dbg
|
||||||
|
Architecture: amd64 i386
|
||||||
|
Section: debug
|
||||||
|
Priority: extra
|
||||||
|
Depends: ${misc:Depends},
|
||||||
|
libsystemback (= ${binary:Version})
|
||||||
|
Description: Debug symbols for libsystemback
|
||||||
|
Systemback makes it easy to create backups of the system and the users
|
||||||
|
configuration files. In case of problems you can easily restore the previous
|
||||||
|
state of the system. There are extra features like system copying, system
|
||||||
|
installation and Live system creation.
|
||||||
|
.
|
||||||
|
This package contains the debug symbols for libsystemback.
|
||||||
|
|
||||||
|
Package: systemback-efiboot-amd64
|
||||||
|
Architecture: all
|
||||||
|
Depends: ${misc:Depends},
|
||||||
|
xz-utils
|
||||||
|
Description: Systemback boot files
|
||||||
|
Systemback makes it easy to create backups of the system and the users
|
||||||
|
configuration files. In case of problems you can easily restore the previous
|
||||||
|
state of the system. There are extra features like system copying, system
|
||||||
|
installation and Live system creation.
|
||||||
|
.
|
||||||
|
This package contais 64-bit boot files for UEFI-based machines.
|
||||||
|
|
||||||
|
Package: systemback-locales
|
||||||
|
Architecture: all
|
||||||
|
Depends: ${misc:Depends}
|
||||||
|
Description: Systemback localizations files
|
||||||
|
Systemback makes it easy to create backups of the system and the users
|
||||||
|
configuration files. In case of problems you can easily restore the previous
|
||||||
|
state of the system. There are extra features like system copying, system
|
||||||
|
installation and Live system creation.
|
||||||
|
.
|
||||||
|
This package contains localizations files for Systemback.
|
||||||
22
debian/copyright
vendored
Normal file
@@ -0,0 +1,22 @@
|
|||||||
|
Format: http://www.debian.org/doc/packaging-manuals/copyright-format/1.0
|
||||||
|
Upstream-Name: Systemback
|
||||||
|
Source: https://sourceforge.net/projects/systemback/files
|
||||||
|
|
||||||
|
Files: *
|
||||||
|
Copyright: 2010-2016 Krisztián Kende <nemh@freemail.hu>
|
||||||
|
License: GPL-3+
|
||||||
|
This package is free software; you can redistribute it and/or modify it under
|
||||||
|
the terms of the GNU General Public License as published by the Free Software
|
||||||
|
Foundation; either version 3 of the License, or (at your option) any later
|
||||||
|
version.
|
||||||
|
.
|
||||||
|
This package is distributed in the hope that it will be useful, but WITHOUT ANY
|
||||||
|
WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR A
|
||||||
|
PARTICULAR PURPOSE. See the GNU General Public License for more details.
|
||||||
|
.
|
||||||
|
You should have received a copy of the GNU General Public License along with
|
||||||
|
this package; if not, write to the Free Software Foundation, Inc., 51 Franklin
|
||||||
|
St, Fifth Floor, Boston, MA 02110-1301 USA
|
||||||
|
.
|
||||||
|
On Debian systems, the full text of the GNU General Public License version 3
|
||||||
|
can be found in the file '/usr/share/common-licenses/GPL'.
|
||||||
1
debian/libsystemback.install
vendored
Normal file
@@ -0,0 +1 @@
|
|||||||
|
libsystemback/libsystemback.so* usr/lib/systemback
|
||||||
21
debian/libsystemback.postrm
vendored
Executable file
@@ -0,0 +1,21 @@
|
|||||||
|
#!/bin/sh -e
|
||||||
|
|
||||||
|
if [ "$1" = purge ] && [ -d /etc/systemback ]
|
||||||
|
then
|
||||||
|
echo "Deleting Systemback configuration files ..."
|
||||||
|
|
||||||
|
if [ -f /etc/systemback/systemback.conf ]
|
||||||
|
then
|
||||||
|
sdir="$(grep ^storage_directory= /etc/systemback/systemback.conf | tail -c +19)"
|
||||||
|
rm /etc/systemback/systemback.conf
|
||||||
|
|
||||||
|
if [ "$sdir" ] && [ -d "$sdir"/Systemback ] && [ ! -d "$sdir"/Systemback/S01_* ] && [ ! -d "$sdir"/Systemback/H01_* ]
|
||||||
|
then
|
||||||
|
[ ! -e "$sdir"/Systemback/.sbschedule ] || rm "$sdir"/Systemback/.sbschedule
|
||||||
|
! rm -d "$sdir"/Systemback 2>/dev/null || echo "Deleting empty Systemback storage directory ..."
|
||||||
|
fi
|
||||||
|
fi
|
||||||
|
|
||||||
|
rm -r /etc/systemback
|
||||||
|
fi
|
||||||
|
#DEBHELPER#
|
||||||
62
debian/rules
vendored
Executable file
@@ -0,0 +1,62 @@
|
|||||||
|
#!/usr/bin/make -f
|
||||||
|
|
||||||
|
configure: configure-stamp
|
||||||
|
|
||||||
|
configure-stamp:
|
||||||
|
qmake -qt5
|
||||||
|
touch configure-stamp
|
||||||
|
|
||||||
|
build: build-arch build-indep
|
||||||
|
|
||||||
|
build-arch: build-arch-stamp
|
||||||
|
|
||||||
|
build-indep: build-indep-stamp
|
||||||
|
|
||||||
|
build-arch-stamp: configure-stamp
|
||||||
|
$(MAKE) -j $(shell getconf _NPROCESSORS_ONLN 2>/dev/null || echo 1)
|
||||||
|
touch build-arch-stamp
|
||||||
|
|
||||||
|
build-indep-stamp:
|
||||||
|
lrelease -qt5 systemback.pro
|
||||||
|
touch build-indep-stamp
|
||||||
|
|
||||||
|
clean:
|
||||||
|
rm -f configure-stamp build-*-stamp lang/*.qm libsystemback/libmount.hpp
|
||||||
|
[ ! -f Makefile ] || $(MAKE) distclean
|
||||||
|
dh_clean
|
||||||
|
|
||||||
|
binary-arch: build-arch
|
||||||
|
dh_installdirs -a
|
||||||
|
dh_install -a
|
||||||
|
dh_installman debian/systemback.1 -p systemback
|
||||||
|
dh_installman debian/systemback-cli.1 -p systemback-cli
|
||||||
|
dh_strip --dbg-package=systemback-dbg -p systemback
|
||||||
|
dh_strip --dbg-package=systemback-cli-dbg -p systemback-cli
|
||||||
|
dh_strip --dbg-package=systemback-scheduler-dbg -p systemback-scheduler
|
||||||
|
dh_strip --dbg-package=libsystemback-dbg -p libsystemback
|
||||||
|
dh_link -a
|
||||||
|
dh_fixperms -a
|
||||||
|
chmod 4755 debian/systemback-scheduler/usr/lib/systemback/sbsustart
|
||||||
|
dh_makeshlibs -nV "libsystemback (= $(shell dpkg-parsechangelog | sed -n 's/^Version: //p'))" -a
|
||||||
|
dh_shlibdeps -a
|
||||||
|
dh_installdeb -a
|
||||||
|
dh_gencontrol -a
|
||||||
|
dh_installdocs -a
|
||||||
|
dh_installchangelogs -a
|
||||||
|
dh_lintian -a
|
||||||
|
dh_compress -a
|
||||||
|
dh_builddeb -a
|
||||||
|
|
||||||
|
binary-indep: build-indep
|
||||||
|
dh_install -i
|
||||||
|
dh_fixperms -i
|
||||||
|
dh_installdeb -i
|
||||||
|
dh_gencontrol -i
|
||||||
|
dh_installdocs -i
|
||||||
|
dh_installchangelogs -i
|
||||||
|
dh_compress -i
|
||||||
|
dh_builddeb -i
|
||||||
|
|
||||||
|
binary: binary-arch binary-indep
|
||||||
|
|
||||||
|
.PHONY: configure build-arch build-indep clean binary-arch binary-indep binary
|
||||||
1
debian/source.lintian-overrides
vendored
Normal file
@@ -0,0 +1 @@
|
|||||||
|
systemback source: newer-standards-version *
|
||||||
1
debian/source/format
vendored
Normal file
@@ -0,0 +1 @@
|
|||||||
|
3.0 (native)
|
||||||
70
debian/systemback-cli.1
vendored
Normal file
@@ -0,0 +1,70 @@
|
|||||||
|
.TH Systemback 1 "02.02.2016."
|
||||||
|
|
||||||
|
.SH NAME
|
||||||
|
Systemback - Simple system backup and restore application with extra
|
||||||
|
.br
|
||||||
|
features
|
||||||
|
|
||||||
|
.SH SYNOPSIS
|
||||||
|
\fBsystemback-cli\fR [\fIOPTION\fR]
|
||||||
|
|
||||||
|
.SH DESCRIPTION
|
||||||
|
|
||||||
|
\fBSystemback\fR makes it easy to create backups of the system and the users
|
||||||
|
configuration files. In case of problems you can easily restore the previous
|
||||||
|
state of the system. There are extra features like system copying, system
|
||||||
|
installation and Live system creation.
|
||||||
|
|
||||||
|
.SH OPTIONS
|
||||||
|
.TP
|
||||||
|
.B -n, --newbackup
|
||||||
|
create a new restore point
|
||||||
|
.TP
|
||||||
|
.B -s, --storagedir <path>
|
||||||
|
get or set restore points storage directory path
|
||||||
|
.TP
|
||||||
|
.B -u, --upgrade
|
||||||
|
upgrade current system
|
||||||
|
.br
|
||||||
|
remove unnecessary files and packages
|
||||||
|
.TP
|
||||||
|
.B -v, --version
|
||||||
|
output Systemback version number
|
||||||
|
.TP
|
||||||
|
.B -h, --help
|
||||||
|
show help
|
||||||
|
|
||||||
|
.SH ENVIRONMENT
|
||||||
|
.TP
|
||||||
|
.B DBGLEV
|
||||||
|
set the debug level for the stdout printed error messages
|
||||||
|
.br
|
||||||
|
these will be redirected to the /tmp/systemback-cli_stderr
|
||||||
|
.br
|
||||||
|
0 - no error messages
|
||||||
|
.br
|
||||||
|
1 - print the error messages when a process has stopped because
|
||||||
|
.br
|
||||||
|
an error occurred (default)
|
||||||
|
.br
|
||||||
|
2 - this is the same as level 1
|
||||||
|
.br
|
||||||
|
3 - print the error messages with extra informations
|
||||||
|
|
||||||
|
.SH FILES
|
||||||
|
.SS /etc/systemback/systemback.conf
|
||||||
|
configuration of GUI and CLI
|
||||||
|
.br
|
||||||
|
the possible variables and values are indicated in the file, all other changes
|
||||||
|
are lost
|
||||||
|
|
||||||
|
.SS /etc/systemback/systemback.excludes
|
||||||
|
exclude hidden user files and directories from restore points
|
||||||
|
.br
|
||||||
|
exclude user data files and directories from Live system
|
||||||
|
|
||||||
|
.SS /etc/systemback/systemback.includes
|
||||||
|
include user data files and directories into the restore points
|
||||||
|
|
||||||
|
.SH AUTHOR
|
||||||
|
Krisztián Kende (nemh@freemail.hu)
|
||||||
1
debian/systemback-cli.install
vendored
Normal file
@@ -0,0 +1 @@
|
|||||||
|
systemback-cli/systemback-cli usr/bin
|
||||||
1
debian/systemback-efiboot-amd64.install
vendored
Normal file
@@ -0,0 +1 @@
|
|||||||
|
efi-amd64.bootfiles usr/share/systemback
|
||||||
1
debian/systemback-locales.install
vendored
Normal file
@@ -0,0 +1 @@
|
|||||||
|
lang/*.qm usr/share/systemback/lang
|
||||||
3
debian/systemback-scheduler.install
vendored
Normal file
@@ -0,0 +1,3 @@
|
|||||||
|
sbscheduler/sbscheduler usr/lib/systemback
|
||||||
|
sbsustart/sbsustart usr/lib/systemback
|
||||||
|
sbschedule*.desktop etc/xdg/autostart
|
||||||
1
debian/systemback-scheduler.lintian-overrides
vendored
Normal file
@@ -0,0 +1 @@
|
|||||||
|
systemback-scheduler: setuid-binary
|
||||||
11
debian/systemback-scheduler.postrm
vendored
Executable file
@@ -0,0 +1,11 @@
|
|||||||
|
#!/bin/sh -e
|
||||||
|
|
||||||
|
if [ -d /run ]
|
||||||
|
then pfile=/run/sbscheduler.pid
|
||||||
|
else pfile=/var/run/sbscheduler.pid
|
||||||
|
fi
|
||||||
|
|
||||||
|
if [ "$1" = upgrade ] && [ -s $pfile ]
|
||||||
|
then printf restart > $pfile
|
||||||
|
fi
|
||||||
|
#DEBHELPER#
|
||||||
8
debian/systemback-scheduler.preinst
vendored
Executable file
@@ -0,0 +1,8 @@
|
|||||||
|
#!/bin/sh -e
|
||||||
|
|
||||||
|
if [ "$1" = install ] && grep ^enabled=true /etc/systemback/systemback.conf >/dev/null 2>&1
|
||||||
|
then
|
||||||
|
echo "Disabling Systemback scheduler ..."
|
||||||
|
sed -i s/^enabled=true/enabled=false/g /etc/systemback/systemback.conf
|
||||||
|
fi
|
||||||
|
#DEBHELPER#
|
||||||
16
debian/systemback-scheduler.prerm
vendored
Executable file
@@ -0,0 +1,16 @@
|
|||||||
|
#!/bin/sh -e
|
||||||
|
|
||||||
|
if [ -d /run ]
|
||||||
|
then dir=/run
|
||||||
|
else dir=/var/run
|
||||||
|
fi
|
||||||
|
|
||||||
|
if [ "$1" = remove ] && [ -e $dir/sbscheduler.lock ] && [ -s $dir/sbscheduler.pid ]
|
||||||
|
then
|
||||||
|
echo "Stopping Systemback scheduler daemon ..."
|
||||||
|
|
||||||
|
if kill $(cat $dir/sbscheduler.pid) >/dev/null 2>&1
|
||||||
|
then rm $dir/sbscheduler.lock $dir/sbscheduler.pid
|
||||||
|
fi
|
||||||
|
fi
|
||||||
|
#DEBHELPER#
|
||||||
49
debian/systemback.1
vendored
Normal file
@@ -0,0 +1,49 @@
|
|||||||
|
.TH Systemback 1 "02.02.2016."
|
||||||
|
|
||||||
|
.SH NAME
|
||||||
|
Systemback - Simple system backup and restore application with extra
|
||||||
|
.br
|
||||||
|
features
|
||||||
|
|
||||||
|
.SH SYNOPSIS
|
||||||
|
\fBsystemback
|
||||||
|
|
||||||
|
.SH DESCRIPTION
|
||||||
|
|
||||||
|
\fBSystemback\fR makes it easy to create backups of the system and the users
|
||||||
|
configuration files. In case of problems you can easily restore the previous
|
||||||
|
state of the system. There are extra features like system copying, system
|
||||||
|
installation and Live system creation.
|
||||||
|
|
||||||
|
.SH ENVIRONMENT
|
||||||
|
.TP
|
||||||
|
.B DBGLEV
|
||||||
|
set the debug level for the stdout printed error messages
|
||||||
|
.br
|
||||||
|
0 - no error messages
|
||||||
|
.br
|
||||||
|
1 - print the error messages when a process has stopped because
|
||||||
|
.br
|
||||||
|
an error occurred (default)
|
||||||
|
.br
|
||||||
|
2 - print all error messages
|
||||||
|
.br
|
||||||
|
3 - print all error messages with extra informations
|
||||||
|
|
||||||
|
.SH FILES
|
||||||
|
.SS /etc/systemback/systemback.conf
|
||||||
|
configuration of GUI and CLI
|
||||||
|
.br
|
||||||
|
the possible variables and values are indicated in the file, all other changes
|
||||||
|
are lost
|
||||||
|
|
||||||
|
.SS /etc/systemback/systemback.excludes
|
||||||
|
exclude hidden user files and directories from restore points
|
||||||
|
.br
|
||||||
|
exclude user data files and directories from Live system
|
||||||
|
|
||||||
|
.SS /etc/systemback/systemback.includes
|
||||||
|
include user data files and directories into the restore points
|
||||||
|
|
||||||
|
.SH AUTHOR
|
||||||
|
Krisztián Kende (nemh@freemail.hu)
|
||||||
9
debian/systemback.install
vendored
Normal file
@@ -0,0 +1,9 @@
|
|||||||
|
systemback/systemback usr/bin
|
||||||
|
sbsysupgrade/sbsysupgrade usr/lib/systemback
|
||||||
|
splash.png usr/share/systemback
|
||||||
|
logo.png usr/share/systemback
|
||||||
|
systemback*.desktop /usr/share/applications
|
||||||
|
icons/128x128/systemback.png usr/share/icons/hicolor/128x128/apps
|
||||||
|
icons/256x256/systemback.png usr/share/icons/hicolor/256x256/apps
|
||||||
|
icons/48x48/systemback.png usr/share/icons/hicolor/48x48/apps
|
||||||
|
icons/64x64/systemback.png usr/share/icons/hicolor/64x64/apps
|
||||||
1
debian/systemback.links
vendored
Normal file
@@ -0,0 +1 @@
|
|||||||
|
/usr/lib/systemback/sbsustart /usr/bin/systemback-sustart
|
||||||
2
debian/systemback.lintian-overrides
vendored
Normal file
@@ -0,0 +1,2 @@
|
|||||||
|
systemback: desktop-command-not-in-package
|
||||||
|
systemback: binary-without-manpage
|
||||||
BIN
doc/systemback-1.png
Normal file
|
After Width: | Height: | Size: 54 KiB |
BIN
doc/systemback-2.png
Normal file
|
After Width: | Height: | Size: 37 KiB |
BIN
efi-amd64.bootfiles
Normal file
BIN
icons/128x128/systemback.png
Normal file
|
After Width: | Height: | Size: 12 KiB |
BIN
icons/256x256/systemback.png
Normal file
|
After Width: | Height: | Size: 37 KiB |
BIN
icons/48x48/systemback.png
Normal file
|
After Width: | Height: | Size: 3.4 KiB |
BIN
icons/64x64/systemback.png
Normal file
|
After Width: | Height: | Size: 4.8 KiB |
1884
lang/systemback_ar_EG.ts
Normal file
1884
lang/systemback_ca_ES.ts
Normal file
1899
lang/systemback_cs.ts
Normal file
1900
lang/systemback_da_DK.ts
Normal file
1898
lang/systemback_de.ts
Normal file
1289
lang/systemback_en_GB.ts
Normal file
1885
lang/systemback_es.ts
Normal file
1884
lang/systemback_fi.ts
Normal file
1899
lang/systemback_fr.ts
Normal file
1898
lang/systemback_gl_ES.ts
Normal file
1899
lang/systemback_hu.ts
Normal file
1898
lang/systemback_id.ts
Normal file
1290
lang/systemback_ko.ts
Normal file
1898
lang/systemback_pt_BR.ts
Normal file
1898
lang/systemback_ro.ts
Normal file
1898
lang/systemback_ru.ts
Normal file
1884
lang/systemback_tr.ts
Normal file
1898
lang/systemback_uk.ts
Normal file
1898
lang/systemback_zh_CN.ts
Normal file
51
libsystemback/bstr.hpp
Normal file
@@ -0,0 +1,51 @@
|
|||||||
|
/*
|
||||||
|
* Copyright(C) 2015-2016, Krisztián Kende <nemh@freemail.hu>
|
||||||
|
*
|
||||||
|
* This file is part of the Systemback.
|
||||||
|
*
|
||||||
|
* The Systemback is free software; you can redistribute it and/or modify it under
|
||||||
|
* the terms of the GNU General Public License as published by the Free Software
|
||||||
|
* Foundation; either version 3 of the License, or (at your option) any later
|
||||||
|
* version.
|
||||||
|
*
|
||||||
|
* The Systemback is distributed in the hope that it will be useful, but WITHOUT
|
||||||
|
* ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS
|
||||||
|
* FOR A PARTICULAR PURPOSE. See the GNU General Public License for more details.
|
||||||
|
*
|
||||||
|
* You should have received a copy of the GNU General Public License along with the
|
||||||
|
* Systemback. If not, see <http://www.gnu.org/licenses>.
|
||||||
|
*/
|
||||||
|
|
||||||
|
#ifndef BSTR_HPP
|
||||||
|
#define BSTR_HPP
|
||||||
|
|
||||||
|
#include "sbtypedef.hpp"
|
||||||
|
|
||||||
|
class bstr
|
||||||
|
{
|
||||||
|
private:
|
||||||
|
QBA ba;
|
||||||
|
|
||||||
|
public:
|
||||||
|
inline bstr() {}
|
||||||
|
inline bstr(cchar *txt) : data(txt) {}
|
||||||
|
inline bstr(cQBA &txt) : data(txt.constData()) {}
|
||||||
|
inline bstr(cQStr &txt) : ba(txt.toUtf8()), data(ba.constData()) {}
|
||||||
|
operator cchar *() const;
|
||||||
|
|
||||||
|
cchar *data;
|
||||||
|
|
||||||
|
cchar *rplc(cchar *bef, cchar *aft);
|
||||||
|
};
|
||||||
|
|
||||||
|
inline bstr::operator cchar *() const
|
||||||
|
{
|
||||||
|
return data;
|
||||||
|
}
|
||||||
|
|
||||||
|
inline cchar *bstr::rplc(cchar *bef, cchar *aft)
|
||||||
|
{
|
||||||
|
return ba.replace(bef, aft);
|
||||||
|
}
|
||||||
|
|
||||||
|
#endif
|
||||||
20
libsystemback/lcheck.sh
Executable file
@@ -0,0 +1,20 @@
|
|||||||
|
#!/bin/sh
|
||||||
|
#
|
||||||
|
# Copyright(C) 2015-2016, Krisztián Kende <nemh@freemail.hu>
|
||||||
|
#
|
||||||
|
# This file is part of the Systemback.
|
||||||
|
#
|
||||||
|
# The Systemback is free software; you can redistribute it and/or modify it under
|
||||||
|
# the terms of the GNU General Public License as published by the Free Software
|
||||||
|
# Foundation; either version 3 of the License, or (at your option) any later
|
||||||
|
# version.
|
||||||
|
#
|
||||||
|
# The Systemback is distributed in the hope that it will be useful, but WITHOUT
|
||||||
|
# ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS
|
||||||
|
# FOR A PARTICULAR PURPOSE. See the GNU General Public License for more details.
|
||||||
|
#
|
||||||
|
# You should have received a copy of the GNU General Public License along with the
|
||||||
|
# Systemback. If not, see <http://www.gnu.org/licenses>.
|
||||||
|
#
|
||||||
|
|
||||||
|
grep "*new)" /usr/include/libmount/libmount.h >/dev/null && sed "s/*new)/*new_table)/g" /usr/include/libmount/libmount.h > libmount.hpp
|
||||||
53
libsystemback/libsystemback.pro
Normal file
@@ -0,0 +1,53 @@
|
|||||||
|
QT -= gui
|
||||||
|
|
||||||
|
TARGET = systemback
|
||||||
|
|
||||||
|
CONFIG += c++11 \
|
||||||
|
exceptions_off
|
||||||
|
|
||||||
|
TEMPLATE = lib
|
||||||
|
|
||||||
|
DEFINES += SYSTEMBACK_LIBRARY \
|
||||||
|
_FILE_OFFSET_BITS=64
|
||||||
|
|
||||||
|
system(./lcheck.sh):exists(libmount.hpp) {
|
||||||
|
DEFINES += C_MNT_LIB
|
||||||
|
}
|
||||||
|
|
||||||
|
SOURCES += sblib.cpp
|
||||||
|
|
||||||
|
HEADERS += sblib.hpp \
|
||||||
|
sblib_global.hpp \
|
||||||
|
sbtypedef.hpp \
|
||||||
|
bstr.hpp
|
||||||
|
|
||||||
|
RESOURCES += version.qrc
|
||||||
|
|
||||||
|
QMAKE_CXXFLAGS += -g \
|
||||||
|
-fno-rtti \
|
||||||
|
-fvisibility=hidden \
|
||||||
|
-fvisibility-inlines-hidden \
|
||||||
|
-fno-asynchronous-unwind-tables
|
||||||
|
|
||||||
|
QMAKE_CXXFLAGS_WARN_ON += -Wno-unused-result
|
||||||
|
|
||||||
|
CONFIG(debug, debug|release) {
|
||||||
|
QMAKE_CXXFLAGS_WARN_ON += -Wextra \
|
||||||
|
-Wshadow \
|
||||||
|
-Werror
|
||||||
|
}
|
||||||
|
|
||||||
|
QMAKE_LFLAGS += -g \
|
||||||
|
-Wl,-Bsymbolic-functions \
|
||||||
|
-Wl,--as-needed \
|
||||||
|
-fuse-ld=gold \
|
||||||
|
-Wl,-z,relro
|
||||||
|
|
||||||
|
! equals(QMAKE_CXX, clang++) {
|
||||||
|
QMAKE_CXXFLAGS += -flto
|
||||||
|
QMAKE_LFLAGS += -flto
|
||||||
|
}
|
||||||
|
|
||||||
|
LIBS += -lmount \
|
||||||
|
-lblkid \
|
||||||
|
-lparted
|
||||||
4243
libsystemback/sblib.cpp
Normal file
290
libsystemback/sblib.hpp
Normal file
@@ -0,0 +1,290 @@
|
|||||||
|
/*
|
||||||
|
* Copyright(C) 2014-2016, Krisztián Kende <nemh@freemail.hu>
|
||||||
|
*
|
||||||
|
* This file is part of the Systemback.
|
||||||
|
*
|
||||||
|
* The Systemback is free software; you can redistribute it and/or modify it under
|
||||||
|
* the terms of the GNU General Public License as published by the Free Software
|
||||||
|
* Foundation; either version 3 of the License, or (at your option) any later
|
||||||
|
* version.
|
||||||
|
*
|
||||||
|
* The Systemback is distributed in the hope that it will be useful, but WITHOUT
|
||||||
|
* ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS
|
||||||
|
* FOR A PARTICULAR PURPOSE. See the GNU General Public License for more details.
|
||||||
|
*
|
||||||
|
* You should have received a copy of the GNU General Public License along with the
|
||||||
|
* Systemback. If not, see <http://www.gnu.org/licenses>.
|
||||||
|
*/
|
||||||
|
|
||||||
|
#ifndef SBLIB_HPP
|
||||||
|
#define SBLIB_HPP
|
||||||
|
|
||||||
|
#include "sblib_global.hpp"
|
||||||
|
#include "bstr.hpp"
|
||||||
|
#include <QCoreApplication>
|
||||||
|
#include <QStringBuilder>
|
||||||
|
#include <QTemporaryFile>
|
||||||
|
#include <QFileInfo>
|
||||||
|
#include <QThread>
|
||||||
|
#include <sys/statvfs.h>
|
||||||
|
#include <sys/stat.h>
|
||||||
|
#include <unistd.h>
|
||||||
|
|
||||||
|
#define fnln __attribute__((always_inline))
|
||||||
|
#define cfgfile "/etc/systemback/systemback.conf"
|
||||||
|
#define excfile "/etc/systemback/systemback.excludes"
|
||||||
|
#define incfile "/etc/systemback/systemback.includes"
|
||||||
|
|
||||||
|
class SHARED_EXPORT_IMPORT sb : public QThread
|
||||||
|
{
|
||||||
|
Q_DECLARE_TR_FUNCTIONS(systemback)
|
||||||
|
|
||||||
|
public:
|
||||||
|
enum { Remove = 0, Copy = 1, Sync = 2, Mount = 3, Umount = 4, Readprttns = 5, Readlvdevs = 6, Ruuid = 7, Setpflag = 8, Mkptable = 9, Mkpart = 10, Delpart = 11, Crtrpoint = 12, Srestore = 13, Scopy = 14, Lvprpr = 15,
|
||||||
|
MSDOS = 0, GPT = 1, Clear = 2, Primary = 3, Extended = 4, Logical = 5, Freespace = 6, Emptyspace = 7,
|
||||||
|
Nodbg = 0, Errdbg = 1, Alldbg = 2, Extdbg = 3, Cextdbg = 4, Nulldbg = 5, Falsedbg = 6,
|
||||||
|
Notexist = 0, Isfile = 1, Isdir = 2, Islink = 3, Isblock = 4, Unknown = 5,
|
||||||
|
Noflag = 0, Silent = 1, Bckgrnd = 2, Prgrss = 4, Wait = 8,
|
||||||
|
Sblock = 0, Dpkglock = 1, Aptlock = 2, Schdlrlock = 3,
|
||||||
|
False = 0, True = 1, Empty = 2, Include = 3,
|
||||||
|
Crtdir = 0, Rmfile = 1, Crthlnk = 2,
|
||||||
|
Read = 0, Write = 1, Exec = 2,
|
||||||
|
Norm = 0, All = 1, Mixed = 2 };
|
||||||
|
|
||||||
|
static sb SBThrd;
|
||||||
|
static QStr ThrdStr[3], eout, sdir[3], schdlr[2], pnames[15], lang, style, wsclng;
|
||||||
|
static ullong ThrdLng[2];
|
||||||
|
static uchar dbglev, pnumber, ismpnt, schdle[6], waot, incrmtl, xzcmpr, autoiso, ecache;
|
||||||
|
static schar Progress;
|
||||||
|
static bool ExecKill, ThrdKill;
|
||||||
|
|
||||||
|
static fnln QStr hunit(ullong size);
|
||||||
|
|
||||||
|
static QStr mid(cQStr &txt, ushort start, ushort len),
|
||||||
|
fload(cQStr &path, bool ascnt),
|
||||||
|
right(cQStr &txt, short len),
|
||||||
|
left(cQStr &txt, short len),
|
||||||
|
gdetect(cQStr rdir = "/"),
|
||||||
|
rndstr(uchar vlen = 10),
|
||||||
|
ruuid(cQStr &part),
|
||||||
|
appver(),
|
||||||
|
dbginf();
|
||||||
|
|
||||||
|
static QBA fload(cQStr &path);
|
||||||
|
template<typename T> static ullong dfree(const T &path);
|
||||||
|
static fnln ullong fsize(cQStr &path);
|
||||||
|
|
||||||
|
static fnln ushort instr(cQStr &txt, cQStr &stxt, ushort start = 1),
|
||||||
|
rinstr(cQStr &txt, cQStr &stxt);
|
||||||
|
|
||||||
|
template<typename T> static uchar stype(const T &path, bool flink = false);
|
||||||
|
|
||||||
|
static uchar exec(cQStr &cmd, uchar flag = Noflag, cQStr &envv = nullptr),
|
||||||
|
exec(cQSL &cmds);
|
||||||
|
|
||||||
|
template<typename T1, typename T2> static bool issmfs(const T1 &item1, const T2 &item2);
|
||||||
|
template<typename T> static fnln bool crtdir(const T &path);
|
||||||
|
template<typename T> static fnln bool rmfile(const T &file);
|
||||||
|
template<typename T> static bool exist(const T &path);
|
||||||
|
|
||||||
|
static fnln bool islink(cQStr &path),
|
||||||
|
isfile(cQStr &path),
|
||||||
|
isdir(cQStr &path);
|
||||||
|
|
||||||
|
static bool srestore(uchar mthd, cQStr &usr, cQStr &srcdir, cQStr &trgt, bool sfstab = false),
|
||||||
|
mkpart(cQStr &dev, ullong start = 0, ullong len = 0, uchar type = Primary),
|
||||||
|
mcheck(cQStr &item, cQStr &mnts = fload("/proc/self/mounts")),
|
||||||
|
mount(cQStr &dev, cQStr &mpoint, cQStr &moptns = nullptr),
|
||||||
|
like(cQStr &txt, cQSL &lst, uchar mode = Norm),
|
||||||
|
execsrch(cQStr &fname, cQStr &ppath = nullptr),
|
||||||
|
scopy(uchar mthd, cQStr &usr, cQStr &srcdir),
|
||||||
|
mkptable(cQStr &dev, cQStr &type = "msdos"),
|
||||||
|
crtfile(cQStr &path, cQStr &txt = nullptr),
|
||||||
|
like(int num, cSIL &lst, bool all = false),
|
||||||
|
access(cQStr &path, uchar mode = Read),
|
||||||
|
copy(cQStr &srcfile, cQStr &newfile),
|
||||||
|
setpflag(cQStr &part, cQStr &flags),
|
||||||
|
rename(cQStr &opath, cQStr &npath),
|
||||||
|
error(QStr txt, bool dbg = false),
|
||||||
|
cfgwrite(cQStr &file = cfgfile),
|
||||||
|
crtrpoint(cQStr &pname),
|
||||||
|
islnxfs(cQStr &path),
|
||||||
|
remove(cQStr &path),
|
||||||
|
lvprpr(bool iudata),
|
||||||
|
fopen(QFile &file),
|
||||||
|
umount(cQStr &dev),
|
||||||
|
isnum(cQStr &txt),
|
||||||
|
lock(uchar type);
|
||||||
|
|
||||||
|
static void readprttns(QSL &strlst),
|
||||||
|
readlvdevs(QSL &strlst),
|
||||||
|
delpart(cQStr &part),
|
||||||
|
unlock(uchar type),
|
||||||
|
delay(ushort msec),
|
||||||
|
print(cQStr &txt),
|
||||||
|
supgrade(),
|
||||||
|
pupgrade(),
|
||||||
|
thrdelay(),
|
||||||
|
cfgread(),
|
||||||
|
fssync(),
|
||||||
|
ldtltr();
|
||||||
|
|
||||||
|
protected:
|
||||||
|
void run();
|
||||||
|
|
||||||
|
private:
|
||||||
|
sb();
|
||||||
|
~sb();
|
||||||
|
|
||||||
|
static QTrn *SBtr;
|
||||||
|
static QSL *ThrdSlst;
|
||||||
|
static int sblock[4];
|
||||||
|
static uchar ThrdType, ThrdChr;
|
||||||
|
static bool ThrdBool, ThrdRslt;
|
||||||
|
|
||||||
|
static QStr fdbg(cQStr &path1, cQStr &path2 = nullptr),
|
||||||
|
rlink(cQStr &path, ushort blen);
|
||||||
|
|
||||||
|
static ullong devsize(cQStr &dev);
|
||||||
|
|
||||||
|
static bool rodir(QBA &ba, QUCL &ucl, cQStr &path, uchar hidden = False, cQSL &ilist = QSL(), uchar oplen = 0),
|
||||||
|
rodir(cQStr &path, QBA &ba, QUCL &ucl, ullong id = 0, uchar oplen = 0),
|
||||||
|
cerr(uchar type, cQStr &str1, cQStr &str2 = nullptr),
|
||||||
|
rodir(QUCL &ucl, cQStr &path, uchar oplen = 0),
|
||||||
|
rodir(QBA &ba, cQStr &path, uchar oplen = 0),
|
||||||
|
inclcheck(cQSL &ilist, cQStr &item);
|
||||||
|
|
||||||
|
uchar fcomp(cQStr &file1, cQStr &file2);
|
||||||
|
template<typename T1, typename T2> fnln bool crthlnk(const T1 &srclnk, const T2 &newlnk);
|
||||||
|
|
||||||
|
bool odir(QBAL &balst, cQStr &path, uchar hidden = False, cQSL &ilist = QSL(), cQStr &ppath = nullptr),
|
||||||
|
thrdsrestore(uchar mthd, cQStr &usr, cQStr &srcdir, cQStr &trgt, bool sfstab),
|
||||||
|
cpertime(cQStr &srcitem, cQStr &newitem, bool skel = false),
|
||||||
|
cpfile(cQStr &srcfile, cQStr &newfile, bool skel = false),
|
||||||
|
thrdscopy(uchar mthd, cQStr &usr, cQStr &srcdir),
|
||||||
|
recrmdir(cbstr &path, bool slimit = false),
|
||||||
|
cplink(cQStr &srclink, cQStr &newlink),
|
||||||
|
cpdir(cQStr &srcdir, cQStr &newdir),
|
||||||
|
exclcheck(cQSL &elist, cQStr &item),
|
||||||
|
lcomp(cQStr &link1, cQStr &link2),
|
||||||
|
thrdcrtrpoint(cQStr &trgt),
|
||||||
|
thrdlvprpr(bool iudata),
|
||||||
|
umnt(cbstr &dev);
|
||||||
|
|
||||||
|
void edetect(QSL &elst, bool spath = false);
|
||||||
|
};
|
||||||
|
|
||||||
|
inline QStr sb::left(cQStr &txt, short len)
|
||||||
|
{
|
||||||
|
return txt.length() > qAbs(len) ? txt.left(len > 0 ? len : txt.length() + len) : len > 0 ? txt : nullptr;
|
||||||
|
}
|
||||||
|
|
||||||
|
inline QStr sb::right(cQStr &txt, short len)
|
||||||
|
{
|
||||||
|
return txt.length() > qAbs(len) ? txt.right(len > 0 ? len : txt.length() + len) : len > 0 ? txt : nullptr;
|
||||||
|
}
|
||||||
|
|
||||||
|
inline QStr sb::mid(cQStr &txt, ushort start, ushort len)
|
||||||
|
{
|
||||||
|
return txt.length() >= start ? txt.length() - start + 1 > len ? txt.mid(start - 1, len) : txt.right(txt.length() - start + 1) : nullptr;
|
||||||
|
}
|
||||||
|
|
||||||
|
inline ushort sb::instr(cQStr &txt, cQStr &stxt, ushort start)
|
||||||
|
{
|
||||||
|
return txt.indexOf(stxt, start - 1) + 1;
|
||||||
|
}
|
||||||
|
|
||||||
|
inline ushort sb::rinstr(cQStr &txt, cQStr &stxt)
|
||||||
|
{
|
||||||
|
return txt.lastIndexOf(stxt) + 1;
|
||||||
|
}
|
||||||
|
|
||||||
|
inline bool sb::like(int num, cSIL &lst, bool all)
|
||||||
|
{
|
||||||
|
for(int val : lst)
|
||||||
|
if(all ? num != val : num == val) return ! all;
|
||||||
|
|
||||||
|
return all;
|
||||||
|
}
|
||||||
|
|
||||||
|
template<typename T> inline bool sb::exist(const T &path)
|
||||||
|
{
|
||||||
|
struct stat istat;
|
||||||
|
return ! lstat(bstr(path), &istat);
|
||||||
|
}
|
||||||
|
|
||||||
|
inline bool sb::islink(cQStr &path)
|
||||||
|
{
|
||||||
|
return QFileInfo(path).isSymLink();
|
||||||
|
}
|
||||||
|
|
||||||
|
inline bool sb::isfile(cQStr &path)
|
||||||
|
{
|
||||||
|
return QFileInfo(path).isFile();
|
||||||
|
}
|
||||||
|
|
||||||
|
inline bool sb::isdir(cQStr &path)
|
||||||
|
{
|
||||||
|
return QFileInfo(path).isDir();
|
||||||
|
}
|
||||||
|
|
||||||
|
template<typename T> inline uchar sb::stype(const T &path, bool flink)
|
||||||
|
{
|
||||||
|
struct stat istat;
|
||||||
|
if(flink ? stat(bstr(path), &istat) : lstat(bstr(path), &istat)) return Notexist;
|
||||||
|
|
||||||
|
switch(istat.st_mode & S_IFMT) {
|
||||||
|
case S_IFREG:
|
||||||
|
return Isfile;
|
||||||
|
case S_IFDIR:
|
||||||
|
return Isdir;
|
||||||
|
case S_IFLNK:
|
||||||
|
return Islink;
|
||||||
|
case S_IFBLK:
|
||||||
|
return Isblock;
|
||||||
|
default:
|
||||||
|
return Unknown;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
inline ullong sb::fsize(cQStr &path)
|
||||||
|
{
|
||||||
|
return QFileInfo(path).size();
|
||||||
|
}
|
||||||
|
|
||||||
|
template<typename T> ullong sb::dfree(const T &path)
|
||||||
|
{
|
||||||
|
struct statvfs dstat;
|
||||||
|
return statvfs(bstr(path), &dstat) ? 0 : dstat.f_bavail * dstat.f_bsize;
|
||||||
|
}
|
||||||
|
|
||||||
|
inline QStr sb::hunit(ullong size)
|
||||||
|
{
|
||||||
|
return size < 1024 ? QStr(QStr::number(size) % " B") : size < 1048576 ? QStr::number(qRound64(size * 100.0 / 1024.0) / 100.0) % " KiB" : size < 1073741824 ? QStr::number(qRound64(size * 100.0 / 1024.0 / 1024.0) / 100.0) % " MiB" : size < 1073741824000 ? QStr::number(qRound64(size * 100.0 / 1024.0 / 1024.0 / 1024.0) / 100.0) % " GiB" : QStr::number(qRound64(size * 100.0 / 1024.0 / 1024.0 / 1024.0 / 1024.0) / 100.0) % " TiB";
|
||||||
|
}
|
||||||
|
|
||||||
|
template<typename T1, typename T2> inline bool sb::issmfs(const T1 &item1, const T2 &item2)
|
||||||
|
{
|
||||||
|
struct stat istat[2];
|
||||||
|
return ! (stat(bstr(item1), &istat[0]) || stat(bstr(item2), &istat[1])) && istat[0].st_dev == istat[1].st_dev;
|
||||||
|
}
|
||||||
|
|
||||||
|
template<typename T> inline bool sb::crtdir(const T &path)
|
||||||
|
{
|
||||||
|
return mkdir(bstr(path), 0755) ? cerr(Crtdir, path) : true;
|
||||||
|
}
|
||||||
|
|
||||||
|
template<typename T> inline bool sb::rmfile(const T &file)
|
||||||
|
{
|
||||||
|
return unlink(bstr(file)) ? cerr(Rmfile, file) : true;
|
||||||
|
}
|
||||||
|
|
||||||
|
inline bool sb::isnum(cQStr &txt)
|
||||||
|
{
|
||||||
|
for(uchar a(0) ; a < txt.length() ; ++a)
|
||||||
|
if(! txt.at(a).isDigit()) return false;
|
||||||
|
|
||||||
|
return ! txt.isEmpty();
|
||||||
|
}
|
||||||
|
|
||||||
|
#endif
|
||||||
30
libsystemback/sblib_global.hpp
Normal file
@@ -0,0 +1,30 @@
|
|||||||
|
/*
|
||||||
|
* Copyright(C) 2014-2016, Krisztián Kende <nemh@freemail.hu>
|
||||||
|
*
|
||||||
|
* This file is part of the Systemback.
|
||||||
|
*
|
||||||
|
* The Systemback is free software; you can redistribute it and/or modify it under
|
||||||
|
* the terms of the GNU General Public License as published by the Free Software
|
||||||
|
* Foundation; either version 3 of the License, or (at your option) any later
|
||||||
|
* version.
|
||||||
|
*
|
||||||
|
* The Systemback is distributed in the hope that it will be useful, but WITHOUT
|
||||||
|
* ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS
|
||||||
|
* FOR A PARTICULAR PURPOSE. See the GNU General Public License for more details.
|
||||||
|
*
|
||||||
|
* You should have received a copy of the GNU General Public License along with the
|
||||||
|
* Systemback. If not, see <http://www.gnu.org/licenses>.
|
||||||
|
*/
|
||||||
|
|
||||||
|
#ifndef SBLIB_GLOBAL_HPP
|
||||||
|
#define SBLIB_GLOBAL_HPP
|
||||||
|
|
||||||
|
#include <QtGlobal>
|
||||||
|
|
||||||
|
#ifdef SYSTEMBACK_LIBRARY
|
||||||
|
#define SHARED_EXPORT_IMPORT Q_DECL_EXPORT
|
||||||
|
#else
|
||||||
|
#define SHARED_EXPORT_IMPORT Q_DECL_IMPORT
|
||||||
|
#endif
|
||||||
|
|
||||||
|
#endif
|
||||||
75
libsystemback/sbtypedef.hpp
Normal file
@@ -0,0 +1,75 @@
|
|||||||
|
/*
|
||||||
|
* Copyright(C) 2014-2016, Krisztián Kende <nemh@freemail.hu>
|
||||||
|
*
|
||||||
|
* This file is part of the Systemback.
|
||||||
|
*
|
||||||
|
* The Systemback is free software; you can redistribute it and/or modify it under
|
||||||
|
* the terms of the GNU General Public License as published by the Free Software
|
||||||
|
* Foundation; either version 3 of the License, or (at your option) any later
|
||||||
|
* version.
|
||||||
|
*
|
||||||
|
* The Systemback is distributed in the hope that it will be useful, but WITHOUT
|
||||||
|
* ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS
|
||||||
|
* FOR A PARTICULAR PURPOSE. See the GNU General Public License for more details.
|
||||||
|
*
|
||||||
|
* You should have received a copy of the GNU General Public License along with the
|
||||||
|
* Systemback. If not, see <http://www.gnu.org/licenses>.
|
||||||
|
*/
|
||||||
|
|
||||||
|
#ifndef SBTYPEDEF_HPP
|
||||||
|
#define SBTYPEDEF_HPP
|
||||||
|
|
||||||
|
#include <QtWidgets/QDesktopWidget>
|
||||||
|
#include <QtWidgets/QTableWidget>
|
||||||
|
#include <QtWidgets/QRadioButton>
|
||||||
|
#include <QtWidgets/QListWidget>
|
||||||
|
#include <QtWidgets/QPushButton>
|
||||||
|
#include <QtWidgets/QLineEdit>
|
||||||
|
#include <QtWidgets/QComboBox>
|
||||||
|
#include <QtWidgets/QCheckBox>
|
||||||
|
#include <QtWidgets/QLabel>
|
||||||
|
#include <QTranslator>
|
||||||
|
#include <QTextStream>
|
||||||
|
#include <QStringList>
|
||||||
|
|
||||||
|
class bstr;
|
||||||
|
|
||||||
|
typedef QTranslator QTrn;
|
||||||
|
typedef QCursor *QCr;
|
||||||
|
typedef QDesktopWidget *QDW;
|
||||||
|
typedef QWidget *QWdt;
|
||||||
|
typedef QTableWidget *QTblW;
|
||||||
|
typedef QListWidget *QLW;
|
||||||
|
typedef QPushButton *QPB;
|
||||||
|
typedef QLineEdit *QLE;
|
||||||
|
typedef QComboBox *QCbB;
|
||||||
|
typedef QRadioButton *QRB;
|
||||||
|
typedef QCheckBox *QCB;
|
||||||
|
typedef QLabel *QLbl;
|
||||||
|
typedef QTextStream QTS;
|
||||||
|
typedef QList<QWidget *> QWL;
|
||||||
|
typedef QList<QComboBox *> QCbBL;
|
||||||
|
typedef QList<QLabel *> QLbL;
|
||||||
|
typedef const QStringList cQSL;
|
||||||
|
typedef QStringList QSL;
|
||||||
|
typedef QList<QByteArray> QBAL;
|
||||||
|
typedef QList<QList<uchar>> QUCLL;
|
||||||
|
typedef QList<long long> QLIL;
|
||||||
|
typedef const QList<uchar> cQUCL;
|
||||||
|
typedef QList<uchar> QUCL;
|
||||||
|
typedef const std::initializer_list<int> cSIL;
|
||||||
|
typedef const QString cQStr;
|
||||||
|
typedef QString QStr;
|
||||||
|
typedef const QByteArray cQBA;
|
||||||
|
typedef QByteArray QBA;
|
||||||
|
typedef const QChar cQChar;
|
||||||
|
typedef const QRect cQRect;
|
||||||
|
typedef const QSize cQSize;
|
||||||
|
typedef const QPoint cQPoint;
|
||||||
|
typedef const bstr cbstr;
|
||||||
|
typedef unsigned long long ullong;
|
||||||
|
typedef long long llong;
|
||||||
|
typedef const char cchar;
|
||||||
|
typedef signed char schar;
|
||||||
|
|
||||||
|
#endif
|
||||||
1
libsystemback/version
Normal file
@@ -0,0 +1 @@
|
|||||||
|
1.8.402_05.16.2016
|
||||||
5
libsystemback/version.qrc
Normal file
@@ -0,0 +1,5 @@
|
|||||||
|
<RCC>
|
||||||
|
<qresource prefix="/">
|
||||||
|
<file>version</file>
|
||||||
|
</qresource>
|
||||||
|
</RCC>
|
||||||
10
sbschedule-kde.desktop
Normal file
@@ -0,0 +1,10 @@
|
|||||||
|
[Desktop Entry]
|
||||||
|
Encoding=UTF-8
|
||||||
|
Version=1.0
|
||||||
|
Name=Systemback scheduler daemon
|
||||||
|
Exec=/usr/lib/systemback/sbsustart scheduler
|
||||||
|
Type=Application
|
||||||
|
Icon=systemback
|
||||||
|
Terminal=false
|
||||||
|
OnlyShowIn=KDE;
|
||||||
|
NoDisplay=true
|
||||||
10
sbschedule.desktop
Normal file
@@ -0,0 +1,10 @@
|
|||||||
|
[Desktop Entry]
|
||||||
|
Encoding=UTF-8
|
||||||
|
Version=1.0
|
||||||
|
Name=Systemback scheduler daemon
|
||||||
|
Exec=/usr/lib/systemback/sbsustart scheduler gtk+
|
||||||
|
Type=Application
|
||||||
|
Icon=systemback
|
||||||
|
Terminal=false
|
||||||
|
NotShowIn=KDE;
|
||||||
|
NoDisplay=true
|
||||||
40
sbscheduler/main.cpp
Normal file
@@ -0,0 +1,40 @@
|
|||||||
|
/*
|
||||||
|
* Copyright(C) 2014-2016, Krisztián Kende <nemh@freemail.hu>
|
||||||
|
*
|
||||||
|
* This file is part of the Systemback.
|
||||||
|
*
|
||||||
|
* The Systemback is free software; you can redistribute it and/or modify it under
|
||||||
|
* the terms of the GNU General Public License as published by the Free Software
|
||||||
|
* Foundation; either version 3 of the License, or (at your option) any later
|
||||||
|
* version.
|
||||||
|
*
|
||||||
|
* The Systemback is distributed in the hope that it will be useful, but WITHOUT
|
||||||
|
* ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS
|
||||||
|
* FOR A PARTICULAR PURPOSE. See the GNU General Public License for more details.
|
||||||
|
*
|
||||||
|
* You should have received a copy of the GNU General Public License along with the
|
||||||
|
* Systemback. If not, see <http://www.gnu.org/licenses>.
|
||||||
|
*/
|
||||||
|
|
||||||
|
#include "sbscheduler.hpp"
|
||||||
|
#include <QTimer>
|
||||||
|
|
||||||
|
QDateTime scheduler::cfglmd;
|
||||||
|
|
||||||
|
int main(int argc, char *argv[])
|
||||||
|
{
|
||||||
|
QCoreApplication a(argc, argv);
|
||||||
|
sb::ldtltr();
|
||||||
|
scheduler s;
|
||||||
|
|
||||||
|
QTimer::singleShot(0, &s,
|
||||||
|
#if QT_VERSION < QT_VERSION_CHECK(5, 4, 0)
|
||||||
|
SLOT(main())
|
||||||
|
#else
|
||||||
|
&scheduler::main
|
||||||
|
#endif
|
||||||
|
);
|
||||||
|
|
||||||
|
uchar rv(a.exec());
|
||||||
|
return rv;
|
||||||
|
}
|
||||||
145
sbscheduler/sbscheduler.cpp
Normal file
@@ -0,0 +1,145 @@
|
|||||||
|
/*
|
||||||
|
* Copyright(C) 2014-2016, Krisztián Kende <nemh@freemail.hu>
|
||||||
|
*
|
||||||
|
* This file is part of the Systemback.
|
||||||
|
*
|
||||||
|
* The Systemback is free software; you can redistribute it and/or modify it under
|
||||||
|
* the terms of the GNU General Public License as published by the Free Software
|
||||||
|
* Foundation; either version 3 of the License, or (at your option) any later
|
||||||
|
* version.
|
||||||
|
*
|
||||||
|
* The Systemback is distributed in the hope that it will be useful, but WITHOUT
|
||||||
|
* ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS
|
||||||
|
* FOR A PARTICULAR PURPOSE. See the GNU General Public License for more details.
|
||||||
|
*
|
||||||
|
* You should have received a copy of the GNU General Public License along with the
|
||||||
|
* Systemback. If not, see <http://www.gnu.org/licenses>.
|
||||||
|
*/
|
||||||
|
|
||||||
|
#include "sbscheduler.hpp"
|
||||||
|
#include <QDir>
|
||||||
|
|
||||||
|
void scheduler::main()
|
||||||
|
{
|
||||||
|
{
|
||||||
|
QSL args(qApp->arguments());
|
||||||
|
|
||||||
|
uchar rv(args.count() != 2 ? 1
|
||||||
|
: sb::schdlr[1] != "false" && (sb::schdlr[1] == "everyone" || sb::right(sb::schdlr[1], -1).split(',').contains(args.at(1))) ? 2
|
||||||
|
: getuid() + getgid() ? 3
|
||||||
|
: sb::isfile("/cdrom/casper/filesystem.squashfs") || sb::isfile("/lib/live/mount/medium/live/filesystem.squashfs") ? 4
|
||||||
|
: ! sb::lock(sb::Schdlrlock) ? 5
|
||||||
|
: daemon(0, 0) ? 6
|
||||||
|
: [&]() -> uchar {
|
||||||
|
sb::delay(100);
|
||||||
|
return sb::lock(sb::Schdlrlock) && sb::crtfile(*(pfile = new QStr(sb::isdir("/run") ? "/run/sbscheduler.pid" : "/var/run/sbscheduler.pid")), QStr::number(qApp->applicationPid())) ? 0 : 255;
|
||||||
|
}());
|
||||||
|
|
||||||
|
if(rv)
|
||||||
|
{
|
||||||
|
if(rv < 255) sb::error("\n " % sb::tr("Cannot start the Systemback scheduler daemon!") % "\n\n " % [rv] {
|
||||||
|
switch(rv) {
|
||||||
|
case 1:
|
||||||
|
return sb::tr("Missing, wrong or too much argument(s).");
|
||||||
|
case 2:
|
||||||
|
return sb::tr("The process is disabled for this user.");
|
||||||
|
case 3:
|
||||||
|
return sb::tr("Root privileges are required.");
|
||||||
|
case 4:
|
||||||
|
return sb::tr("This system is a Live.");
|
||||||
|
case 5:
|
||||||
|
return sb::tr("Already running.");
|
||||||
|
default:
|
||||||
|
return sb::tr("Unable to daemonize.");
|
||||||
|
}
|
||||||
|
}() % "\n\n");
|
||||||
|
|
||||||
|
return qApp->exit(rv);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
QDateTime pflmd(QFileInfo(*pfile).lastModified());
|
||||||
|
sleep(290);
|
||||||
|
|
||||||
|
forever
|
||||||
|
{
|
||||||
|
sleep(10);
|
||||||
|
|
||||||
|
if(! sb::isfile(*pfile) || (pflmd != QFileInfo(*pfile).lastModified() && sb::fload(*pfile) != QBA::number(qApp->applicationPid())))
|
||||||
|
{
|
||||||
|
sb::unlock(sb::Schdlrlock), sb::exec("sbscheduler " % qApp->arguments().at(1), sb::Silent | sb::Bckgrnd);
|
||||||
|
break;
|
||||||
|
}
|
||||||
|
|
||||||
|
if(! sb::isfile(cfgfile) || cfglmd != QFileInfo(cfgfile).lastModified()) sb::cfgread(),
|
||||||
|
cfglmd = QFileInfo(cfgfile).lastModified();
|
||||||
|
|
||||||
|
if(! (sb::isdir(sb::sdir[1]) && sb::access(sb::sdir[1], sb::Write)))
|
||||||
|
sleep(50);
|
||||||
|
else if(! sb::isfile(sb::sdir[1] % "/.sbschedule"))
|
||||||
|
sb::crtfile(sb::sdir[1] % "/.sbschedule");
|
||||||
|
else if(! sb::schdle[0])
|
||||||
|
sleep(1790);
|
||||||
|
else if(QFileInfo(sb::sdir[1] % "/.sbschedule").lastModified().secsTo(QDateTime::currentDateTime()) / 60 >= sb::schdle[1] * 1440 + sb::schdle[2] * 60 + sb::schdle[3] && sb::lock(sb::Sblock))
|
||||||
|
{
|
||||||
|
if(! sb::lock(sb::Dpkglock) || [] {
|
||||||
|
if(! sb::lock(sb::Aptlock))
|
||||||
|
{
|
||||||
|
sb::unlock(sb::Dpkglock);
|
||||||
|
return true;
|
||||||
|
}
|
||||||
|
|
||||||
|
return false;
|
||||||
|
}())
|
||||||
|
|
||||||
|
sb::unlock(sb::Sblock);
|
||||||
|
else
|
||||||
|
{
|
||||||
|
if(sb::schdle[5] || ! sb::execsrch("systemback"))
|
||||||
|
newrpnt();
|
||||||
|
else
|
||||||
|
{
|
||||||
|
QStr xauth("/tmp/sbXauthority-" % sb::rndstr()), usrhm(qgetenv("HOME"));
|
||||||
|
|
||||||
|
if((qEnvironmentVariableIsSet("XAUTHORITY") && QFile(qgetenv("XAUTHORITY")).copy(xauth)) || [&] {
|
||||||
|
QStr path("/home/" % qApp->arguments().at(1) % "/.Xauthority");
|
||||||
|
return (sb::isfile(path) && QFile(path).copy(xauth)) || (sb::isfile(path = usrhm % "/.Xauthority") && QFile(path).copy(xauth));
|
||||||
|
}()) sb::exec("systemback schedule", sb::Wait, "XAUTHORITY=" % xauth),
|
||||||
|
sb::rmfile(xauth);
|
||||||
|
}
|
||||||
|
|
||||||
|
sb::unlock(sb::Sblock), sb::unlock(sb::Dpkglock), sb::unlock(sb::Aptlock), sleep(50);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
qApp->quit();
|
||||||
|
}
|
||||||
|
|
||||||
|
void scheduler::newrpnt()
|
||||||
|
{
|
||||||
|
sb::pupgrade();
|
||||||
|
|
||||||
|
for(cQStr &item : QDir(sb::sdir[1]).entryList(QDir::Dirs | QDir::Hidden | QDir::NoSymLinks | QDir::NoDotAndDotDot))
|
||||||
|
if(sb::like(item, {"_.DELETED_*", "_.S00_*"}) && ! sb::remove(sb::sdir[1] % '/' % item)) return;
|
||||||
|
|
||||||
|
for(uchar a(9) ; a > 1 ; --a)
|
||||||
|
if(! sb::pnames[a].isEmpty() && (a == 9 || a > 2 ? sb::pnumber < a + 2 : sb::pnumber == 3) && ! (QFile::rename(sb::sdir[1] % (a < 9 ? QStr("/S0" % QStr::number(a + 1)) : "/S10") % '_' % sb::pnames[a], sb::sdir[1] % "/.DELETED_" % sb::pnames[a]) && sb::remove(sb::sdir[1] % "/.DELETED_" % sb::pnames[a]))) return;
|
||||||
|
|
||||||
|
QStr dtime(QDateTime().currentDateTime().toString("yyyy-MM-dd,hh.mm.ss"));
|
||||||
|
|
||||||
|
if(sb::crtrpoint(dtime))
|
||||||
|
{
|
||||||
|
for(uchar a(0) ; a < 9 && sb::isdir(sb::sdir[1] % "/S0" % QStr::number(a + 1) % '_' % sb::pnames[a]) ; ++a)
|
||||||
|
if(! QFile::rename(sb::sdir[1] % "/S0" % QStr::number(a + 1) % '_' % sb::pnames[a], sb::sdir[1] % (a < 8 ? "/S0" : "/S") % QStr::number(a + 2) % '_' % sb::pnames[a])) return;
|
||||||
|
|
||||||
|
if(! QFile::rename(sb::sdir[1] % "/.S00_" % dtime, sb::sdir[1] % "/S01_" % dtime)) return;
|
||||||
|
}
|
||||||
|
else if(sb::dfree(sb::sdir[1]) < 104857600)
|
||||||
|
sb::remove(sb::sdir[1] % "/.S00_" % dtime);
|
||||||
|
else
|
||||||
|
return;
|
||||||
|
|
||||||
|
sb::crtfile(sb::sdir[1] % "/.sbschedule"), sb::fssync();
|
||||||
|
if(sb::ecache) sb::crtfile("/proc/sys/vm/drop_caches", "3");
|
||||||
|
}
|
||||||
52
sbscheduler/sbscheduler.hpp
Normal file
@@ -0,0 +1,52 @@
|
|||||||
|
/*
|
||||||
|
* Copyright(C) 2014-2016, Krisztián Kende <nemh@freemail.hu>
|
||||||
|
*
|
||||||
|
* This file is part of the Systemback.
|
||||||
|
*
|
||||||
|
* The Systemback is free software; you can redistribute it and/or modify it under
|
||||||
|
* the terms of the GNU General Public License as published by the Free Software
|
||||||
|
* Foundation; either version 3 of the License, or (at your option) any later
|
||||||
|
* version.
|
||||||
|
*
|
||||||
|
* The Systemback is distributed in the hope that it will be useful, but WITHOUT
|
||||||
|
* ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS
|
||||||
|
* FOR A PARTICULAR PURPOSE. See the GNU General Public License for more details.
|
||||||
|
*
|
||||||
|
* You should have received a copy of the GNU General Public License along with the
|
||||||
|
* Systemback. If not, see <http://www.gnu.org/licenses>.
|
||||||
|
*/
|
||||||
|
|
||||||
|
#ifndef SBSCHEDULER_HPP
|
||||||
|
#define SBSCHEDULER_HPP
|
||||||
|
|
||||||
|
#include "../libsystemback/sblib.hpp"
|
||||||
|
#include <QDateTime>
|
||||||
|
#include <QObject>
|
||||||
|
|
||||||
|
class scheduler : public QObject
|
||||||
|
{
|
||||||
|
Q_OBJECT
|
||||||
|
|
||||||
|
public:
|
||||||
|
inline scheduler() : pfile(nullptr) {}
|
||||||
|
~scheduler();
|
||||||
|
|
||||||
|
static QDateTime cfglmd;
|
||||||
|
|
||||||
|
#if QT_VERSION < QT_VERSION_CHECK(5, 4, 0)
|
||||||
|
public slots:
|
||||||
|
#endif
|
||||||
|
void main();
|
||||||
|
|
||||||
|
private:
|
||||||
|
QStr *pfile;
|
||||||
|
|
||||||
|
void newrpnt();
|
||||||
|
};
|
||||||
|
|
||||||
|
inline scheduler::~scheduler()
|
||||||
|
{
|
||||||
|
if(pfile) delete pfile;
|
||||||
|
}
|
||||||
|
|
||||||
|
#endif
|
||||||
46
sbscheduler/sbscheduler.pro
Normal file
@@ -0,0 +1,46 @@
|
|||||||
|
QT -= gui
|
||||||
|
QT += core
|
||||||
|
|
||||||
|
TARGET = sbscheduler
|
||||||
|
|
||||||
|
CONFIG -= app_bundle
|
||||||
|
CONFIG += console \
|
||||||
|
c++11 \
|
||||||
|
exceptions_off
|
||||||
|
|
||||||
|
TEMPLATE = app
|
||||||
|
|
||||||
|
DEFINES += _FILE_OFFSET_BITS=64
|
||||||
|
|
||||||
|
SOURCES += main.cpp \
|
||||||
|
sbscheduler.cpp
|
||||||
|
|
||||||
|
HEADERS += sbscheduler.hpp
|
||||||
|
|
||||||
|
QMAKE_CXXFLAGS += -g \
|
||||||
|
-fno-rtti \
|
||||||
|
-fvisibility=hidden \
|
||||||
|
-fvisibility-inlines-hidden \
|
||||||
|
-fno-asynchronous-unwind-tables
|
||||||
|
|
||||||
|
CONFIG(debug, debug|release) {
|
||||||
|
QMAKE_CXXFLAGS_WARN_ON += -Wextra \
|
||||||
|
-Wshadow \
|
||||||
|
-Werror
|
||||||
|
}
|
||||||
|
|
||||||
|
QMAKE_LFLAGS += -g \
|
||||||
|
-Wl,-rpath=/usr/lib/systemback \
|
||||||
|
-Wl,--as-needed \
|
||||||
|
-fuse-ld=gold \
|
||||||
|
-Wl,-z,relro
|
||||||
|
|
||||||
|
! equals(QMAKE_CXX, clang++) {
|
||||||
|
QMAKE_CXXFLAGS += -flto
|
||||||
|
QMAKE_LFLAGS += -flto
|
||||||
|
}
|
||||||
|
|
||||||
|
LIBS += -L../libsystemback \
|
||||||
|
-lsystemback
|
||||||
|
|
||||||
|
INCLUDEPATH = ../libsystemback
|
||||||
63
sbsustart/main.cpp
Normal file
@@ -0,0 +1,63 @@
|
|||||||
|
/*
|
||||||
|
* Copyright(C) 2014-2016, Krisztián Kende <nemh@freemail.hu>
|
||||||
|
*
|
||||||
|
* This file is part of the Systemback.
|
||||||
|
*
|
||||||
|
* The Systemback is free software; you can redistribute it and/or modify it under
|
||||||
|
* the terms of the GNU General Public License as published by the Free Software
|
||||||
|
* Foundation; either version 3 of the License, or (at your option) any later
|
||||||
|
* version.
|
||||||
|
*
|
||||||
|
* The Systemback is distributed in the hope that it will be useful, but WITHOUT
|
||||||
|
* ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS
|
||||||
|
* FOR A PARTICULAR PURPOSE. See the GNU General Public License for more details.
|
||||||
|
*
|
||||||
|
* You should have received a copy of the GNU General Public License along with the
|
||||||
|
* Systemback. If not, see <http://www.gnu.org/licenses>.
|
||||||
|
*/
|
||||||
|
|
||||||
|
#include "sbsustart.hpp"
|
||||||
|
#include <QTimer>
|
||||||
|
|
||||||
|
uint sustart::uid(getuid());
|
||||||
|
|
||||||
|
int main(int argc, char *argv[])
|
||||||
|
{
|
||||||
|
#if QT_VERSION >= QT_VERSION_CHECK(5, 3, 0)
|
||||||
|
if(sustart::uid && setuid(0) && sustart::uid != geteuid())
|
||||||
|
{
|
||||||
|
QStr arg1(argv[1]);
|
||||||
|
|
||||||
|
if(! sb::like(arg1, {"_systemback_", "_scheduler_"}))
|
||||||
|
{
|
||||||
|
sb::error("\n Missing, wrong or too much argument(s).\n\n");
|
||||||
|
return 2;
|
||||||
|
}
|
||||||
|
|
||||||
|
QStr emsg("Cannot start Systemback " % QStr(arg1 == "systemback" ? "graphical user interface" : "scheduler daemon") % "!\n\nUnable to get root permissions.");
|
||||||
|
|
||||||
|
if(seteuid(sustart::uid))
|
||||||
|
sb::error("\n " % emsg.replace("\n\n", "\n\n ") % "\n\n");
|
||||||
|
else
|
||||||
|
sb::exec((sb::execsrch("zenity") ? "zenity --title=Systemback --error --text=\"" : "kdialog --title=Systemback --error=\"") % emsg % '\"', sb::Bckgrnd);
|
||||||
|
|
||||||
|
return 1;
|
||||||
|
}
|
||||||
|
#endif
|
||||||
|
|
||||||
|
QCoreApplication a(argc, argv);
|
||||||
|
if(sb::dbglev) sb::dbglev = sb::Nodbg;
|
||||||
|
sb::ldtltr();
|
||||||
|
sustart s;
|
||||||
|
|
||||||
|
QTimer::singleShot(0, &s,
|
||||||
|
#if QT_VERSION < QT_VERSION_CHECK(5, 4, 0)
|
||||||
|
SLOT(main())
|
||||||
|
#else
|
||||||
|
&sustart::main
|
||||||
|
#endif
|
||||||
|
);
|
||||||
|
|
||||||
|
uchar rv(a.exec());
|
||||||
|
return rv;
|
||||||
|
}
|
||||||
140
sbsustart/sbsustart.cpp
Normal file
@@ -0,0 +1,140 @@
|
|||||||
|
/*
|
||||||
|
* Copyright(C) 2014-2016, Krisztián Kende <nemh@freemail.hu>
|
||||||
|
*
|
||||||
|
* This file is part of the Systemback.
|
||||||
|
*
|
||||||
|
* The Systemback is free software; you can redistribute it and/or modify it under
|
||||||
|
* the terms of the GNU General Public License as published by the Free Software
|
||||||
|
* Foundation; either version 3 of the License, or (at your option) any later
|
||||||
|
* version.
|
||||||
|
*
|
||||||
|
* The Systemback is distributed in the hope that it will be useful, but WITHOUT
|
||||||
|
* ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS
|
||||||
|
* FOR A PARTICULAR PURPOSE. See the GNU General Public License for more details.
|
||||||
|
*
|
||||||
|
* You should have received a copy of the GNU General Public License along with the
|
||||||
|
* Systemback. If not, see <http://www.gnu.org/licenses>.
|
||||||
|
*/
|
||||||
|
|
||||||
|
#include "sbsustart.hpp"
|
||||||
|
#include <QProcess>
|
||||||
|
|
||||||
|
void sustart::main()
|
||||||
|
{
|
||||||
|
bool silent;
|
||||||
|
|
||||||
|
{
|
||||||
|
QSL args(qApp->arguments());
|
||||||
|
|
||||||
|
uchar mode([&] {
|
||||||
|
switch(args.count()) {
|
||||||
|
case 1:
|
||||||
|
if(args.at(0).endsWith("systemback-sustart"))
|
||||||
|
{
|
||||||
|
silent = false;
|
||||||
|
return Systemback;
|
||||||
|
}
|
||||||
|
|
||||||
|
break;
|
||||||
|
case 2 ... 3:
|
||||||
|
silent = true;
|
||||||
|
|
||||||
|
if(args.at(1) == "systemback")
|
||||||
|
return Systemback;
|
||||||
|
else if(args.at(1) == "finstall")
|
||||||
|
return Finstall;
|
||||||
|
else if(args.at(1) == "scheduler")
|
||||||
|
return Scheduler;
|
||||||
|
}
|
||||||
|
|
||||||
|
return Unknown;
|
||||||
|
}()), rv(mode ? [&, mode] {
|
||||||
|
QStr uname, usrhm;
|
||||||
|
|
||||||
|
if(! uid)
|
||||||
|
uname = "root", usrhm = "/root";
|
||||||
|
else
|
||||||
|
{
|
||||||
|
QFile file("/etc/passwd");
|
||||||
|
|
||||||
|
if(sb::fopen(file))
|
||||||
|
while(! file.atEnd())
|
||||||
|
{
|
||||||
|
QStr line(file.readLine().trimmed());
|
||||||
|
|
||||||
|
if(line.contains("x:" % QStr::number(uid) % ':'))
|
||||||
|
{
|
||||||
|
QSL uslst(line.split(':'));
|
||||||
|
uname = uslst.at(0), usrhm = uslst.at(5);
|
||||||
|
break;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
if(uname.isEmpty() || usrhm.isEmpty()) return 3;
|
||||||
|
}
|
||||||
|
|
||||||
|
bool uidinr(getuid()), gidinr(getgid());
|
||||||
|
|
||||||
|
if(uidinr || gidinr)
|
||||||
|
{
|
||||||
|
if((uidinr && setuid(0)) || (gidinr && setgid(0))) return 3;
|
||||||
|
|
||||||
|
auto clrenv([](cQBA &uhm, cQStr &xpath = nullptr) {
|
||||||
|
QSL excl{"_DISPLAY_", "_PATH_", "_LANG_", "_XAUTHORITY_", "_DBGLEV_"};
|
||||||
|
|
||||||
|
for(cQStr &cvar : QProcess::systemEnvironment())
|
||||||
|
{
|
||||||
|
QStr var(sb::left(cvar, sb::instr(cvar, "=") - 1));
|
||||||
|
if(! (sb::like(var, excl) || qunsetenv(bstr(var)))) return false;
|
||||||
|
}
|
||||||
|
|
||||||
|
if(! (qputenv("USER", "root") && qputenv("HOME", uhm) && qputenv("LOGNAME", "root") && qputenv("SHELL", "/bin/bash") && (xpath.isEmpty() || qputenv("XAUTHORITY", xpath.toUtf8())))) return false;
|
||||||
|
return true;
|
||||||
|
});
|
||||||
|
|
||||||
|
if(mode == Scheduler)
|
||||||
|
{
|
||||||
|
if(! clrenv(usrhm.toUtf8())) return 3;
|
||||||
|
cmd = new QStr("sbscheduler " % uname);
|
||||||
|
}
|
||||||
|
else
|
||||||
|
{
|
||||||
|
QStr xauth("/tmp/sbXauthority-" % sb::rndstr());
|
||||||
|
if((qEnvironmentVariableIsEmpty("XAUTHORITY") || ! QFile(qgetenv("XAUTHORITY")).copy(xauth)) && ! ((sb::isfile("/home/" % uname % "/.Xauthority") && QFile("/home/" % uname % "/.Xauthority").copy(xauth)) || (sb::isfile(usrhm % "/.Xauthority") && QFile(usrhm % "/.Xauthority").copy(xauth)))) return 4;
|
||||||
|
if(! clrenv("/root", xauth)) return 3;
|
||||||
|
cmd = new QStr("systemback " % (mode == Finstall ? QStr("finstall ") : "authorization " % uname));
|
||||||
|
}
|
||||||
|
}
|
||||||
|
else
|
||||||
|
cmd = new QStr(mode == Scheduler ? [&]() -> QStr {
|
||||||
|
qputenv("HOME", usrhm.toUtf8());
|
||||||
|
return "sbscheduler " % uname;
|
||||||
|
}() : "systemback" % QStr(mode == Finstall ? " finstall" : nullptr));
|
||||||
|
|
||||||
|
return 0;
|
||||||
|
}() : 2);
|
||||||
|
|
||||||
|
if(rv)
|
||||||
|
{
|
||||||
|
if(rv == 2)
|
||||||
|
sb::error("\n " % sb::tr("Missing, wrong or too much argument(s).") % "\n\n");
|
||||||
|
else
|
||||||
|
{
|
||||||
|
QStr emsg((mode == Scheduler ? sb::tr("Cannot start the Systemback scheduler daemon!") : sb::tr("Cannot start the Systemback graphical user interface!")) % "\n\n" % (rv == 3 ? sb::tr("Unable to get root permissions.") : sb::tr("Unable to connect to the X server.")));
|
||||||
|
|
||||||
|
#if QT_VERSION < QT_VERSION_CHECK(5, 3, 0)
|
||||||
|
if(uid != geteuid() && seteuid(uid))
|
||||||
|
sb::error("\n " % emsg.replace("\n\n", "\n\n ") % "\n\n");
|
||||||
|
else
|
||||||
|
#endif
|
||||||
|
sb::exec((sb::execsrch("zenity") ? "zenity --title=Systemback --error --text=\"" : "kdialog --title=Systemback --error=\"") % emsg % '\"', sb::Bckgrnd);
|
||||||
|
}
|
||||||
|
|
||||||
|
return qApp->exit(rv);
|
||||||
|
}
|
||||||
|
|
||||||
|
if(args.count() == 3 && args.at(2) == "gtk+") qputenv("QT_STYLE_OVERRIDE", "gtk+");
|
||||||
|
}
|
||||||
|
|
||||||
|
qApp->exit(silent ? sb::exec(*cmd, sb::Silent | sb::Wait, "DBGLEV=0") : sb::exec(*cmd, sb::Wait));
|
||||||
|
}
|
||||||
51
sbsustart/sbsustart.hpp
Normal file
@@ -0,0 +1,51 @@
|
|||||||
|
/*
|
||||||
|
* Copyright(C) 2014-2016, Krisztián Kende <nemh@freemail.hu>
|
||||||
|
*
|
||||||
|
* This file is part of the Systemback.
|
||||||
|
*
|
||||||
|
* The Systemback is free software; you can redistribute it and/or modify it under
|
||||||
|
* the terms of the GNU General Public License as published by the Free Software
|
||||||
|
* Foundation; either version 3 of the License, or (at your option) any later
|
||||||
|
* version.
|
||||||
|
*
|
||||||
|
* The Systemback is distributed in the hope that it will be useful, but WITHOUT
|
||||||
|
* ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS
|
||||||
|
* FOR A PARTICULAR PURPOSE. See the GNU General Public License for more details.
|
||||||
|
*
|
||||||
|
* You should have received a copy of the GNU General Public License along with the
|
||||||
|
* Systemback. If not, see <http://www.gnu.org/licenses>.
|
||||||
|
*/
|
||||||
|
|
||||||
|
#ifndef SBSUSTART_HPP
|
||||||
|
#define SBSUSTART_HPP
|
||||||
|
|
||||||
|
#include "../libsystemback/sblib.hpp"
|
||||||
|
#include <QObject>
|
||||||
|
|
||||||
|
class sustart : public QObject
|
||||||
|
{
|
||||||
|
Q_OBJECT
|
||||||
|
|
||||||
|
public:
|
||||||
|
inline sustart() : cmd(nullptr) {}
|
||||||
|
~sustart();
|
||||||
|
|
||||||
|
static uint uid;
|
||||||
|
|
||||||
|
#if QT_VERSION < QT_VERSION_CHECK(5, 4, 0)
|
||||||
|
public slots:
|
||||||
|
#endif
|
||||||
|
void main();
|
||||||
|
|
||||||
|
private:
|
||||||
|
enum { Unknown = 0, Systemback = 1, Finstall = 2, Scheduler = 3 };
|
||||||
|
|
||||||
|
QStr *cmd;
|
||||||
|
};
|
||||||
|
|
||||||
|
inline sustart::~sustart()
|
||||||
|
{
|
||||||
|
if(cmd) delete cmd;
|
||||||
|
}
|
||||||
|
|
||||||
|
#endif
|
||||||
46
sbsustart/sbsustart.pro
Normal file
@@ -0,0 +1,46 @@
|
|||||||
|
QT -= gui
|
||||||
|
QT += core
|
||||||
|
|
||||||
|
TARGET = sbsustart
|
||||||
|
|
||||||
|
CONFIG -= app_bundle
|
||||||
|
CONFIG += console \
|
||||||
|
c++11 \
|
||||||
|
exceptions_off
|
||||||
|
|
||||||
|
TEMPLATE = app
|
||||||
|
|
||||||
|
DEFINES += _FILE_OFFSET_BITS=64
|
||||||
|
|
||||||
|
SOURCES += main.cpp \
|
||||||
|
sbsustart.cpp
|
||||||
|
|
||||||
|
HEADERS += sbsustart.hpp
|
||||||
|
|
||||||
|
QMAKE_CXXFLAGS += -g \
|
||||||
|
-fno-rtti \
|
||||||
|
-fvisibility=hidden \
|
||||||
|
-fvisibility-inlines-hidden \
|
||||||
|
-fno-asynchronous-unwind-tables
|
||||||
|
|
||||||
|
CONFIG(debug, debug|release) {
|
||||||
|
QMAKE_CXXFLAGS_WARN_ON += -Wextra \
|
||||||
|
-Wshadow \
|
||||||
|
-Werror
|
||||||
|
}
|
||||||
|
|
||||||
|
QMAKE_LFLAGS += -g \
|
||||||
|
-Wl,-rpath=/usr/lib/systemback \
|
||||||
|
-Wl,--as-needed \
|
||||||
|
-fuse-ld=gold \
|
||||||
|
-Wl,-z,relro
|
||||||
|
|
||||||
|
! equals(QMAKE_CXX, clang++) {
|
||||||
|
QMAKE_CXXFLAGS += -flto
|
||||||
|
QMAKE_LFLAGS += -flto
|
||||||
|
}
|
||||||
|
|
||||||
|
LIBS += -L../libsystemback \
|
||||||
|
-lsystemback
|
||||||
|
|
||||||
|
INCLUDEPATH = ../libsystemback
|
||||||
26
sbsysupgrade/sbsysupgrade.cpp
Normal file
@@ -0,0 +1,26 @@
|
|||||||
|
/*
|
||||||
|
* Copyright(C) 2014-2016, Krisztián Kende <nemh@freemail.hu>
|
||||||
|
*
|
||||||
|
* This file is part of the Systemback.
|
||||||
|
*
|
||||||
|
* The Systemback is free software; you can redistribute it and/or modify it under
|
||||||
|
* the terms of the GNU General Public License as published by the Free Software
|
||||||
|
* Foundation; either version 3 of the License, or (at your option) any later
|
||||||
|
* version.
|
||||||
|
*
|
||||||
|
* The Systemback is distributed in the hope that it will be useful, but WITHOUT
|
||||||
|
* ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS
|
||||||
|
* FOR A PARTICULAR PURPOSE. See the GNU General Public License for more details.
|
||||||
|
*
|
||||||
|
* You should have received a copy of the GNU General Public License along with the
|
||||||
|
* Systemback. If not, see <http://www.gnu.org/licenses>.
|
||||||
|
*/
|
||||||
|
|
||||||
|
#include "../libsystemback/sblib.hpp"
|
||||||
|
|
||||||
|
int main(int argc, char *argv[])
|
||||||
|
{
|
||||||
|
QCoreApplication a(argc, argv);
|
||||||
|
sb::ldtltr(), sb::supgrade();
|
||||||
|
return 0;
|
||||||
|
}
|
||||||
41
sbsysupgrade/sbsysupgrade.pro
Normal file
@@ -0,0 +1,41 @@
|
|||||||
|
QT -= gui
|
||||||
|
QT += core
|
||||||
|
|
||||||
|
TARGET = sbsysupgrade
|
||||||
|
|
||||||
|
CONFIG -= app_bundle
|
||||||
|
CONFIG += console \
|
||||||
|
c++11 \
|
||||||
|
exceptions_off
|
||||||
|
|
||||||
|
TEMPLATE = app
|
||||||
|
|
||||||
|
DEFINES += _FILE_OFFSET_BITS=64
|
||||||
|
|
||||||
|
SOURCES += sbsysupgrade.cpp
|
||||||
|
|
||||||
|
QMAKE_CXXFLAGS += -g \
|
||||||
|
-fno-rtti \
|
||||||
|
-fvisibility=hidden \
|
||||||
|
-fvisibility-inlines-hidden \
|
||||||
|
-fno-asynchronous-unwind-tables
|
||||||
|
|
||||||
|
CONFIG(debug, debug|release) {
|
||||||
|
QMAKE_CXXFLAGS_WARN_ON += -Wextra \
|
||||||
|
-Wshadow \
|
||||||
|
-Werror
|
||||||
|
}
|
||||||
|
|
||||||
|
QMAKE_LFLAGS += -g \
|
||||||
|
-Wl,-rpath=/usr/lib/systemback \
|
||||||
|
-Wl,--as-needed \
|
||||||
|
-fuse-ld=gold \
|
||||||
|
-Wl,-z,relro
|
||||||
|
|
||||||
|
! equals(QMAKE_CXX, clang++) {
|
||||||
|
QMAKE_CXXFLAGS += -flto
|
||||||
|
QMAKE_LFLAGS += -flto
|
||||||
|
}
|
||||||
|
|
||||||
|
LIBS += -L../libsystemback \
|
||||||
|
-lsystemback
|
||||||
BIN
splash.png
Normal file
|
After Width: | Height: | Size: 86 KiB |
45
systemback-cli/main.cpp
Normal file
@@ -0,0 +1,45 @@
|
|||||||
|
/*
|
||||||
|
* Copyright(C) 2014-2016, Krisztián Kende <nemh@freemail.hu>
|
||||||
|
*
|
||||||
|
* This file is part of the Systemback.
|
||||||
|
*
|
||||||
|
* The Systemback is free software; you can redistribute it and/or modify it under
|
||||||
|
* the terms of the GNU General Public License as published by the Free Software
|
||||||
|
* Foundation; either version 3 of the License, or (at your option) any later
|
||||||
|
* version.
|
||||||
|
*
|
||||||
|
* The Systemback is distributed in the hope that it will be useful, but WITHOUT
|
||||||
|
* ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS
|
||||||
|
* FOR A PARTICULAR PURPOSE. See the GNU General Public License for more details.
|
||||||
|
*
|
||||||
|
* You should have received a copy of the GNU General Public License along with the
|
||||||
|
* Systemback. If not, see <http://www.gnu.org/licenses>.
|
||||||
|
*/
|
||||||
|
|
||||||
|
#include "systemback-cli.hpp"
|
||||||
|
|
||||||
|
int main(int argc, char *argv[])
|
||||||
|
{
|
||||||
|
switch(sb::dbglev) {
|
||||||
|
case sb::Alldbg:
|
||||||
|
sb::dbglev = sb::Nulldbg;
|
||||||
|
break;
|
||||||
|
case sb::Extdbg:
|
||||||
|
sb::dbglev = sb::Cextdbg;
|
||||||
|
}
|
||||||
|
|
||||||
|
QCoreApplication a(argc, argv);
|
||||||
|
sb::ldtltr();
|
||||||
|
systemback c;
|
||||||
|
|
||||||
|
QTimer::singleShot(0, &c,
|
||||||
|
#if QT_VERSION < QT_VERSION_CHECK(5, 4, 0)
|
||||||
|
SLOT(main())
|
||||||
|
#else
|
||||||
|
&systemback::main
|
||||||
|
#endif
|
||||||
|
);
|
||||||
|
|
||||||
|
uchar rv(a.exec());
|
||||||
|
return rv;
|
||||||
|
}
|
||||||
664
systemback-cli/systemback-cli.cpp
Normal file
@@ -0,0 +1,664 @@
|
|||||||
|
/*
|
||||||
|
* Copyright(C) 2014-2016, Krisztián Kende <nemh@freemail.hu>
|
||||||
|
*
|
||||||
|
* This file is part of the Systemback.
|
||||||
|
*
|
||||||
|
* The Systemback is free software; you can redistribute it and/or modify it under
|
||||||
|
* the terms of the GNU General Public License as published by the Free Software
|
||||||
|
* Foundation; either version 3 of the License, or (at your option) any later
|
||||||
|
* version.
|
||||||
|
*
|
||||||
|
* The Systemback is distributed in the hope that it will be useful, but WITHOUT
|
||||||
|
* ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS
|
||||||
|
* FOR A PARTICULAR PURPOSE. See the GNU General Public License for more details.
|
||||||
|
*
|
||||||
|
* You should have received a copy of the GNU General Public License along with the
|
||||||
|
* Systemback. If not, see <http://www.gnu.org/licenses>.
|
||||||
|
*/
|
||||||
|
|
||||||
|
#include "systemback-cli.hpp"
|
||||||
|
#include <QTextStream>
|
||||||
|
#include <QDateTime>
|
||||||
|
#include <QDir>
|
||||||
|
#include <ncursesw/ncurses.h>
|
||||||
|
|
||||||
|
#ifdef timeout
|
||||||
|
#undef timeout
|
||||||
|
#endif
|
||||||
|
|
||||||
|
#ifdef instr
|
||||||
|
#undef instr
|
||||||
|
#endif
|
||||||
|
|
||||||
|
void systemback::main()
|
||||||
|
{
|
||||||
|
auto help([] {
|
||||||
|
return tr("Usage: systemback-cli [option]\n\n"
|
||||||
|
" Options:\n\n"
|
||||||
|
" -n, --newbackup create a new restore point\n\n"
|
||||||
|
" -s, --storagedir <path> get or set the restore points storage directory path\n\n"
|
||||||
|
" -u, --upgrade upgrade the current system\n"
|
||||||
|
" remove the unnecessary files and packages\n\n"
|
||||||
|
" -v, --version output the Systemback version number\n\n"
|
||||||
|
" -h, --help show this help");
|
||||||
|
});
|
||||||
|
|
||||||
|
uchar rv([&] {
|
||||||
|
QSL args(qApp->arguments());
|
||||||
|
|
||||||
|
if(args.count() == 1 || [&] {
|
||||||
|
if(sb::like(args.at(1), {"_-h_", "_--help_"}))
|
||||||
|
sb::print("\n " % help() % "\n\n");
|
||||||
|
else if(sb::like(args.at(1), {"_-v_", "_--version_"}))
|
||||||
|
sb::print("\n " % sb::appver() % "\n\n");
|
||||||
|
else
|
||||||
|
return true;
|
||||||
|
|
||||||
|
return false;
|
||||||
|
}()) return sb::isfile("/cdrom/casper/filesystem.squashfs") || sb::isfile("/lib/live/mount/medium/live/filesystem.squashfs") ? 2
|
||||||
|
: getuid() + getgid() ? 3
|
||||||
|
: ! sb::lock(sb::Sblock) ? 4
|
||||||
|
: ! sb::lock(sb::Dpkglock) ? 5
|
||||||
|
: ! sb::lock(sb::Aptlock) ? 6
|
||||||
|
: [&] {
|
||||||
|
auto startui([this](bool crtrpt = false) -> uchar {
|
||||||
|
if(! (isatty(fileno(stdin)) && isatty(fileno(stdout)) && isatty(fileno(stderr)))) return 255;
|
||||||
|
initscr();
|
||||||
|
|
||||||
|
uchar crv(! has_colors() ? 7
|
||||||
|
: LINES < 24 || COLS < 80 ? 8
|
||||||
|
: [crtrpt, this]() -> uchar {
|
||||||
|
noecho(),
|
||||||
|
raw(),
|
||||||
|
curs_set(0),
|
||||||
|
attron(A_BOLD),
|
||||||
|
start_color(),
|
||||||
|
assume_default_colors(COLOR_BLUE, COLOR_BLACK),
|
||||||
|
init_pair(1, COLOR_WHITE, COLOR_BLACK),
|
||||||
|
init_pair(2, COLOR_BLUE, COLOR_BLACK),
|
||||||
|
init_pair(3, COLOR_GREEN, COLOR_BLACK),
|
||||||
|
init_pair(4, COLOR_YELLOW, COLOR_BLACK),
|
||||||
|
init_pair(5, COLOR_RED, COLOR_BLACK),
|
||||||
|
sbtxt = bstr("Systemback " % tr("basic restore UI")), blgn = COLS / 2 - 6 - tr("basic restore UI").length() / 2;
|
||||||
|
if(! crtrpt) return clistart();
|
||||||
|
sb::pupgrade();
|
||||||
|
return newrpnt() ? 0 : sb::dfree(sb::sdir[1]) < 104857600 ? 12 : 13;
|
||||||
|
}());
|
||||||
|
|
||||||
|
endwin();
|
||||||
|
return crv;
|
||||||
|
});
|
||||||
|
|
||||||
|
return args.count() == 1 ? startui()
|
||||||
|
: sb::like(args.at(1), {"_-n_", "_--newrestorepoint_"}) ? sb::isdir(sb::sdir[1]) && sb::access(sb::sdir[1], sb::Write) ? startui(true) : 14
|
||||||
|
: sb::like(args.at(1), {"_-s_", "_--storagedir_"}) ? storagedir(args)
|
||||||
|
: sb::like(args.at(1), {"_-u_", "_--upgrade_"}) ? [] {
|
||||||
|
sb::unlock(sb::Dpkglock), sb::unlock(sb::Aptlock),
|
||||||
|
sb::supgrade();
|
||||||
|
return 0;
|
||||||
|
}() : 1;
|
||||||
|
}();
|
||||||
|
|
||||||
|
return 0;
|
||||||
|
}());
|
||||||
|
|
||||||
|
if(! sb::like(rv, {0, 255})) sb::error("\n " % [=]() -> QStr {
|
||||||
|
auto dbg([](cQStr &txt) {
|
||||||
|
if(! sb::eout.isEmpty()) sb::crtfile("/tmp/systemback-cli_stderr", QStr((sb::dbglev == sb::sb::Cextdbg ? sb::dbginf() : nullptr) % sb::eout).trimmed().replace("\n\n\n", "\n\n").replace("\n ", "\n") % '\n');
|
||||||
|
return txt;
|
||||||
|
});
|
||||||
|
|
||||||
|
switch(rv) {
|
||||||
|
case 1:
|
||||||
|
return help();
|
||||||
|
case 2:
|
||||||
|
return tr("The Systemback command line interface cannot be used on a Live system!");
|
||||||
|
case 3:
|
||||||
|
return tr("Root privileges are required for running the Systemback!");
|
||||||
|
case 4:
|
||||||
|
return tr("An another Systemback process is currently running, please wait until it finishes.");
|
||||||
|
case 5:
|
||||||
|
return tr("Unable to get exclusive lock!") % "\n\n " % tr("First, close all package manager.");
|
||||||
|
case 6:
|
||||||
|
return tr("The re-synchronization of package index files currently in progress, please wait until it finishes.");
|
||||||
|
case 7:
|
||||||
|
return tr("This stupid terminal does not support color!");
|
||||||
|
case 8:
|
||||||
|
return tr("This terminal is too small!") % " (< 80x24)";
|
||||||
|
case 9:
|
||||||
|
return tr("The specified storage directory path has not been set!");
|
||||||
|
case 10:
|
||||||
|
return tr("The restoration is aborted!");
|
||||||
|
case 11:
|
||||||
|
return dbg(tr("The restoration is completed, but an error occurred while reinstalling the GRUB!"));
|
||||||
|
case 12:
|
||||||
|
return dbg(tr("The restore point creation is aborted!") % "\n\n " % tr("Not enough free disk space to complete the process."));
|
||||||
|
case 13:
|
||||||
|
return dbg(tr("The restore point creation is aborted!") % "\n\n " % tr("There has been critical changes in the file system during this operation."));
|
||||||
|
case 14:
|
||||||
|
return dbg(tr("The restore points storage directory is not available or not writable!"));
|
||||||
|
default:
|
||||||
|
return dbg(tr("The restore point deletion is aborted!") % "\n\n " % tr("An error occurred while during the process."));
|
||||||
|
}
|
||||||
|
}() % "\n\n");
|
||||||
|
|
||||||
|
qApp->exit(rv);
|
||||||
|
}
|
||||||
|
|
||||||
|
uchar systemback::clistart()
|
||||||
|
{
|
||||||
|
mvprintw(0, blgn, sbtxt),
|
||||||
|
attron(COLOR_PAIR(1)),
|
||||||
|
printw(bstr("\n\n " % tr("Available restore point(s):") % "\n\n")),
|
||||||
|
sb::pupgrade(),
|
||||||
|
attron(COLOR_PAIR(3));
|
||||||
|
if(! sb::pnames[0].isEmpty()) printw(bstr(" 1 ─ " % sb::left(sb::pnames[0], COLS - 7) % '\n'));
|
||||||
|
if(! sb::pnames[1].isEmpty()) printw(bstr(" 2 ─ " % sb::left(sb::pnames[1], COLS - 7) % '\n'));
|
||||||
|
if(sb::pnumber == 3) attron(COLOR_PAIR(5));
|
||||||
|
if(! sb::pnames[2].isEmpty()) printw(bstr(" 3 ─ " % sb::left(sb::pnames[2], COLS - 7) % '\n'));
|
||||||
|
if(sb::pnumber == 4) attron(COLOR_PAIR(5));
|
||||||
|
if(! sb::pnames[3].isEmpty()) printw(bstr(" 4 ─ " % sb::left(sb::pnames[3], COLS - 7) % '\n'));
|
||||||
|
if(sb::pnumber == 5) attron(COLOR_PAIR(5));
|
||||||
|
if(! sb::pnames[4].isEmpty()) printw(bstr(" 5 ─ " % sb::left(sb::pnames[4], COLS - 7) % '\n'));
|
||||||
|
if(sb::pnumber == 6) attron(COLOR_PAIR(5));
|
||||||
|
if(! sb::pnames[5].isEmpty()) printw(bstr(" 6 ─ " % sb::left(sb::pnames[5], COLS - 7) % '\n'));
|
||||||
|
if(sb::pnumber == 7) attron(COLOR_PAIR(5));
|
||||||
|
if(! sb::pnames[6].isEmpty()) printw(bstr(" 7 ─ " % sb::left(sb::pnames[6], COLS - 7) % '\n'));
|
||||||
|
if(sb::pnumber == 8) attron(COLOR_PAIR(5));
|
||||||
|
if(! sb::pnames[7].isEmpty()) printw(bstr(" 8 ─ " % sb::left(sb::pnames[7], COLS - 7) % '\n'));
|
||||||
|
if(sb::pnumber == 9) attron(COLOR_PAIR(5));
|
||||||
|
if(! sb::pnames[8].isEmpty()) printw(bstr(" 9 ─ " % sb::left(sb::pnames[8], COLS - 7) % '\n'));
|
||||||
|
if(sb::pnumber == 10) attron(COLOR_PAIR(5));
|
||||||
|
if(! sb::pnames[9].isEmpty()) printw(bstr(" A ─ " % sb::left(sb::pnames[9], COLS - 7) % '\n'));
|
||||||
|
attron(COLOR_PAIR(3));
|
||||||
|
if(! sb::pnames[10].isEmpty()) printw(bstr(" B ─ " % sb::left(sb::pnames[10], COLS - 7) % '\n'));
|
||||||
|
if(! sb::pnames[11].isEmpty()) printw(bstr(" C ─ " % sb::left(sb::pnames[11], COLS - 7) % '\n'));
|
||||||
|
if(! sb::pnames[12].isEmpty()) printw(bstr(" D ─ " % sb::left(sb::pnames[12], COLS - 7) % '\n'));
|
||||||
|
if(! sb::pnames[13].isEmpty()) printw(bstr(" E ─ " % sb::left(sb::pnames[13], COLS - 7) % '\n'));
|
||||||
|
if(! sb::pnames[14].isEmpty()) printw(bstr(" F ─ " % sb::left(sb::pnames[14], COLS - 7) % '\n'));
|
||||||
|
printw(bstr("\n G ─ " % tr("Create new") % "\n Q ─ " % tr("Quit") % '\n')),
|
||||||
|
attron(COLOR_PAIR(2)),
|
||||||
|
mvprintw(LINES - 1, COLS - 13, "Kendek, GPLv3"),
|
||||||
|
refresh();
|
||||||
|
if(! sb::eout.isEmpty()) sb::eout.clear();
|
||||||
|
if(! pname.isEmpty()) pname.clear();
|
||||||
|
|
||||||
|
do {
|
||||||
|
int gtch(getch());
|
||||||
|
|
||||||
|
switch(gtch) {
|
||||||
|
case '1' ... '9':
|
||||||
|
{
|
||||||
|
QStr cstr(gtch);
|
||||||
|
cpoint = "S0" % cstr;
|
||||||
|
uchar num(cstr.toUShort() - 1);
|
||||||
|
if(! sb::pnames[num].isEmpty()) pname = sb::pnames[num];
|
||||||
|
break;
|
||||||
|
}
|
||||||
|
case 'a':
|
||||||
|
case 'A':
|
||||||
|
cpoint = "S10";
|
||||||
|
if(! sb::pnames[9].isEmpty()) pname = sb::pnames[9];
|
||||||
|
break;
|
||||||
|
case 'b':
|
||||||
|
case 'B':
|
||||||
|
cpoint = "H01";
|
||||||
|
if(! sb::pnames[10].isEmpty()) pname = sb::pnames[10];
|
||||||
|
break;
|
||||||
|
case 'c':
|
||||||
|
case 'C':
|
||||||
|
cpoint = "H02";
|
||||||
|
if(! sb::pnames[11].isEmpty()) pname = sb::pnames[11];
|
||||||
|
break;
|
||||||
|
case 'd':
|
||||||
|
case 'D':
|
||||||
|
cpoint = "H03";
|
||||||
|
if(! sb::pnames[12].isEmpty()) pname = sb::pnames[12];
|
||||||
|
break;
|
||||||
|
case 'e':
|
||||||
|
case 'E':
|
||||||
|
cpoint = "H04";
|
||||||
|
if(! sb::pnames[13].isEmpty()) pname = sb::pnames[13];
|
||||||
|
break;
|
||||||
|
case 'f':
|
||||||
|
case 'F':
|
||||||
|
cpoint = "H05";
|
||||||
|
if(! sb::pnames[14].isEmpty()) pname = sb::pnames[14];
|
||||||
|
break;
|
||||||
|
case 'g':
|
||||||
|
case 'G':
|
||||||
|
if(! newrpnt()) return sb::dfree(sb::sdir[1]) < 104857600 ? 12 : 13;
|
||||||
|
clear();
|
||||||
|
return clistart();
|
||||||
|
case 'q':
|
||||||
|
case 'Q':
|
||||||
|
return 0;
|
||||||
|
}
|
||||||
|
} while(pname.isEmpty());
|
||||||
|
|
||||||
|
clear(),
|
||||||
|
mvprintw(0, blgn, sbtxt),
|
||||||
|
attron(COLOR_PAIR(1)),
|
||||||
|
printw(bstr("\n\n " % tr("Selected restore point:"))),
|
||||||
|
attron(COLOR_PAIR(4)),
|
||||||
|
printw(bstr("\n\n " % sb::left(pname, COLS - 3))),
|
||||||
|
attron(COLOR_PAIR(3)),
|
||||||
|
printw(bstr("\n\n 1 ─ " % tr("Delete") % "\n 2 ─ " % tr("System restore") % " ▸\n B ─ ◂ " % tr("Back"))),
|
||||||
|
attron(COLOR_PAIR(2)),
|
||||||
|
mvprintw(LINES - 1, COLS - 13, "Kendek, GPLv3"),
|
||||||
|
refresh();
|
||||||
|
|
||||||
|
forever
|
||||||
|
switch(getch()) {
|
||||||
|
case '1':
|
||||||
|
pset(2), progress(Start);
|
||||||
|
|
||||||
|
if(! (sb::rename(sb::sdir[1] % '/' % cpoint % '_' % pname, sb::sdir[1] % "/.DELETED_" % pname) && sb::remove(sb::sdir[1] % "/.DELETED_" % pname)))
|
||||||
|
{
|
||||||
|
progress(Stop);
|
||||||
|
return 15;
|
||||||
|
}
|
||||||
|
|
||||||
|
emptycache(),
|
||||||
|
progress(Stop),
|
||||||
|
clear();
|
||||||
|
return clistart();
|
||||||
|
case '2':
|
||||||
|
clear();
|
||||||
|
return restore();
|
||||||
|
case 'b':
|
||||||
|
case 'B':
|
||||||
|
clear();
|
||||||
|
return clistart();
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
uchar systemback::storagedir(cQSL &args)
|
||||||
|
{
|
||||||
|
if(args.count() == 2)
|
||||||
|
sb::print("\n " % sb::sdir[0] % "\n\n");
|
||||||
|
else
|
||||||
|
{
|
||||||
|
QStr ndir;
|
||||||
|
|
||||||
|
{
|
||||||
|
QStr cpath, idir(args.at(2));
|
||||||
|
|
||||||
|
if(args.count() > 3)
|
||||||
|
for(uchar a(3) ; a < args.count() ; ++a) idir.append(' ' % args.at(a));
|
||||||
|
|
||||||
|
QSL excl{"*/Systemback_", "*/Systemback/*", "*/_", "_/bin_", "_/bin/*", "_/boot_", "_/boot/*", "_/cdrom_", "_/cdrom/*", "_/dev_", "_/dev/*", "_/etc_", "_/etc/*", "_/lib_", "_/lib/*", "_/lib32_", "_/lib32/*", "_/lib64_", "_/lib64/*", "_/opt_", "_/opt/*", "_/proc_", "_/proc/*", "_/root_", "_/root/*", "_/run_", "_/run/*", "_/sbin_", "_/sbin/*", "_/selinux_", "_/selinux/*", "_/snap_", "_/snap/*", "_/srv_", "_/srv/*_", "_/sys_", "_/sys/*", "_/tmp_", "_/tmp/*", "_/usr_", "_/usr/*", "_/var_", "_/var/*"};
|
||||||
|
if(sb::like(ndir = QDir::cleanPath(idir), excl) || sb::like(cpath = QDir(idir).canonicalPath(), excl) || sb::like(sb::fload("/etc/passwd"), {"*:" % idir % ":*","*:" % ndir % ":*", "*:" % cpath % ":*"}) || ! sb::islnxfs(cpath)) return 9;
|
||||||
|
}
|
||||||
|
|
||||||
|
if(sb::sdir[0] != ndir)
|
||||||
|
{
|
||||||
|
if(sb::isdir(sb::sdir[1]))
|
||||||
|
{
|
||||||
|
QSL dlst(QDir(sb::sdir[1]).entryList(QDir::AllEntries | QDir::Hidden | QDir::NoDotAndDotDot));
|
||||||
|
|
||||||
|
if(! dlst.count())
|
||||||
|
rmdir(bstr(sb::sdir[1]));
|
||||||
|
else if(dlst.count() == 1 && sb::isfile(sb::sdir[1] % "/.sbschedule"))
|
||||||
|
sb::remove(sb::sdir[1]);
|
||||||
|
}
|
||||||
|
|
||||||
|
sb::sdir[0] = ndir, sb::sdir[1] = sb::sdir[0] % "/Systemback", sb::ismpnt = ! sb::issmfs(sb::sdir[0], sb::sdir[0].count('/') == 1 ? "/" : sb::left(sb::sdir[0], sb::rinstr(sb::sdir[0], "/") - 1));
|
||||||
|
if(! sb::cfgwrite()) return 9;
|
||||||
|
}
|
||||||
|
|
||||||
|
if(! (sb::isdir(sb::sdir[1]) || sb::crtdir(sb::sdir[1]))) sb::rename(sb::sdir[1], sb::sdir[1] % '_' % sb::rndstr()),
|
||||||
|
sb::crtdir(sb::sdir[1]);
|
||||||
|
|
||||||
|
if(! sb::isfile(sb::sdir[1] % "/.sbschedule")) sb::crtfile(sb::sdir[1] % "/.sbschedule");
|
||||||
|
sb::print("\n " % twrp(tr("The specified storage directory path is set.")) % "\n\n");
|
||||||
|
}
|
||||||
|
|
||||||
|
return 0;
|
||||||
|
}
|
||||||
|
|
||||||
|
void systemback::emptycache()
|
||||||
|
{
|
||||||
|
pset(1),
|
||||||
|
sb::fssync();
|
||||||
|
if(sb::ecache) sb::crtfile("/proc/sys/vm/drop_caches", "3");
|
||||||
|
}
|
||||||
|
|
||||||
|
bool systemback::newrpnt()
|
||||||
|
{
|
||||||
|
auto end([this](bool rv = true) {
|
||||||
|
progress(Stop);
|
||||||
|
return rv;
|
||||||
|
});
|
||||||
|
|
||||||
|
progress(Start);
|
||||||
|
|
||||||
|
for(cQStr &item : QDir(sb::sdir[1]).entryList(QDir::Dirs | QDir::Hidden | QDir::NoSymLinks | QDir::NoDotAndDotDot))
|
||||||
|
if(sb::like(item, {"_.DELETED_*", "_.S00_*"}))
|
||||||
|
{
|
||||||
|
if(prun.type != 3) pset(3);
|
||||||
|
if(! sb::remove(sb::sdir[1] % '/' % item)) return end(false);
|
||||||
|
}
|
||||||
|
|
||||||
|
for(uchar a(9) ; a > 1 ; --a)
|
||||||
|
if(! sb::pnames[a].isEmpty() && (a == 9 || a > 2 ? sb::pnumber < a + 2 : sb::pnumber == 3))
|
||||||
|
{
|
||||||
|
if(prun.type != 4) pset(4);
|
||||||
|
if(! (sb::rename(sb::sdir[1] % (a < 9 ? QStr("/S0" % QStr::number(a + 1)) : "/S10") % '_' % sb::pnames[a], sb::sdir[1] % "/.DELETED_" % sb::pnames[a]) && sb::remove(sb::sdir[1] % "/.DELETED_" % sb::pnames[a]))) return end(false);
|
||||||
|
}
|
||||||
|
|
||||||
|
pset(5);
|
||||||
|
QStr dtime(QDateTime().currentDateTime().toString("yyyy-MM-dd,hh.mm.ss"));
|
||||||
|
if(! sb::crtrpoint(dtime)) return end(false);
|
||||||
|
|
||||||
|
for(uchar a(0) ; a < 9 && sb::isdir(sb::sdir[1] % "/S0" % QStr::number(a + 1) % '_' % sb::pnames[a]) ; ++a)
|
||||||
|
if(! sb::rename(sb::sdir[1] % "/S0" % QStr::number(a + 1) % '_' % sb::pnames[a], sb::sdir[1] % (a < 8 ? "/S0" : "/S") % QStr::number(a + 2) % '_' % sb::pnames[a])) return end(false);
|
||||||
|
|
||||||
|
if(! sb::rename(sb::sdir[1] % "/.S00_" % dtime, sb::sdir[1] % "/S01_" % dtime)) return end(false);
|
||||||
|
sb::crtfile(sb::sdir[1] % "/.sbschedule"),
|
||||||
|
emptycache();
|
||||||
|
return end();
|
||||||
|
}
|
||||||
|
|
||||||
|
uchar systemback::restore()
|
||||||
|
{
|
||||||
|
mvprintw(0, blgn, sbtxt),
|
||||||
|
attron(COLOR_PAIR(1));
|
||||||
|
uchar mthd(0), fsave(0), greinst(0);
|
||||||
|
|
||||||
|
{
|
||||||
|
bstr rtxt[3]{bstr("\n\n " % tr("Restore with the following restore point:")), bstr("\n\n " % pname), bstr("\n\n " % tr("Restore with the following restore method:"))};
|
||||||
|
printw(rtxt[0]),
|
||||||
|
attron(COLOR_PAIR(4)),
|
||||||
|
printw(rtxt[1]),
|
||||||
|
attron(COLOR_PAIR(1)),
|
||||||
|
printw(rtxt[2]),
|
||||||
|
attron(COLOR_PAIR(3)),
|
||||||
|
printw(bstr("\n\n 1 ─ " % tr("Full restore") % "\n 2 ─ " % tr("System files restore"))),
|
||||||
|
attron(COLOR_PAIR(1)),
|
||||||
|
printw(bstr("\n\n " % tr("Users configuration files restore"))),
|
||||||
|
attron(COLOR_PAIR(3)),
|
||||||
|
printw(bstr("\n\n 3 ─ " % tr("Complete configuration files restore") % "\n 4 ─ " % tr("Keep newly installed configuration files") % "\n\n C ─ " % tr("Cancel"))),
|
||||||
|
attron(COLOR_PAIR(2)),
|
||||||
|
mvprintw(LINES - 1, COLS - 13, "Kendek, GPLv3"),
|
||||||
|
refresh();
|
||||||
|
|
||||||
|
do {
|
||||||
|
int gtch(getch());
|
||||||
|
|
||||||
|
switch(gtch) {
|
||||||
|
case 'c':
|
||||||
|
case 'C':
|
||||||
|
clear();
|
||||||
|
return clistart();
|
||||||
|
case '1' ... '4':
|
||||||
|
mthd = QStr(gtch).toUShort();
|
||||||
|
}
|
||||||
|
} while(! mthd);
|
||||||
|
|
||||||
|
clear(),
|
||||||
|
mvprintw(0, blgn, sbtxt),
|
||||||
|
attron(COLOR_PAIR(1)),
|
||||||
|
printw(rtxt[0]),
|
||||||
|
attron(COLOR_PAIR(4)),
|
||||||
|
printw(rtxt[1]),
|
||||||
|
attron(COLOR_PAIR(1)),
|
||||||
|
printw(rtxt[2]),
|
||||||
|
attron(COLOR_PAIR(4));
|
||||||
|
|
||||||
|
printw(bstr("\n\n " % [mthd] {
|
||||||
|
switch(mthd) {
|
||||||
|
case 1:
|
||||||
|
return tr("Full restore");
|
||||||
|
case 2:
|
||||||
|
return tr("System files restore");
|
||||||
|
case 3:
|
||||||
|
return tr("Complete configuration files restore");
|
||||||
|
default:
|
||||||
|
return tr("Configuration files restore");
|
||||||
|
}
|
||||||
|
}()));
|
||||||
|
|
||||||
|
attron(COLOR_PAIR(3));
|
||||||
|
|
||||||
|
if(mthd < 3)
|
||||||
|
{
|
||||||
|
if(sb::isfile("/etc/fstab"))
|
||||||
|
{
|
||||||
|
printw(bstr("\n\n " % tr("You want to keep the current fstab file?") % ' ' % tr("(Y/N)"))),
|
||||||
|
attron(COLOR_PAIR(2)),
|
||||||
|
mvprintw(LINES - 1, COLS - 13, "Kendek, GPLv3"),
|
||||||
|
refresh();
|
||||||
|
|
||||||
|
do {
|
||||||
|
QChar gtch(getch());
|
||||||
|
|
||||||
|
if(sb::like(gtch.toUpper(), {"_Y_", '_' % yn[0] % '_'}))
|
||||||
|
fsave = 1;
|
||||||
|
else if(sb::like(gtch.toUpper(), {"_N_", '_' % yn[1] % '_'}))
|
||||||
|
fsave = 2;
|
||||||
|
} while(! fsave);
|
||||||
|
|
||||||
|
clear(),
|
||||||
|
mvprintw(0, blgn, sbtxt),
|
||||||
|
attron(COLOR_PAIR(1)),
|
||||||
|
printw(rtxt[0]),
|
||||||
|
attron(COLOR_PAIR(4)),
|
||||||
|
printw(rtxt[1]),
|
||||||
|
attron(COLOR_PAIR(1)),
|
||||||
|
printw(rtxt[2]),
|
||||||
|
attron(COLOR_PAIR(4)),
|
||||||
|
printw(bstr("\n\n " % (mthd == 1 ? tr("Full restore") : tr("System files restore")) % "\n\n " % tr("You want to keep the current fstab file?") % ' ' % tr("(Y/N)") % ' ' % yn[fsave == 1 ? 0 : 1])),
|
||||||
|
attron(COLOR_PAIR(3));
|
||||||
|
|
||||||
|
if(sb::execsrch("update-grub2", sb::sdir[1] % '/' % cpoint % '_' % pname))
|
||||||
|
{
|
||||||
|
printw(bstr("\n\n " % tr("Reinstall the GRUB 2 bootloader?") % ' ' % tr("(Y/N)"))),
|
||||||
|
attron(COLOR_PAIR(2)),
|
||||||
|
mvprintw(LINES - 1, COLS - 13, "Kendek, GPLv3"),
|
||||||
|
refresh();
|
||||||
|
|
||||||
|
do {
|
||||||
|
QChar gtch(getch());
|
||||||
|
|
||||||
|
if(sb::like(gtch.toUpper(), {"_Y_", '_' % yn[0] % '_'}))
|
||||||
|
greinst = 1;
|
||||||
|
else if(sb::like(gtch.toUpper(), {"_N_", '_' % yn[1] % '_'}))
|
||||||
|
greinst = 2;
|
||||||
|
} while(! greinst);
|
||||||
|
|
||||||
|
clear(),
|
||||||
|
mvprintw(0, blgn, sbtxt),
|
||||||
|
attron(COLOR_PAIR(1)),
|
||||||
|
printw(rtxt[0]),
|
||||||
|
attron(COLOR_PAIR(4)),
|
||||||
|
printw(rtxt[1]),
|
||||||
|
attron(COLOR_PAIR(1)),
|
||||||
|
printw(rtxt[2]),
|
||||||
|
attron(COLOR_PAIR(4)),
|
||||||
|
printw(bstr("\n\n " % (mthd == 1 ? tr("Full restore") : tr("System files restore")) % "\n\n " % tr("You want to keep the current fstab file?") % ' ' % tr("(Y/N)") % ' ' % yn[fsave == 1 ? 0 : 1] % "\n\n " % tr("Reinstall the GRUB 2 bootloader?") % ' ' % tr("(Y/N)") % ' ' % yn[greinst == 1 ? 0 : 1]));
|
||||||
|
}
|
||||||
|
}
|
||||||
|
else if(sb::execsrch("update-grub2", sb::sdir[1] % '/' % cpoint % '_' % pname))
|
||||||
|
{
|
||||||
|
printw(bstr("\n\n " % tr("Reinstall the GRUB 2 bootloader?") % ' ' % tr("(Y/N)"))),
|
||||||
|
attron(COLOR_PAIR(2)),
|
||||||
|
mvprintw(LINES - 1, COLS - 13, "Kendek, GPLv3"),
|
||||||
|
refresh();
|
||||||
|
|
||||||
|
do {
|
||||||
|
QChar gtch(getch());
|
||||||
|
|
||||||
|
if(sb::like(gtch.toUpper(), {"_Y_", '_' % yn[0] % '_'}))
|
||||||
|
greinst = 1;
|
||||||
|
else if(sb::like(gtch.toUpper(), {"_N_", '_' % yn[1] % '_'}))
|
||||||
|
greinst = 2;
|
||||||
|
} while(! greinst);
|
||||||
|
|
||||||
|
clear(),
|
||||||
|
mvprintw(0, blgn, sbtxt),
|
||||||
|
attron(COLOR_PAIR(1)),
|
||||||
|
printw(rtxt[0]),
|
||||||
|
attron(COLOR_PAIR(4)),
|
||||||
|
printw(rtxt[1]),
|
||||||
|
attron(COLOR_PAIR(1)),
|
||||||
|
printw(rtxt[2]),
|
||||||
|
attron(COLOR_PAIR(4)),
|
||||||
|
printw(bstr("\n\n " % (mthd == 1 ? tr("Full restore") : tr("System files restore")) % "\n\n " % tr("Reinstall the GRUB 2 bootloader?") % ' ' % tr("(Y/N)") % ' ' % yn[greinst == 1 ? 0 : 1]));
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
attron(COLOR_PAIR(3)),
|
||||||
|
printw(bstr("\n\n " % tr("Start the restore?") % ' ' % tr("(Y/N)"))),
|
||||||
|
attron(COLOR_PAIR(2)),
|
||||||
|
mvprintw(LINES - 1, COLS - 13, "Kendek, GPLv3"),
|
||||||
|
refresh();
|
||||||
|
bool rstart(false);
|
||||||
|
|
||||||
|
do {
|
||||||
|
QChar gtch(getch());
|
||||||
|
|
||||||
|
if(sb::like(gtch.toUpper(), {"_Y_", '_' % yn[0] % '_'}))
|
||||||
|
rstart = true;
|
||||||
|
else if(sb::like(gtch.toUpper(), {"_N_", '_' % yn[1] % '_'}))
|
||||||
|
return 10;
|
||||||
|
} while(! rstart);
|
||||||
|
|
||||||
|
pset(mthd + 5),
|
||||||
|
progress(Start);
|
||||||
|
bool sfstab(fsave == 1);
|
||||||
|
sb::srestore(mthd, nullptr, sb::sdir[1] % '/' % cpoint % '_' % pname, nullptr, sfstab);
|
||||||
|
{ bool err(greinst == 1 && sb::exec("sh -c \"update-grub ; grub-install --force " % sb::gdetect() % '\"', sb::Silent));
|
||||||
|
progress(Stop);
|
||||||
|
if(err) return 11; }
|
||||||
|
clear(),
|
||||||
|
mvprintw(0, blgn, sbtxt),
|
||||||
|
attron(COLOR_PAIR(1));
|
||||||
|
|
||||||
|
printw(bstr("\n\n " % twrp([mthd] {
|
||||||
|
switch(mthd) {
|
||||||
|
case 1:
|
||||||
|
return tr("The full system restoration is completed.");
|
||||||
|
case 2:
|
||||||
|
return tr("The system files restoration are completed.");
|
||||||
|
case 3:
|
||||||
|
return tr("The users configuration files full restoration are completed.");
|
||||||
|
default:
|
||||||
|
return tr("The users configuration files restoration are completed.");
|
||||||
|
}
|
||||||
|
}())));
|
||||||
|
|
||||||
|
attron(COLOR_PAIR(3)),
|
||||||
|
printw(bstr("\n\n " % twrp(mthd < 3 ? tr("Press 'ENTER' key to reboot the computer, or 'Q' to quit.") : tr("Press 'ENTER' key to quit.")))),
|
||||||
|
attron(COLOR_PAIR(2)),
|
||||||
|
mvprintw(LINES - 1, COLS - 13, "Kendek, GPLv3"),
|
||||||
|
refresh();
|
||||||
|
|
||||||
|
forever
|
||||||
|
switch(getch()) {
|
||||||
|
case '\n':
|
||||||
|
if(mthd < 3) sb::exec(sb::execsrch("reboot") ? "reboot" : "systemctl reboot", sb::Bckgrnd);
|
||||||
|
return 0;
|
||||||
|
case 'q':
|
||||||
|
case 'Q':
|
||||||
|
if(mthd < 3) return 0;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
void systemback::pset(uchar type)
|
||||||
|
{
|
||||||
|
prun.txt = [type]() -> QStr {
|
||||||
|
switch(type) {
|
||||||
|
case 1:
|
||||||
|
return sb::ecache ? tr("Emptying cache") : tr("Flushing filesystem buffers");
|
||||||
|
case 2:
|
||||||
|
return tr("Deleting restore point");
|
||||||
|
case 3:
|
||||||
|
return tr("Deleting incomplete restore point");
|
||||||
|
case 4:
|
||||||
|
return tr("Deleting old restore point(s)");
|
||||||
|
case 5:
|
||||||
|
return tr("Creating restore point");
|
||||||
|
case 6:
|
||||||
|
return tr("Restoring the full system");
|
||||||
|
case 7:
|
||||||
|
return tr("Restoring the system files");
|
||||||
|
default:
|
||||||
|
return tr("Restoring the users configuration files");
|
||||||
|
}
|
||||||
|
}();
|
||||||
|
|
||||||
|
prun.type = type;
|
||||||
|
}
|
||||||
|
|
||||||
|
void systemback::progress(uchar status)
|
||||||
|
{
|
||||||
|
switch(status) {
|
||||||
|
case Start:
|
||||||
|
connect(ptimer = new QTimer, SIGNAL(timeout()), this, SLOT(progress())),
|
||||||
|
QTimer::singleShot(0, this, SLOT(progress())),
|
||||||
|
ptimer->start(2000);
|
||||||
|
if(sb::dbglev == sb::Nulldbg) sb::dbglev = sb::Errdbg;
|
||||||
|
return;
|
||||||
|
case Inprog:
|
||||||
|
for(uchar a(0) ; a < 4 ; ++a)
|
||||||
|
{
|
||||||
|
switch(prun.type) {
|
||||||
|
case 5 ... 9:
|
||||||
|
{
|
||||||
|
schar cperc(sb::Progress);
|
||||||
|
|
||||||
|
if(cperc == -1)
|
||||||
|
prun.pbar = prun.pbar == " (?%)" ? " ( %)" : " (?%)";
|
||||||
|
else if(cperc > 99)
|
||||||
|
{
|
||||||
|
if(prun.cperc < 100) prun.cperc = 100, prun.pbar = " (100%)";
|
||||||
|
}
|
||||||
|
else if(prun.cperc < cperc)
|
||||||
|
prun.pbar = " (" % QStr::number(prun.cperc = cperc) % "%)";
|
||||||
|
else if(! (prun.cperc || prun.pbar == " (0%)"))
|
||||||
|
prun.pbar = " (0%)";
|
||||||
|
else if(sb::like(99, {cperc, prun.cperc}, true))
|
||||||
|
prun.pbar = " (100%)", prun.cperc = 100;
|
||||||
|
|
||||||
|
break;
|
||||||
|
}
|
||||||
|
default:
|
||||||
|
if(! prun.pbar.isEmpty()) prun.pbar.clear();
|
||||||
|
}
|
||||||
|
|
||||||
|
if(! ptimer) return;
|
||||||
|
clear(),
|
||||||
|
attron(COLOR_PAIR(2)),
|
||||||
|
mvprintw(0, blgn, sbtxt),
|
||||||
|
attron(COLOR_PAIR(1));
|
||||||
|
|
||||||
|
mvprintw(LINES / 2 - 1, COLS / 2 - (prun.txt.length() + prun.pbar.length() + 4) / 2, bstr(prun.txt % prun.pbar % [a] {
|
||||||
|
switch(a) {
|
||||||
|
case 0:
|
||||||
|
return " ";
|
||||||
|
case 1:
|
||||||
|
return " . ";
|
||||||
|
case 2:
|
||||||
|
return " .. ";
|
||||||
|
default:
|
||||||
|
return " ...";
|
||||||
|
}
|
||||||
|
}()));
|
||||||
|
|
||||||
|
attron(COLOR_PAIR(2)),
|
||||||
|
mvprintw(LINES - 1, COLS - 13, "Kendek, GPLv3"),
|
||||||
|
refresh();
|
||||||
|
if(a < 3) sb::delay(500);
|
||||||
|
}
|
||||||
|
|
||||||
|
break;
|
||||||
|
case Stop:
|
||||||
|
delete ptimer, ptimer = nullptr;
|
||||||
|
prun.txt.clear();
|
||||||
|
if(! prun.pbar.isEmpty()) prun.pbar.clear();
|
||||||
|
if(prun.cperc) prun.cperc = 0;
|
||||||
|
if(sb::Progress > -1) sb::Progress = -1;
|
||||||
|
}
|
||||||
|
}
|
||||||
83
systemback-cli/systemback-cli.hpp
Normal file
@@ -0,0 +1,83 @@
|
|||||||
|
/*
|
||||||
|
* Copyright(C) 2014-2016, Krisztián Kende <nemh@freemail.hu>
|
||||||
|
*
|
||||||
|
* This file is part of the Systemback.
|
||||||
|
*
|
||||||
|
* The Systemback is free software; you can redistribute it and/or modify it under
|
||||||
|
* the terms of the GNU General Public License as published by the Free Software
|
||||||
|
* Foundation; either version 3 of the License, or (at your option) any later
|
||||||
|
* version.
|
||||||
|
*
|
||||||
|
* The Systemback is distributed in the hope that it will be useful, but WITHOUT
|
||||||
|
* ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS
|
||||||
|
* FOR A PARTICULAR PURPOSE. See the GNU General Public License for more details.
|
||||||
|
*
|
||||||
|
* You should have received a copy of the GNU General Public License along with the
|
||||||
|
* Systemback. If not, see <http://www.gnu.org/licenses>.
|
||||||
|
*/
|
||||||
|
|
||||||
|
#ifndef SYSTEMBACKCLI_HPP
|
||||||
|
#define SYSTEMBACKCLI_HPP
|
||||||
|
|
||||||
|
#include "../libsystemback/sblib.hpp"
|
||||||
|
#include <QTimer>
|
||||||
|
|
||||||
|
class systemback : public QObject
|
||||||
|
{
|
||||||
|
Q_OBJECT
|
||||||
|
|
||||||
|
public:
|
||||||
|
systemback();
|
||||||
|
~systemback();
|
||||||
|
|
||||||
|
#if QT_VERSION < QT_VERSION_CHECK(5, 4, 0)
|
||||||
|
public slots:
|
||||||
|
#endif
|
||||||
|
void main();
|
||||||
|
|
||||||
|
private:
|
||||||
|
enum { Inprog = 0, Start = 1, Stop = 2 };
|
||||||
|
|
||||||
|
struct {
|
||||||
|
QStr txt, pbar;
|
||||||
|
uchar type, cperc;
|
||||||
|
} prun;
|
||||||
|
|
||||||
|
QTimer *ptimer;
|
||||||
|
QStr pname, cpoint;
|
||||||
|
QChar yn[2];
|
||||||
|
bstr sbtxt;
|
||||||
|
uchar blgn;
|
||||||
|
|
||||||
|
QStr twrp(cQStr &txt);
|
||||||
|
uchar storagedir(cQSL &args);
|
||||||
|
|
||||||
|
uchar clistart(),
|
||||||
|
restore();
|
||||||
|
|
||||||
|
bool newrpnt();
|
||||||
|
|
||||||
|
void pset(uchar type),
|
||||||
|
emptycache();
|
||||||
|
|
||||||
|
private slots:
|
||||||
|
void progress(uchar status = Inprog);
|
||||||
|
};
|
||||||
|
|
||||||
|
inline systemback::systemback() : ptimer(nullptr)
|
||||||
|
{
|
||||||
|
QStr yns(tr("(Y/N)"));
|
||||||
|
yn[0] = yns.at(1), yn[1] = yns.at(3), prun.cperc = 0;
|
||||||
|
}
|
||||||
|
|
||||||
|
inline systemback::~systemback()
|
||||||
|
{
|
||||||
|
if(ptimer) delete ptimer;
|
||||||
|
}
|
||||||
|
|
||||||
|
inline QStr systemback::twrp(cQStr &txt)
|
||||||
|
{
|
||||||
|
return txt.length() > 78 ? QStr(txt).replace(txt.left(78).lastIndexOf(' '), 1, "\n ") : txt;
|
||||||
|
}
|
||||||
|
|
||||||
|
#endif
|
||||||
45
systemback-cli/systemback-cli.pro
Normal file
@@ -0,0 +1,45 @@
|
|||||||
|
QT -= gui
|
||||||
|
QT += core
|
||||||
|
|
||||||
|
TARGET = systemback-cli
|
||||||
|
|
||||||
|
CONFIG -= app_bundle
|
||||||
|
CONFIG += console \
|
||||||
|
c++11 \
|
||||||
|
exceptions_off
|
||||||
|
|
||||||
|
TEMPLATE = app
|
||||||
|
|
||||||
|
DEFINES += _FILE_OFFSET_BITS=64
|
||||||
|
|
||||||
|
SOURCES += main.cpp \
|
||||||
|
systemback-cli.cpp
|
||||||
|
|
||||||
|
HEADERS += systemback-cli.hpp
|
||||||
|
|
||||||
|
QMAKE_CXXFLAGS += -g \
|
||||||
|
-fno-rtti \
|
||||||
|
-fvisibility=hidden \
|
||||||
|
-fvisibility-inlines-hidden \
|
||||||
|
-fno-asynchronous-unwind-tables
|
||||||
|
|
||||||
|
CONFIG(debug, debug|release) {
|
||||||
|
QMAKE_CXXFLAGS_WARN_ON += -Wextra \
|
||||||
|
-Wshadow \
|
||||||
|
-Werror
|
||||||
|
}
|
||||||
|
|
||||||
|
QMAKE_LFLAGS += -g \
|
||||||
|
-Wl,-rpath=/usr/lib/systemback \
|
||||||
|
-Wl,--as-needed \
|
||||||
|
-fuse-ld=gold \
|
||||||
|
-Wl,-z,relro
|
||||||
|
|
||||||
|
! equals(QMAKE_CXX, clang++) {
|
||||||
|
QMAKE_CXXFLAGS += -flto
|
||||||
|
QMAKE_LFLAGS += -flto
|
||||||
|
}
|
||||||
|
|
||||||
|
LIBS += -L../libsystemback \
|
||||||
|
-lsystemback \
|
||||||
|
-lncursesw
|
||||||
12
systemback-kde.desktop
Normal file
@@ -0,0 +1,12 @@
|
|||||||
|
[Desktop Entry]
|
||||||
|
Encoding=UTF-8
|
||||||
|
Version=1.0
|
||||||
|
Name=Systemback
|
||||||
|
Comment=Simple system backup and restore application with extra features
|
||||||
|
Comment[hu]=Egyszerű rendszermentő és visszaállító alkalmazás további extra funkciókkal
|
||||||
|
Exec=/usr/lib/systemback/sbsustart systemback
|
||||||
|
Type=Application
|
||||||
|
Icon=systemback
|
||||||
|
Terminal=false
|
||||||
|
OnlyShowIn=KDE;
|
||||||
|
Categories=System;
|
||||||
12
systemback.desktop
Normal file
@@ -0,0 +1,12 @@
|
|||||||
|
[Desktop Entry]
|
||||||
|
Encoding=UTF-8
|
||||||
|
Version=1.0
|
||||||
|
Name=Systemback
|
||||||
|
Comment=Simple system backup and restore application with extra features
|
||||||
|
Comment[hu]=Egyszerű rendszermentő és visszaállító alkalmazás további extra funkciókkal
|
||||||
|
Exec=/usr/lib/systemback/sbsustart systemback gtk+
|
||||||
|
Type=Application
|
||||||
|
Icon=systemback
|
||||||
|
Terminal=false
|
||||||
|
NotShowIn=KDE;
|
||||||
|
Categories=System;
|
||||||
33
systemback.pro
Normal file
@@ -0,0 +1,33 @@
|
|||||||
|
TEMPLATE = subdirs
|
||||||
|
|
||||||
|
SUBDIRS += libsystemback \
|
||||||
|
sbscheduler \
|
||||||
|
sbsysupgrade \
|
||||||
|
sbsustart \
|
||||||
|
systemback \
|
||||||
|
systemback-cli
|
||||||
|
|
||||||
|
sbscheduler.depends = libsystemback
|
||||||
|
sbsysupgrade.depends = libsystemback
|
||||||
|
sbsustart.depends = libsystemback
|
||||||
|
systemback.depends = libsystemback
|
||||||
|
systemback-cli.depends = libsystemback
|
||||||
|
|
||||||
|
TRANSLATIONS = lang/systemback_hu.ts \
|
||||||
|
lang/systemback_ar_EG.ts \
|
||||||
|
lang/systemback_ca_ES.ts \
|
||||||
|
lang/systemback_cs.ts \
|
||||||
|
lang/systemback_da_DK.ts \
|
||||||
|
lang/systemback_de.ts \
|
||||||
|
lang/systemback_en_GB.ts \
|
||||||
|
lang/systemback_es.ts \
|
||||||
|
lang/systemback_fi.ts \
|
||||||
|
lang/systemback_fr.ts \
|
||||||
|
lang/systemback_gl_ES.ts \
|
||||||
|
lang/systemback_id.ts \
|
||||||
|
lang/systemback_pt_BR.ts \
|
||||||
|
lang/systemback_ro.ts \
|
||||||
|
lang/systemback_ru.ts \
|
||||||
|
lang/systemback_tr.ts \
|
||||||
|
lang/systemback_uk.ts \
|
||||||
|
lang/systemback_zh_CN.ts
|
||||||
43
systemback/bttnevent.hpp
Normal file
@@ -0,0 +1,43 @@
|
|||||||
|
/*
|
||||||
|
* Copyright(C) 2014-2016, Krisztián Kende <nemh@freemail.hu>
|
||||||
|
*
|
||||||
|
* This file is part of the Systemback.
|
||||||
|
*
|
||||||
|
* The Systemback is free software; you can redistribute it and/or modify it under
|
||||||
|
* the terms of the GNU General Public License as published by the Free Software
|
||||||
|
* Foundation; either version 3 of the License, or (at your option) any later
|
||||||
|
* version.
|
||||||
|
*
|
||||||
|
* The Systemback is distributed in the hope that it will be useful, but WITHOUT
|
||||||
|
* ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS
|
||||||
|
* FOR A PARTICULAR PURPOSE. See the GNU General Public License for more details.
|
||||||
|
*
|
||||||
|
* You should have received a copy of the GNU General Public License along with the
|
||||||
|
* Systemback. If not, see <http://www.gnu.org/licenses>.
|
||||||
|
*/
|
||||||
|
|
||||||
|
#ifndef BTTNEVENT_HPP
|
||||||
|
#define BTTNEVENT_HPP
|
||||||
|
|
||||||
|
#include <QPushButton>
|
||||||
|
|
||||||
|
class bttnevent : public QPushButton
|
||||||
|
{
|
||||||
|
Q_OBJECT
|
||||||
|
|
||||||
|
public:
|
||||||
|
inline bttnevent(QWidget *prnt) : QPushButton(prnt) {}
|
||||||
|
|
||||||
|
protected:
|
||||||
|
void leaveEvent(QEvent *);
|
||||||
|
|
||||||
|
signals:
|
||||||
|
void Mouse_Leave();
|
||||||
|
};
|
||||||
|
|
||||||
|
inline void bttnevent::leaveEvent(QEvent *)
|
||||||
|
{
|
||||||
|
emit Mouse_Leave();
|
||||||
|
}
|
||||||
|
|
||||||
|
#endif
|
||||||
50
systemback/chckbxevent.hpp
Normal file
@@ -0,0 +1,50 @@
|
|||||||
|
/*
|
||||||
|
* Copyright(C) 2014-2016, Krisztián Kende <nemh@freemail.hu>
|
||||||
|
*
|
||||||
|
* This file is part of the Systemback.
|
||||||
|
*
|
||||||
|
* The Systemback is free software; you can redistribute it and/or modify it under
|
||||||
|
* the terms of the GNU General Public License as published by the Free Software
|
||||||
|
* Foundation; either version 3 of the License, or (at your option) any later
|
||||||
|
* version.
|
||||||
|
*
|
||||||
|
* The Systemback is distributed in the hope that it will be useful, but WITHOUT
|
||||||
|
* ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS
|
||||||
|
* FOR A PARTICULAR PURPOSE. See the GNU General Public License for more details.
|
||||||
|
*
|
||||||
|
* You should have received a copy of the GNU General Public License along with the
|
||||||
|
* Systemback. If not, see <http://www.gnu.org/licenses>.
|
||||||
|
*/
|
||||||
|
|
||||||
|
#ifndef CHCKBXEVENT_HPP
|
||||||
|
#define CHCKBXEVENT_HPP
|
||||||
|
|
||||||
|
#include <QCheckBox>
|
||||||
|
|
||||||
|
class chckbxevent : public QCheckBox
|
||||||
|
{
|
||||||
|
Q_OBJECT
|
||||||
|
|
||||||
|
public:
|
||||||
|
inline chckbxevent(QWidget *prnt) : QCheckBox(prnt) {}
|
||||||
|
|
||||||
|
protected:
|
||||||
|
void enterEvent(QEvent *),
|
||||||
|
leaveEvent(QEvent *);
|
||||||
|
|
||||||
|
signals:
|
||||||
|
void Mouse_Enter();
|
||||||
|
void Mouse_Leave();
|
||||||
|
};
|
||||||
|
|
||||||
|
inline void chckbxevent::enterEvent(QEvent *)
|
||||||
|
{
|
||||||
|
emit Mouse_Enter();
|
||||||
|
}
|
||||||
|
|
||||||
|
inline void chckbxevent::leaveEvent(QEvent *)
|
||||||
|
{
|
||||||
|
emit Mouse_Leave();
|
||||||
|
}
|
||||||
|
|
||||||
|
#endif
|
||||||
94
systemback/lblevent.hpp
Normal file
@@ -0,0 +1,94 @@
|
|||||||
|
/*
|
||||||
|
* Copyright(C) 2014-2016, Krisztián Kende <nemh@freemail.hu>
|
||||||
|
*
|
||||||
|
* This file is part of the Systemback.
|
||||||
|
*
|
||||||
|
* The Systemback is free software; you can redistribute it and/or modify it under
|
||||||
|
* the terms of the GNU General Public License as published by the Free Software
|
||||||
|
* Foundation; either version 3 of the License, or (at your option) any later
|
||||||
|
* version.
|
||||||
|
*
|
||||||
|
* The Systemback is distributed in the hope that it will be useful, but WITHOUT
|
||||||
|
* ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS
|
||||||
|
* FOR A PARTICULAR PURPOSE. See the GNU General Public License for more details.
|
||||||
|
*
|
||||||
|
* You should have received a copy of the GNU General Public License along with the
|
||||||
|
* Systemback. If not, see <http://www.gnu.org/licenses>.
|
||||||
|
*/
|
||||||
|
|
||||||
|
#ifndef LBLEVENT_HPP
|
||||||
|
#define LBLEVENT_HPP
|
||||||
|
|
||||||
|
#include <QMouseEvent>
|
||||||
|
#include <QLabel>
|
||||||
|
|
||||||
|
class lblevent : public QLabel
|
||||||
|
{
|
||||||
|
Q_OBJECT
|
||||||
|
|
||||||
|
public:
|
||||||
|
inline lblevent(QWidget *prnt) : QLabel(prnt) {}
|
||||||
|
static ushort MouseX, MouseY;
|
||||||
|
|
||||||
|
protected:
|
||||||
|
void mouseDoubleClickEvent(QMouseEvent *ev),
|
||||||
|
mouseReleaseEvent(QMouseEvent *ev),
|
||||||
|
mousePressEvent(QMouseEvent *ev),
|
||||||
|
mouseMoveEvent(QMouseEvent *),
|
||||||
|
enterEvent(QEvent *),
|
||||||
|
leaveEvent(QEvent *);
|
||||||
|
|
||||||
|
private:
|
||||||
|
bool MousePressed;
|
||||||
|
|
||||||
|
signals:
|
||||||
|
void Mouse_Released();
|
||||||
|
void Mouse_DblClick();
|
||||||
|
void Mouse_Pressed();
|
||||||
|
void Mouse_Click();
|
||||||
|
void Mouse_Enter();
|
||||||
|
void Mouse_Leave();
|
||||||
|
void Mouse_Move();
|
||||||
|
};
|
||||||
|
|
||||||
|
inline void lblevent::mousePressEvent(QMouseEvent *ev)
|
||||||
|
{
|
||||||
|
if(ev->button() == Qt::LeftButton)
|
||||||
|
{
|
||||||
|
MouseX = ev->x(), MouseY = ev->y(), MousePressed = true;
|
||||||
|
emit Mouse_Pressed();
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
inline void lblevent::mouseMoveEvent(QMouseEvent *)
|
||||||
|
{
|
||||||
|
if(MousePressed) emit Mouse_Move();
|
||||||
|
}
|
||||||
|
|
||||||
|
inline void lblevent::mouseReleaseEvent(QMouseEvent *ev)
|
||||||
|
{
|
||||||
|
if(ev->button() == Qt::LeftButton)
|
||||||
|
{
|
||||||
|
MousePressed = false;
|
||||||
|
emit Mouse_Released();
|
||||||
|
}
|
||||||
|
|
||||||
|
emit Mouse_Click();
|
||||||
|
}
|
||||||
|
|
||||||
|
inline void lblevent::mouseDoubleClickEvent(QMouseEvent *ev)
|
||||||
|
{
|
||||||
|
if(ev->button() == Qt::LeftButton) emit Mouse_DblClick();
|
||||||
|
}
|
||||||
|
|
||||||
|
inline void lblevent::enterEvent(QEvent *)
|
||||||
|
{
|
||||||
|
emit Mouse_Enter();
|
||||||
|
}
|
||||||
|
|
||||||
|
inline void lblevent::leaveEvent(QEvent *)
|
||||||
|
{
|
||||||
|
emit Mouse_Leave();
|
||||||
|
}
|
||||||
|
|
||||||
|
#endif
|
||||||
44
systemback/lndtevent.hpp
Normal file
@@ -0,0 +1,44 @@
|
|||||||
|
/*
|
||||||
|
* Copyright(C) 2014-2016, Krisztián Kende <nemh@freemail.hu>
|
||||||
|
*
|
||||||
|
* This file is part of the Systemback.
|
||||||
|
*
|
||||||
|
* The Systemback is free software; you can redistribute it and/or modify it under
|
||||||
|
* the terms of the GNU General Public License as published by the Free Software
|
||||||
|
* Foundation; either version 3 of the License, or (at your option) any later
|
||||||
|
* version.
|
||||||
|
*
|
||||||
|
* The Systemback is distributed in the hope that it will be useful, but WITHOUT
|
||||||
|
* ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS
|
||||||
|
* FOR A PARTICULAR PURPOSE. See the GNU General Public License for more details.
|
||||||
|
*
|
||||||
|
* You should have received a copy of the GNU General Public License along with the
|
||||||
|
* Systemback. If not, see <http://www.gnu.org/licenses>.
|
||||||
|
*/
|
||||||
|
|
||||||
|
#ifndef LNDTEVENT_HPP
|
||||||
|
#define LNDTEVENT_HPP
|
||||||
|
|
||||||
|
#include <QLineEdit>
|
||||||
|
|
||||||
|
class lndtevent : public QLineEdit
|
||||||
|
{
|
||||||
|
Q_OBJECT
|
||||||
|
|
||||||
|
public:
|
||||||
|
inline lndtevent(QWidget *prnt) : QLineEdit(prnt) {}
|
||||||
|
|
||||||
|
protected:
|
||||||
|
void focusOutEvent(QFocusEvent *ev);
|
||||||
|
|
||||||
|
signals:
|
||||||
|
void Focus_Out();
|
||||||
|
};
|
||||||
|
|
||||||
|
inline void lndtevent::focusOutEvent(QFocusEvent *ev)
|
||||||
|
{
|
||||||
|
QLineEdit::focusOutEvent(ev);
|
||||||
|
emit Focus_Out();
|
||||||
|
}
|
||||||
|
|
||||||
|
#endif
|
||||||
40
systemback/main.cpp
Normal file
@@ -0,0 +1,40 @@
|
|||||||
|
/*
|
||||||
|
* Copyright(C) 2014-2016, Krisztián Kende <nemh@freemail.hu>
|
||||||
|
*
|
||||||
|
* This file is part of the Systemback.
|
||||||
|
*
|
||||||
|
* The Systemback is free software; you can redistribute it and/or modify it under
|
||||||
|
* the terms of the GNU General Public License as published by the Free Software
|
||||||
|
* Foundation; either version 3 of the License, or (at your option) any later
|
||||||
|
* version.
|
||||||
|
*
|
||||||
|
* The Systemback is distributed in the hope that it will be useful, but WITHOUT
|
||||||
|
* ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS
|
||||||
|
* FOR A PARTICULAR PURPOSE. See the GNU General Public License for more details.
|
||||||
|
*
|
||||||
|
* You should have received a copy of the GNU General Public License along with the
|
||||||
|
* Systemback. If not, see <http://www.gnu.org/licenses>.
|
||||||
|
*/
|
||||||
|
|
||||||
|
#include "systemback.hpp"
|
||||||
|
#include <QApplication>
|
||||||
|
|
||||||
|
int main(int argc, char *argv[])
|
||||||
|
{
|
||||||
|
QApplication a(argc, argv);
|
||||||
|
sb::ldtltr();
|
||||||
|
|
||||||
|
uchar rv([&a] {
|
||||||
|
if(qgetenv("XAUTHORITY").startsWith("/home/") && ! getuid())
|
||||||
|
{
|
||||||
|
sb::error("\n " % sb::tr("Unsafe X Window authorization!") % "\n\n " % sb::tr("Please do not use 'sudo' command.") % "\n\n");
|
||||||
|
return 1;
|
||||||
|
}
|
||||||
|
|
||||||
|
systemback w;
|
||||||
|
w.fscrn ? w.showFullScreen() : w.show();
|
||||||
|
return a.exec();
|
||||||
|
}());
|
||||||
|
|
||||||
|
return rv;
|
||||||
|
}
|
||||||
26
systemback/pictures.qrc
Normal file
@@ -0,0 +1,26 @@
|
|||||||
|
<RCC>
|
||||||
|
<qresource prefix="/">
|
||||||
|
<file>pictures/back.png</file>
|
||||||
|
<file>pictures/dialogerror.png</file>
|
||||||
|
<file>pictures/dialoginfo.png</file>
|
||||||
|
<file>pictures/dialogquestion.png</file>
|
||||||
|
<file>pictures/dir.png</file>
|
||||||
|
<file>pictures/dirx.png</file>
|
||||||
|
<file>pictures/down.png</file>
|
||||||
|
<file>pictures/error.png</file>
|
||||||
|
<file>pictures/isdir.png</file>
|
||||||
|
<file>pictures/leftarrow.png</file>
|
||||||
|
<file>pictures/leftgreenarrow.png</file>
|
||||||
|
<file>pictures/logo.png</file>
|
||||||
|
<file>pictures/menuback.png</file>
|
||||||
|
<file>pictures/menunext.png</file>
|
||||||
|
<file>pictures/next.png</file>
|
||||||
|
<file>pictures/ok.png</file>
|
||||||
|
<file>pictures/passwordlogo.png</file>
|
||||||
|
<file>pictures/refresh.png</file>
|
||||||
|
<file>pictures/resize.png</file>
|
||||||
|
<file>pictures/rightarrow.png</file>
|
||||||
|
<file>pictures/systemback.png</file>
|
||||||
|
<file>pictures/up.png</file>
|
||||||
|
</qresource>
|
||||||
|
</RCC>
|
||||||
BIN
systemback/pictures/back.png
Normal file
|
After Width: | Height: | Size: 809 B |
BIN
systemback/pictures/dialogerror.png
Normal file
|
After Width: | Height: | Size: 9.7 KiB |
BIN
systemback/pictures/dialoginfo.png
Normal file
|
After Width: | Height: | Size: 12 KiB |
BIN
systemback/pictures/dialogquestion.png
Normal file
|
After Width: | Height: | Size: 16 KiB |
BIN
systemback/pictures/dir.png
Normal file
|
After Width: | Height: | Size: 617 B |
BIN
systemback/pictures/dirx.png
Normal file
|
After Width: | Height: | Size: 679 B |
BIN
systemback/pictures/down.png
Normal file
|
After Width: | Height: | Size: 802 B |
BIN
systemback/pictures/error.png
Normal file
|
After Width: | Height: | Size: 4.9 KiB |
BIN
systemback/pictures/isdir.png
Normal file
|
After Width: | Height: | Size: 554 B |
BIN
systemback/pictures/leftarrow.png
Normal file
|
After Width: | Height: | Size: 707 B |
BIN
systemback/pictures/leftgreenarrow.png
Normal file
|
After Width: | Height: | Size: 706 B |
BIN
systemback/pictures/logo.png
Normal file
|
After Width: | Height: | Size: 101 KiB |
BIN
systemback/pictures/menuback.png
Normal file
|
After Width: | Height: | Size: 667 B |
BIN
systemback/pictures/menunext.png
Normal file
|
After Width: | Height: | Size: 680 B |
BIN
systemback/pictures/next.png
Normal file
|
After Width: | Height: | Size: 842 B |