2 ################################################
 
   3 ### Managed by someone's ansible provisioner ###
 
   4 ################################################
 
   5 # Part of: https://git.somenet.org/root/pub/somesible.git
 
   6 # 2017-2025 by someone <someone@somenet.org>
 
   9 # Copyright 2018 by Jan Vales <jan@jvales.net> (Someone <someone@somenet.org>)
 
  11 #       This program is free software: you can redistribute it and/or modify
 
  12 #       it under the terms of the GNU General Public License as published by
 
  13 #       the Free Software Foundation, version 3 of the License.
 
  15 #       This program is distributed in the hope that it will be useful,
 
  16 #       but WITHOUT ANY WARRANTY; without even the implied warranty of
 
  17 #       MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.    See the
 
  18 #       GNU General Public License for more details.
 
  20 #       You should have received a copy of the GNU General Public License
 
  21 #       along with this program.        If not, see <http://www.gnu.org/licenses/>.
 
  25 # Regenerate /home/$user/.btrfs-snapshots/ symlinks
 
  26 # we use relative symlinking in order to break infinite recursions.
 
  30 for home in $(find . -xdev -mindepth 1 -maxdepth 1 -type d); do
 
  31     echo "HOME: /home/${home}"
 
  32     rm -rf "/home/${home}/.btrfs-snapshots"
 
  33     mkdir "/home/${home}/.btrfs-snapshots"
 
  36     for snap in $(find . -mindepth 2 -maxdepth 2 -type d -iname 'home.*.snap'); do
 
  37         snap_name=$(echo -n $snap | sed -E -e 's#/#-#2g')
 
  38         ln -snf "../../../btrfs/${snap}/${home}" "/home/${home}/.btrfs-snapshots/$snap_name"
 
  39         touch -ahm -r "/btrfs/${snap}" "/home/${home}/.btrfs-snapshots/$snap_name"
 
  42     rename -v 's/home\.(.*)\.snap/$1/' /home/${home}/.btrfs-snapshots/*