Advertisement
s243a

bootopts.sh -- /etc/init.d -- TazPup FileSystem

Mar 5th, 2019
237
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
Bash 5.22 KB | None | 0 0
  1. #!/bin/sh
  2. #
  3. # /etc/init.d/bootopts.sh : SliTaz boot options from the cmdline
  4. #
  5. # Earlier boot options are in rcS, ex: config= and modprobe=
  6. # modified by mistfire
  7.  
  8. . /etc/init.d/rc.functions
  9.  
  10. # Get first usb disk
  11. usb_device() {
  12.     cd /sys/block
  13.     for i in sd* sda ; do
  14.         grep -qs 1 $i/removable && break
  15.     done
  16.     echo $i
  17. }
  18.  
  19. # Parse /proc/cmdline for boot options.
  20. echo 'Checking for SliTaz cmdline options...'
  21.  
  22. # Default user account without password (uid=1000). In live mode the option
  23. # user=name can be used, but user must be added before home= to have home dir.
  24. # This option is not handled by a loop and case like others and has no
  25. # effect on an installed system.
  26. if fgrep -q 'user=' /proc/cmdline; then
  27.     USER=$(cat /proc/cmdline | sed 's/.*user=\([^ ]*\).*/\1/')
  28.     # Avoid usage of an existing system user or root.
  29.     if grep -q ^$USER /etc/passwd; then
  30.         USER=tux
  31.     fi
  32. else
  33.     USER=tux
  34. fi
  35.  
  36. if ! grep -q '100[0-9]:100' /etc/passwd; then
  37.     # Make sure we have users applications.conf
  38.     if [ ! -f '/etc/skel/.config/slitaz/applications.conf' -a \
  39.         -f '/etc/slitaz/applications.conf' ]; then
  40.         mkdir -p /etc/skel/.config/slitaz
  41.         cp /etc/slitaz/applications.conf /etc/skel/.config/slitaz
  42.     fi
  43.  
  44.     action 'Configuring user and group: %s...' "$USER"
  45.     #echo ""
  46.     #echo -n ""
  47.     adduser -D -s /bin/sh -g 'SliTaz User' -G users -h /home/$USER $USER 2>/dev/null
  48.     passwd -d $USER 2>/dev/null
  49.     for group in audio cdrom video tty plugdev disk lp scanner dialout camera operator tape
  50.     do
  51.         addgroup $USER $group 2>/dev/null
  52.     done
  53.     status
  54.  
  55.     if [ "$(which hald)" != "" ] && [ -e /etc/init.d/hald ]; then
  56.         action 'Configuring %s...' "haldaemon"
  57.         adduser -D -H haldaemon 2>/dev/null
  58.             for group in audio cdrom video tty plugdev disk lp scanner dialout camera operator tape
  59.             do
  60.                 addgroup haldaemon $group 2>/dev/null
  61.             done
  62.             addgroup haldaemon haldaemon 2>/dev/null
  63.         status
  64.     fi
  65.  
  66.     # Slim default user
  67.     if [ -f /etc/slim.conf ]; then
  68.         sed -i "s|default_user .*|default_user    $USER|" /etc/slim.conf
  69.     fi
  70. fi
  71.  
  72. # Make sure selected user has home
  73. if [ ! -d /home/$USER ]; then
  74.     cp -a /etc/skel /home/$USER
  75.     chown -R $USER:users /home/$USER
  76. fi
  77.  
  78. for opt in $(cat /proc/cmdline); do
  79.     case $opt in
  80.         eject)
  81.             # Eject cdrom.
  82.             eject /dev/cdrom ;;
  83.         autologin)
  84.             # Autologin option to skip first graphic login prompt.
  85.             if [ -f /etc/slim.conf ]; then
  86.                 sed -i '/auto_login .*/d' /etc/slim.conf
  87.                 echo 'auto_login        yes' >> /etc/slim.conf
  88.             fi ;;
  89.         lang=*)
  90.             # Check for a specified locale (lang=*).
  91.             LANG=${opt#lang=}
  92.             /sbin/tazlocale ${LANG%.UTF-8} ;;
  93.         kmap=*)
  94.             # Check for a specified keymap (kmap=*).
  95.             KEYMAP=${opt#kmap=}
  96.             action 'Setting system keymap to: %s...' "$KEYMAP"
  97.             echo "$KEYMAP" > /etc/keymap.conf
  98.             status ;;
  99.         pkeys=*)
  100.             # Check for a specified keymap (pkeys=*).
  101.             KEYMAP=${opt#pkeys=}
  102.             action 'Setting system keymap to: %s...' "$KEYMAP"
  103.             echo "$KEYMAP" > /etc/keymap.conf
  104.             status ;;  
  105.         tz=*)
  106.             # Check for a specified timezone (tz=*).
  107.             TZ=${opt#tz=}
  108.             action 'Setting timezone to: %s...' "$TZ"
  109.             echo "$TZ" > /etc/TZ
  110.             status ;;
  111.         font=*)
  112.             # Check for a specified console font (font=*).
  113.             FONT=${opt#font=}
  114.             action 'Setting console font to: %s...' "$FONT"
  115.             for con in 1 2 3 4 5 6; do
  116.                 setfont $FONT -C /dev/tty$con
  117.             done
  118.             status ;;
  119.         laptop)
  120.             # Enable Kernel Laptop mode.
  121.             echo '5' > /proc/sys/vm/laptop_mode ;;
  122.         mount)
  123.             # Mount all ext3 partitions found (opt: mount).
  124.  
  125.             # Get the list of partitions.
  126.             DEVICES_LIST=$(fdisk -l | sed '/83 Linux/!d;s/ .*//')
  127.  
  128.             # Mount filesystems rw.
  129.             for device in $DEVICES_LIST; do
  130.                 name=${device#/dev/}
  131.                 # Device can be already used by home=usb.
  132.                 if ! mount | grep ^$device >/dev/null; then
  133.                     echo "Mounting partition: $name on /mnt/$name"
  134.                     mkdir -p /mnt/$name
  135.                     mount $device /mnt/$name
  136.                 fi
  137.             done ;;
  138.         mount-packages)
  139.             # Mount and install packages-XXX.iso (useful without Internet
  140.             # connection).
  141.             PKGSIGN="LABEL=\"packages-$(cat /etc/slitaz-release)\" TYPE=\"iso9660\""
  142.             PKGDEV=$(blkid | grep "$PKGSIGN" | cut -d: -f1)
  143.             [ -z "$PKGDEV" -a -L /dev/cdrom ] && \
  144.                 PKGDEV=$(blkid /dev/cdrom | grep "$PKGSIGN" | cut -d: -f1)
  145.             if [ -n "$PKGDEV" ]; then
  146.                 action 'Mounting packages archive from %s...' "$PKGDEV"
  147.                 mkdir -p /packages; mount -t iso9660 -o ro $PKGDEV /packages
  148.                 status
  149.                 /packages/install.sh
  150.             fi ;;
  151.         wm=*)
  152.             # Check for a Window Manager (for a flavor, default WM can be changed
  153.             # with boot options or via /etc/slitaz/applications.conf).
  154.             WM=${opt#wm=}
  155.             case $WM in
  156.                 ob|openbox|openbox-session)
  157.                     WM=openbox-session ;;
  158.                 e17|enlightenment|enlightenment_start)
  159.                     WM=enlightenment ;;
  160.                 razorqt|razor-session)
  161.                     WM=razor-session ;;
  162.                 lxde|lxde-session)
  163.                     WM=lxde-session;;
  164.                 lxqt|lxqt-session)
  165.                     WM=lxqt-session;;      
  166.                 xfce|xfce4|xfce-session|xfce4-session)
  167.                     WM=xfce4-session ;;
  168.                 cinnamon|cinnamon-session)
  169.                     WM=cinnamon-session ;;
  170.                 mate|mate-session )
  171.                     WM=mate-session ;; 
  172.                 gnome|gnome-session )
  173.                     WM=gnome-session ;;            
  174.             esac
  175.             sed -i s/"WINDOW_MANAGER=.*"/"WINDOW_MANAGER=\"$WM\""/ \
  176.                 /etc/slitaz/applications.conf ;;
  177.         *)
  178.             continue ;;
  179.     esac
  180. done
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement