#!/bin/sh

if test -z $1; then
    echo 'User not specified, using logname to identify'
    username=$(logname)
else
    username=$1
fi

if ! id "$username" &>/dev/null; then
    echo 'Specified user not found'
    exit 1
fi

homedir=$(eval echo ~$username)

if ! test -d $homedir; then
    echo "Cannot find user home directory"
    exit 1
fi

if ! test -d $homedir/.fly-admin-driver/modprobe.d; then
    echo "Backup data for the specified user not found"
    exit 1
fi

if ! test -d $homedir/.fly-admin-driver/xorg.conf.d; then
    echo "Backup data for the specified user not found"
    exit 1
fi
ls $homedir/.fly-admin-driver/modprobe.d
ls $homedir/.fly-admin-driver/xorg.conf.d

cp -rf $homedir/.fly-admin-driver/modprobe.d /etc
cp -rf $homedir/.fly-admin-driver/xorg.conf.d /etc/X11
