milis/bin/ko

156 lines
3.2 KiB
Plaintext
Raw Normal View History

2016-06-14 15:08:00 +02:00
#!/bin/bash
######################################
#### Default Vars ####################
######################################
user_groups=""
2017-08-15 13:37:46 +02:00
default_groups=(users disk network netdev floppy fuse video lp tty audio cdrom scanner adm vboxusers wheel)
2016-06-14 15:08:00 +02:00
# Avoid spaces troubles :)
OLD_IFS=$IFS
IFS="|
"
KDM_CONFFILE="/etc/kde/kdmrc"
GDM_CONFFILE="/etc/gdm/custom.conf"
LXDM_CONFFILE="/etc/lxdm/lxdm.conf"
######################################
#### Functions #######################
######################################
check_args()
{
description="$1"
name="$2"
name_test=`echo -n "$name" | sed 's@^[a-z][a-z0-9]*$@@g'`
if [ "$name_test" != "" ]; then
2016-06-14 19:10:02 +02:00
echo 1>&2 "HATA=kullanıcı sorunlu kareketerler içerrmektedir."
2016-06-14 15:08:00 +02:00
return 1
fi
if grep "$name" /etc/passwd > /dev/null; then
2016-06-14 19:10:02 +02:00
echo 1>&2 "$name kullanıcısı zaten var!"
2016-06-14 15:08:00 +02:00
return 2
fi
desc_test=`echo "$description" | sed 's@^[[:alnum:]! -.,~_@;%<>?]*$@@ig'`
if [ "$desc_test" != "" ]; then
2016-06-14 19:10:02 +02:00
echo 1>&2 "HATA=Uzun ismi ! -.,~_\\\@;%<>? karekerleri içeremez.Harf-sayı olmalıdır! "
2016-06-14 15:08:00 +02:00
return 3
fi
return 0
}
usage()
{
2016-06-14 19:10:02 +02:00
echo 1>&2 'KULLANIM:
ko kullanıcı kullanıcı_ismi'
2016-06-14 15:08:00 +02:00
exit 1
}
2017-12-21 05:04:57 +01:00
# kullanıcıya Milis Xfce4 öntanımlı masaüstü ayarlarının kopyalanması
xfce4_ayarla(){
if [ $1 ];then
_isim=$1
mkdir -p /home/${_isim}/.config
if [ -d /etc/skel/xfce4 ];then
cp -rf /etc/skel/xfce4 /home/${_isim}/.config/
else
cp -rf /root/.config/xfce4 /home/${_isim}/.config/
fi
else
echo "kullanıcı parametresi eksik"
fi
}
2016-06-14 15:08:00 +02:00
if [ $# -eq 1 -o $# -gt 2 ]; then
usage
fi
if [ $UID -ne 0 ]; then
2016-06-14 19:10:02 +02:00
echo 1>&2 "Bu betik root yetkileriyle çalışmaktadır."
2016-06-14 15:08:00 +02:00
exit 1;
fi
if [ $# -lt 2 ]; then
2017-12-21 05:04:57 +01:00
echo -n "Kullanıcı: "
2016-06-14 15:08:00 +02:00
read name
2016-06-14 19:10:02 +02:00
echo -n "Uzun ismi: "
2016-06-14 15:08:00 +02:00
read description
else
description="$1"
name="$2"
fi
check_args "$description" "$name"
ret=$?
while [ $ret -ne 0 ]; do
if [ $ret -lt 3 ]; then
2016-06-14 19:10:02 +02:00
echo -n "Kullancı: "
2016-06-14 15:08:00 +02:00
read name
fi
if [ $ret -eq 3 ]; then
2016-06-14 19:10:02 +02:00
echo -n "Uzun ismi: "
2016-06-14 15:08:00 +02:00
read description
fi
if [ "$name" == "!stop!" -o "$description" == "!stop!" ]; then
exit 1
fi
check_args "$description" "$name"
ret=$?
done
i=0
while [ -n "${default_groups[i]}" ]; do
if grep "${default_groups[i]}" /etc/group > /dev/null ; then
2017-12-21 05:04:57 +01:00
if [ -z "$user_groups" ]; then
user_groups="${default_groups[i]}"
else
user_groups="$user_groups,${default_groups[i]}"
fi
2016-06-14 15:08:00 +02:00
fi
i=$((i+1))
done
echo 1>&2 "
2016-06-14 19:10:02 +02:00
$name kullanıcısının oluşturulması.
2016-06-14 15:08:00 +02:00
"
2017-12-21 05:04:57 +01:00
2017-09-26 08:02:04 +02:00
2016-06-14 15:08:00 +02:00
if [ -z "$user_groups" ]; then
/sbin/useradd -c "${description}" -m "${name}" || exit 1
else
/sbin/useradd -c "${description}" -G "$user_groups" -m "${name}" || exit 1
fi
2017-12-21 05:04:57 +01:00
if [ -f /root/.xinitrc ]; then
cp /root/.xinitrc /home/${name}
fi
2017-09-26 08:02:04 +02:00
2017-04-22 19:43:49 +02:00
2016-06-14 15:08:00 +02:00
passwd "$name"
2017-12-21 05:04:57 +01:00
while true; do
if [ `pgrep xfce4-session` ];then
echo "${name} için Milis Xfce4 öntanımlı masaüstü ayarlarsın mı?";read -p "e veya h-> " eh
case $eh in
[Ee]* ) xfce4_ayarla ${name}; break;;
[Hh]* ) break;;
* ) echo "e veya h";;
esac
fi
exit 0
done
# kullanıcı izinlerin ayarlanması
if [ -d /home/${name} ]; then
#evdizini
chown -R ${name}:${name} /home/${name}
#ses aygıtları
setfacl -m u:${name}:rw /dev/snd/*
fi
2016-06-14 15:08:00 +02:00
exit 0