Massive update. See CHANGELOG for details.

pull/3/head
Ghost1227 15 years ago
parent 6b26e0e912
commit f3ce43e492

@ -1,26 +1,37 @@
Version 0.1 (2009-11-09) Version 0.4 (2010-01-03)
- Initial release - Fixed CHANGELOG to better match standards
- Added proper utilization of exec
- Added checkyesno function to better handle creative responses in cdmrc
- Removed defaultwm option (unused)
- Added 'countfrom' option to allow CDM menus to start at 1
- Added 'usexinit' option to allow usage of ~/.xinitrc
- Added 'serverargs' option to allow passing custom options to the X server
- Massive code cleanup
- Thanks to jpryor for all his help!
Version 0.1b (2009-11-09) Version 0.3.3 (2009-11-26)
- Minor feature addition - Fixed issue with gnome-session handler
- No longer requires editing user files
Version 0.2 (2009-11-10) Version 0.3.2 (2009-11-21)
- Added shutdown option - Added suspend option
- Added ability to set login shell (fix for some foreign layouts)
Version 0.3.1 (2009-11-20)
- Added failsafe to startup script that overrides execution if
logged in as root
Version 0.3 (2009-11-18) Version 0.3 (2009-11-18)
- Fixed X incrementing function (thanks Andrwe) - Fixed X incrementing function (thanks Andrwe)
- Fixed an issue with allowshutdown off and allowconsole on - Fixed an issue with allowshutdown off and allowconsole on
- Code cleanup (thanks Brisbin33) - Code cleanup (thanks Brisbin33)
- Fixed issue with profile.d execution order - Fixed issue with profile.d execution order
Version 0.3.1 (2009-11-20) Version 0.2 (2009-11-10)
- Added failsafe to startup script that overrides execution if - Added shutdown option
logged in as root - Added ability to set login shell (fix for some foreign layouts)
Version 0.3.2 (2009-11-21) Version 0.1b (2009-11-09)
- Added suspend option - Minor feature addition
- No longer requires editing user files
Version 0.3.3 (2009-11-26)
- Fixed issue with gnome-session handler Version 0.1 (2009-11-09)
- Initial release

@ -30,11 +30,24 @@ info="\e[1;34m==>\e[1;37m"
error="\e[1;31m==>\e[1;37m" error="\e[1;31m==>\e[1;37m"
success="\e[1;32m==>\e[1;37m" success="\e[1;32m==>\e[1;37m"
reset="\e[0m" reset="\e[0m"
# Ignore SIGINT (^C) and SIGTSTP (^Z)
trap "" 2 20 trap "" 2 20
userclientrc=$HOME/.xinitrc
sysclientrc=/etc/X11/xinit/xinitrc
# userserverrc=$HOME/.xserverrc
# sysserverrc=/etc/X11/xinit/xserverrc
# Source cdm configuration # Source cdm configuration
if [ -f /etc/cdmrc ]; then if [[ -f /etc/cdmrc ]]; then
source /etc/cdmrc source /etc/cdmrc
count=0
while [[ ${count} -lt ${#userconfig[@]} ]]; do
if [[ "$USER" == "${#userconfig[${count}]}" ]]; then
${userconfig[${count}]}
fi
let count=count+1
done
countfrom=${countfrom:-0}
else else
echo -e "${error} ERROR: A valid cdm configuration was not found!${reset}" echo -e "${error} ERROR: A valid cdm configuration was not found!${reset}"
echo -e "${info} Logging out.${reset}" echo -e "${info} Logging out.${reset}"
@ -42,38 +55,74 @@ else
exit 1 exit 1
fi fi
unset DIALOGRC
# Source theme file # Source theme file
if [[ ! -z ${theme} ]]; then if [[ ! -z ${theme} ]]; then
if [[ -f /usr/share/cdm/themes/${theme} ]]; then if [[ -f /usr/share/cdm/themes/${theme} ]]; then
export DIALOGRC=/usr/share/cdm/themes/${theme} DIALOGRC=/usr/share/cdm/themes/${theme}
else else
echo -e "${info} Theme file ${theme} is invalid, reverting to default theme.${reset}" echo -e "${info} Theme file ${theme} is invalid, reverting to default theme.${reset}"
fi fi
elif [[ -f /usr/share/cdm/themes/default ]]; then fi
export DIALOGRC=/usr/share/cdm/themes/default # Fall back on defaults if valid theme isn't found
else if [[ -z $DIALOGRC ]]; then
echo -e "${info} A valid theme file was not found, using system defaults.${reset}" if [[ -f /usr/share/cdm/themes/default ]]; then
DIALOGRC=/usr/share/cdm/themes/default
else
echo -e "${info} A valid theme file was not found, using system defaults.${reset}"
fi
fi fi
# Based on FreeBSD's /etc/rc.subr
#
# checkyesno var
# Test $1 variable, and warn if not set to YES or NO.
# Return 0 if it's "yes" (et al), nonzero otherwise.
# to make default yes, do "checkyesno var yes"
#
checkyesno() {
local value=${!1}
# debug "checkyesno: $1 is set to $value."
if [[ -n $2 ]]; then
value=${value:-$2}
else
value=${value:-no}
fi
case $value in
# "yes", "true", "on", or "1"
[Yy][Ee][Ss]|[Tt][Rr][Uu][Ee]|[Oo][Nn]|1)
return 0
;;
# "no", "false", "off", or "0"
[Nn][Oo]|[Ff][Aa][Ll][Ss][Ee]|[Oo][Ff][Ff]|0)
return 1
;;
*)
echo "\$${1} is not set properly." >&2
exit 1
;;
esac
}
# If X is already running and locktty=yes, activate it, # If X is already running and locktty=yes, activate it,
# otherwise, increment. # otherwise, increment.
if [[ ${locktty} == "yes" ]]; then if $(checkyesno locktty); then
# Verify display exists # Verify display exists
if [ -n "${display//[0-9]/}" ]; then if [[ -n "${display//[0-9]/}" ]]; then
display=0 display=0
fi fi
# Activate existing X session # Activate existing X session
if xdpyinfo -display :${display}.0 &> /dev/null; then if xdpyinfo -display :${display}.0 &> /dev/null; then
let tty=${display}+${xtty} let tty=display+xtty
chvt ${tty} chvt ${tty}
exit 0 exit 0
fi fi
else else
# Get the first empty display # Get the first empty display
display=0 display=0
while [ ${display} -lt 7 ]; do while [[ ${display} -lt 7 ]]; do
if xdpyinfo -display :${display}.0 &> /dev/null; then if xdpyinfo -display :${display}.0 &> /dev/null; then
let display=${display}+1 let display=display+1
else else
break break
fi fi
@ -85,41 +134,40 @@ mainmenu() {
count=0 count=0
menu=$( menu=$(
while [[ ${count} -lt ${#wmdisplist[@]} ]]; do while [[ ${count} -lt ${#wmdisplist[@]} ]]; do
echo -ne "${count} ${wmdisplist[${count}]} " echo -ne "$((count+countfrom)) ${wmdisplist[${count}]} "
let count=count+1 let count=count+1
done done
) )
# Check if console access is allowed # Check if console access is allowed
if [[ ${allowconsole} == "yes" ]]; then if $(checkyesno allowconsole); then
if [[ ${allowshutdown} != "yes" ]]; then if $(checkyesno allowshutdown); then
let halt=99 let halt=99
fi fi
let console=${#wmdisplist[@]} let console=${#wmdisplist[@]}+countfrom
menu=$(echo -ne "${menu} ${console} Console ") menu="${menu} ${console} Console "
fi fi
# Check if shutdown access is allowed # Check if shutdown access is allowed
if [[ ${allowshutdown} == "yes" ]]; then if $(checkyesno allowshutdown); then
if [[ ${allowconsole} != "yes" ]]; then if $(checkyesno allowconsole); then
let halt=${#wmdisplist[@]} let halt=${#wmdisplist[@]}
else else
let halt=${#wmdisplist[@]}+1 let halt=${#wmdisplist[@]}+1
fi fi
menu=$(echo -ne "${menu} ${halt} Shutdown ") let halt=halt+countfrom
menu="${menu} ${halt} Shutdown "
fi fi
echo "halt=${halt} console=${console} wm='${wm}'" > ~/cdm.tmp
# Override dialog display if only one option is available # Override dialog display if only one option is available
if [[ ${allowconsole} != "yes" ]] && [[ ${allowshutdown} != "yes" ]] && [[ ${#wmdisplist[@]} == 1 ]]; then if ! $(checkyesno allowconsole) && ! $(checkyesno allowshutdown) && [[ ${#wmdisplist[@]} == 1 ]]; then
wm=${wmbinlist[@]} wm=$countfrom
else else
# Display selection dialog # Display selection dialog
wm=$( wm=$(
dialog --colors --backtitle "${name} v${ver}" --stdout \ DIALOGRC="$DIALOGRC" dialog --colors --backtitle "${name} v${ver}" --stdout \
--ok-label " Select " --cancel-label " Logout " \ --ok-label " Select " --cancel-label " Logout " \
--menu "Select Window Manager" 0 0 0 ${menu} --menu "Select Window Manager" 0 0 0 ${menu}
) )
if [[ $? != 0 ]]; then if [[ $? != 0 ]]; then
clear clear
@ -130,36 +178,40 @@ mainmenu() {
# Set wm_bin # Set wm_bin
clear clear
if [[ ${wm} -eq ${console} ]]; then if [[ ${wm} -eq ${console} ]]; then
${SHELL} exec ${SHELL}
exit 0
elif [[ ${wm} -eq ${halt} ]]; then elif [[ ${wm} -eq ${halt} ]]; then
shutdownmenu shutdownmenu
else else
export wm_bin="${wmbinlist[${wm}]}" let wm=wm-countfrom
wm_bin="${wmbinlist[${wm}]}"
xstart xstart
fi fi
} }
shutdownmenu() { shutdownmenu() {
haltmenu="0 Shutdown 1 Reboot" count=$countfrom
haltmenu=$(
# Check if suspend is enabled for opt in Shutdown Reboot Suspend; do
if [[ ${allowsuspend} == "yes" ]]; then # Check if suspend is enabled
haltmenu=$(echo -n "${haltmenu} 2 Suspend ") if [[ $opt != Suspend ]] || $(checkyesno allowsuspend); then
fi echo -ne "$count $opt "
let count=count+1
fi
done
)
# Display shutdown dialog # Display shutdown dialog
haltopt=$( haltopt=$(
dialog --colors --backtitle "${name} v${ver}" --stdout \ DIALOGRC="$DIALOGRC" dialog --colors --backtitle "${name} v${ver}" --stdout \
--ok-label " Select " --cancel-label " Cancel " \ --ok-label " Select " --cancel-label " Cancel " \
--menu "Shutdown" 0 0 0 ${haltmenu} --menu "Shutdown" 0 0 0 ${haltmenu}
) )
if [[ $? == 0 ]]; then if [[ $? == 0 ]]; then
clear clear
if [[ ${haltopt} -eq 0 ]]; then if [[ ${haltopt} -eq $countfrom ]]; then
${shutdowncommand} ${shutdowncommand}
elif [[ ${haltopt} -eq 1 ]]; then elif [[ ${haltopt} -eq $((countfrom+1)) ]]; then
${rebootcommand} ${rebootcommand}
else else
${suspendcommand} ${suspendcommand}
@ -171,17 +223,27 @@ shutdownmenu() {
xstart() { xstart() {
# Start X # Start X
if [ ${loginshell} == "yes" ]; then if $(checkyesno usexinit); then
if [ ${wm_bin} == "gnome-session" ]; then if [[ -f $userclientrc ]]; then
exec ck-launch-session bash --login -c "startx /usr/share/cdm/xinitrc -- :${display} &> /dev/null" & wm_bin="$userclientrc $wm_bin"
elif [[ -f $sysclientrc ]]; then
wm_bin="$sysclientrc $wm_bin"
fi
fi
serverargs=":${display} ${serverargs} vt$((xtty+display))"
if $(checkyesno loginshell); then
if [[ ${wm_bin} == "gnome-session" ]]; then
exec ck-launch-session bash --login -c "startx $wm_bin -- :${serverargs} &> /dev/null" &
else else
exec bash --login -c "startx /usr/share/cdm/xinitrc -- :${display} &> /dev/null" & exec bash --login -c "startx $wm_bin -- :${serverargs} &> /dev/null" &
fi fi
else else
if [ ${wm_bin} == "gnome-session" ]; then if [[ ${wm_bin} == "gnome-session" ]]; then
exec ck-launch-session startx /usr/share/cdm/xinitrc -- :${display} &> /dev/null & exec ck-launch-session startx $wm_bin -- :${serverargs} &> /dev/null &
else else
exec startx /usr/share/cdm/xinitrc -- :${display} &> /dev/null & exec startx $wm_bin -- :${serverargs} &> /dev/null &
fi fi
fi fi
} }

@ -2,8 +2,9 @@
### GLOBAL CONFIGURATION ### ### GLOBAL CONFIGURATION ###
############################ ############################
# Set CDM theme # Set CDM theme and dialog options
theme=cdm theme=cdm
countfrom=0
# List all WM binary names # List all WM binary names
wmbinlist=(awesome openbox-session) wmbinlist=(awesome openbox-session)
@ -49,7 +50,7 @@ courtney() {
allowshutdown=no allowshutdown=no
# Set specific display for user # Set specific display for user
# (Not used unless restricttty=yes) # (Not honored unless locktty=yes)
# display=1 # display=1
} }
@ -60,29 +61,22 @@ courtney() {
# Set default display # Set default display
display=0 display=0
# Set first X tty (default is 7) # Where should first X tty be spawned?
xtty=7 xtty=7
# Restrict tty? (By default, cdm increments X tty, this setting # Restrict tty? (By default, cdm increments X tty, this setting
# allows administrators to lock users into one specific tty by # allows administrators to lock users into one specific tty by
# setting the display=x option on a per-user basis.) # setting the display=N option on a per-user basis.)
locktty=no locktty=no
# Set default Window Manager # Enable login shell (fixes issues with some keymaps, uses bash)
defaultwm=xterm
# Enable login shell (fixes issues with some keymaps, requires bash)
loginshell=no loginshell=no
################################### # Use ~/.xinitrc when it exists, or /etc/X11/xinit/xinitrc when
### DO NOT EDIT BELOW THIS LINE ### # it doesn't. If no, then we instead call the chosen window
################################### # manager directly.
usexinit=no
count=0
while [[ ${count} -lt ${#userconfig[@]} ]]; do # Additional arguments to pass to X server; it will be called as:
if [[ "$USER" == "${userconfig[${count}]}" ]]; then # exec /usr/bin/X :$display $serverargs vt$((xtty+display))
${userconfig[${count}]} serverargs="-nolisten tcp -dpi 96"
fi
let count=count+1
done

@ -1,9 +1,7 @@
if [[ -z "$DISPLAY" ]] && [[ $(tty) = /dev/tty1 ]]; then if [[ -z "$DISPLAY" ]] && [[ $(tty) = /dev/tty1 ]]; then
# Drop root to console # Drop root to console
if [[ $EUID -eq 0 ]]; then if [[ $EUID -eq 0 ]]; then
${SHELL} exec ${SHELL}
exit 0
fi fi
cdm exec cdm
exit 0
fi fi

Loading…
Cancel
Save