blob: 3a4cae09b280ecded6e322f394c59c725f2288e4 (
plain) (
tree)
|
|
#!/bin/ash
TEMP_HOME_DIR="$HOME"
PERSISTENT_HOME_DIR="$HOME/PERSISTENT"
# Use /etc/skel/* files to create default config files for users that do not have any
for file in .bashrc .profile .vimrc .gitconfig .local/share/applications/mimeapps.list; do
[ -e "$TEMP_HOME_DIR/$file" ] && continue
if [ "x$(dirname "$file")" != "x." ]; then
mkdir -p "$TEMP_HOME_DIR/$(dirname "$file")"
fi
if [ -e "$PERSISTENT_HOME_DIR/$file" ]; then
ln -s "$PERSISTENT_HOME_DIR/$file" "$TEMP_HOME_DIR/$file"
continue
fi
if [ -e "/etc/skel/$file" ]; then
if [ -d "$PERSISTENT_HOME_DIR" ]; then
cp "/etc/skel/$file" "$PERSISTENT_HOME_DIR/$file"
ln -s "$PERSISTENT_HOME_DIR/$file" "$TEMP_HOME_DIR/$file"
else
cp "/etc/skel/$file" "$TEMP_HOME_DIR/$file"
fi
fi
done
if [ -d "$PERSISTENT_HOME_DIR" ]; then
# Persistent home was mounted, take care of some convenience directories
for file in .vim .config/htop .config/openslx .config/xfce4; do
[ -e "$TEMP_HOME_DIR/$file" ] && continue
if [ "x$(dirname "$file")" != "x." ]; then
mkdir -p "$TEMP_HOME_DIR/$(dirname "$file")"
fi
if [ ! -d "$PERSISTENT_HOME_DIR/$file" ]; then
mkdir -p "$PERSISTENT_HOME_DIR/$file"
fi
ln -s "$PERSISTENT_HOME_DIR/$file" "$TEMP_HOME_DIR/$file"
done
# configure XDG directories according to $TEMP_HOME_DIR/.openslx/shares
if [ -e "${TEMP_HOME_DIR}/.openslx/shares" ]; then
. "${TEMP_HOME_DIR}/.openslx/shares"
## Documents
TARGET_DIR="$TEMP_HOME_DIR"
[ "$SHARE_DOCUMENTS" = "1" ] && TARGET_DIR="$PERSISTENT_HOME_DIR"
echo "XDG_DOCUMENTS_DIR=\"$TARGET_DIR/Documents\""
echo "XDG_TEMPLATES_DIR=\"$TARGET_DIR/Templates\""
## Downloads
TARGET_DIR="$TEMP_HOME_DIR"
[ "$SHARE_DOWNLOADS" = "1" ] && TARGET_DIR="$PERSISTENT_HOME_DIR"
echo "XDG_DOWNLOAD_DIR=\"$TARGET_DIR/Downloads\""
## Desktop
TARGET_DIR="$TEMP_HOME_DIR"
[ "$SHARE_DESKTOP" = "1" ] && TARGET_DIR="$PERSISTENT_HOME_DIR"
echo "XDG_DESKTOP_DIR=\"$TARGET_DIR/Desktop\""
# Music/Pictures/Videos
TARGET_DIR="$TEMP_HOME_DIR"
[ "$SHARE_MEDIA" = "1" ] && TARGET_DIR="$PERSISTENT_HOME_DIR"
echo "XDG_MUSIC_DIR=\"$TARGET_DIR/Music\""
echo "XDG_PICTURES_DIR=\"$TARGET_DIR/Pictures\""
echo "XDG_VIDEOS_DIR=\"$TARGET_DIR/Videos\""
# Publicshare, w/e that is
TARGET_DIR="$TEMP_HOME_DIR"
[ "$SHARE_OTHER" = "1" ] && TARGET_DIR="$PERSISTENT_HOME_DIR"
echo "XDG_PUBLICSHARE_DIR=\"$TARGET_DIR/Public\""
fi > "$TEMP_HOME_DIR/.config/user-dirs.dirs"
# Check if user has autostart script and run it (so they can create more symlinks etc.)
if [ -x "$PERSISTENT_HOME_DIR/AUTOSTART" ]; then
if cd "$TEMP_HOME_DIR"; then
"$PERSISTENT_HOME_DIR/AUTOSTART"
cd - >/dev/null 2>&1
fi
fi
fi
|