diff options
author | Simon Rettberg | 2024-11-21 15:08:04 +0100 |
---|---|---|
committer | Simon Rettberg | 2024-11-21 15:08:04 +0100 |
commit | 2a2621b8c32e4cfdf85bc0bef6f60acc743c2cd5 (patch) | |
tree | 6493fbc14379a9f3811ef470afe997310ab6f39f /data/etc/profile.d | |
download | netboot-debootstrap-2a2621b8c32e4cfdf85bc0bef6f60acc743c2cd5.tar.gz netboot-debootstrap-2a2621b8c32e4cfdf85bc0bef6f60acc743c2cd5.tar.xz netboot-debootstrap-2a2621b8c32e4cfdf85bc0bef6f60acc743c2cd5.zip |
Initial commit
Diffstat (limited to 'data/etc/profile.d')
-rw-r--r-- | data/etc/profile.d/10-autostart.sh | 83 | ||||
-rw-r--r-- | data/etc/profile.d/20-default-xfce4-panel.sh | 16 |
2 files changed, 99 insertions, 0 deletions
diff --git a/data/etc/profile.d/10-autostart.sh b/data/etc/profile.d/10-autostart.sh new file mode 100644 index 0000000..3a4cae0 --- /dev/null +++ b/data/etc/profile.d/10-autostart.sh @@ -0,0 +1,83 @@ +#!/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 + diff --git a/data/etc/profile.d/20-default-xfce4-panel.sh b/data/etc/profile.d/20-default-xfce4-panel.sh new file mode 100644 index 0000000..6454c84 --- /dev/null +++ b/data/etc/profile.d/20-default-xfce4-panel.sh @@ -0,0 +1,16 @@ +#!/bin/bash + +default_panel_file="/etc/xdg/xfce4/panel/default.xml" +if [ ! -e "$default_panel_file" ]; then + exit 1 +fi + +[ -z "$HOME" ] && HOME=$( getent passwd "$(id -u $PAM_USER)" | awk -F: '{print $6}' ) + +TARGET_HOME_DIR="$HOME" +[ -d "$HOME/PERSISTENT" ] && TARGET_HOME_DIR="$HOME/PERSISTENT" + +if [ ! -e "${TARGET_HOME_DIR}/.config/xfce4/panel/default.xml" ]; then + mkdir -p "${TARGET_HOME_DIR}/.config/xfce4/panel" + cp -f -- "$default_panel_file" "${TARGET_HOME_DIR}/.config/xfce4/panel/" +fi |