summaryrefslogtreecommitdiff
path: root/share/hydractl/sync-tpc
blob: bdedf35f4c835c1adaa69bd8e72cda872a7e4237 (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
#!/bin/bash
#
# sync-tpc
#

# Parameters
BASENAME="$0"
DEST="$1"
MEDIA="/var/cache/media"

# Syntax
if [ -z "$DEST" ]; then
  echo "usage: $BASENAME <dest>"
  exit 1
elif [ ! -d "$DEST" ]; then
  echo "folder $DEST does not exist."
  exit 1
fi

# Sudo
if [ "$USER" != 'root' ]; then
  export SUDO="sudo"
fi

# Encrypted home
$SUDO mkdir -p $DEST/mnt/crypt/home

# Encrypted mountpoints
for folder in /mnt/crypt/home/*; do
  $SUDO mkdir -p $DEST/$folder
done

# Sync files
$SUDO rsync -av --delete /home/                 $DEST/home/
$SUDO rsync -av --delete /var/cache/virtualbox/ $DEST/var/cache/virtualbox/
$SUDO rsync -av --delete /var/chroot/           $DEST/var/chroot/
$SUDO rsync -av --delete /var/cache/pbuilder/   $DEST/var/cache/pbuilder/
$SUDO rsync -av --delete /var/lib/wicd/         $DEST/var/lib/wicd/

# Sync config
$SUDO cp -a /etc/network/interfaces                   $DEST/etc/network/interfaces
$SUDO cp -a /etc/wicd/manager-settings.conf           $DEST/etc/wicd/manager-settings.conf
$SUDO cp -a /etc/udev/rules.d/70-persistent-net.rules $DEST/etc/udev/rules.d/70-persistent-net.rules

# Sync media remotes
hydractl sync-media-remotes $DEST