mirror of
https://github.com/azlux/log2ram.git
synced 2023-10-10 13:37:24 +02:00
parent
324902da44
commit
1af7db2b28
1
debian/control
vendored
1
debian/control
vendored
@ -7,3 +7,4 @@ Maintainer: Azlux <github@azlux.fr>
|
||||
Description: ramlog like for systemd (Put log into a ram folder)
|
||||
Homepage: https://github.com/azlux/log2ram
|
||||
Bugs: https://github.com/azlux/log2ram/issues
|
||||
Recommends: rsync
|
||||
|
33
log2ram
33
log2ram
@ -14,20 +14,6 @@ isSafe () {
|
||||
[ -d $HDD_LOG/ ] || exit 1
|
||||
}
|
||||
|
||||
remountRW() {
|
||||
touch $HDD_LOG/$$ 2>/dev/null >/dev/null
|
||||
RESU=$?
|
||||
INITIAL_STATUS=ro
|
||||
if [ "$RESU" != "0" ] ; then
|
||||
mount -o remount,rw ${HDD_LOG}
|
||||
else
|
||||
INITIAL_STATUS=rw
|
||||
rm $HDD_LOG/$$ 2>/dev/null
|
||||
fi
|
||||
# for return
|
||||
echo $INITIAL_STATUS
|
||||
}
|
||||
|
||||
remountOriginal() {
|
||||
OPTION=$1
|
||||
mount -o remount,${OPTION} ${HDD_LOG}
|
||||
@ -35,14 +21,12 @@ remountOriginal() {
|
||||
|
||||
syncToDisk () {
|
||||
isSafe
|
||||
#INITIAL_STATE=$(remountRW)
|
||||
|
||||
if [ "$USE_RSYNC" = true ]; then
|
||||
if [ -x "$(command -v rsync)" ]; then
|
||||
rsync -aXv --inplace --no-whole-file --delete-after $RAM_LOG/ $HDD_LOG/ 2>&1 | tee -a $LOG2RAM_LOG
|
||||
else
|
||||
cp -rfup $RAM_LOG/ -T $HDD_LOG/ 2>&1 | tee -a $LOG2RAM_LOG
|
||||
fi
|
||||
#remountOriginal ${INITIAL_STATE}
|
||||
}
|
||||
|
||||
syncFromDisk () {
|
||||
@ -63,7 +47,7 @@ syncFromDisk () {
|
||||
exit 1
|
||||
fi
|
||||
|
||||
if [ "$USE_RSYNC" = true ]; then
|
||||
if [ -x "$(command -v rsync)" ]; then
|
||||
rsync -aXv --inplace --no-whole-file --delete-after $HDD_LOG/ $RAM_LOG/ 2>&1 | tee -a $LOG2RAM_LOG
|
||||
else
|
||||
cp -rfup $HDD_LOG/ -T $RAM_LOG/ 2>&1 | tee -a $LOG2RAM_LOG
|
||||
@ -93,19 +77,6 @@ createZramLogDrive () {
|
||||
|
||||
make_log_dir () {
|
||||
[ -d $HDD_LOG/ ] || mkdir $HDD_LOG/
|
||||
# if create mount failed, try to remount in rw the parent directory
|
||||
# and restore original status
|
||||
#if [ ! -d $HDD_LOG/ ] ; then
|
||||
# mkdir $HDD_LOG/ 2>/dev/null /dev/null
|
||||
# RESU=$?
|
||||
# if [ "$RESU" -ne "0" ] ; then
|
||||
# MOUNT_POINT=$(findmnt -T ` dirname $HDD_LOG/ ` -n --raw | cut -d ' ' -f 1 )
|
||||
# mount -o remount,rw ${MOUNT_POINT}
|
||||
# sleep 0.1
|
||||
# mkdir $HDD_LOG/
|
||||
# mount -o remount,ro ${MOUNT_POINT}
|
||||
# fi
|
||||
# fi
|
||||
}
|
||||
|
||||
case "$1" in
|
||||
|
@ -1,7 +1,13 @@
|
||||
#!/usr/bin/env sh
|
||||
|
||||
if dpkg -l log2ram ; then
|
||||
echo "Please run : apt remove log2ram"
|
||||
exit 1
|
||||
fi
|
||||
|
||||
if [ "$(id -u)" -eq 0 ]
|
||||
then
|
||||
echo "Not apt installed. Remove will continue with this script..."
|
||||
service log2ram stop
|
||||
systemctl disable log2ram
|
||||
rm /etc/systemd/system/log2ram.service
|
||||
|
Loading…
Reference in New Issue
Block a user