From 607caaa680748fe666ed685b84315004b4454475 Mon Sep 17 00:00:00 2001 From: milisbir Date: Thu, 21 Dec 2017 06:04:57 +0200 Subject: [PATCH] ko-ks --- bin/ko | 74 ++++++++++++++++++++++++++++++++++++---------------------- bin/ks | 20 ++++++++++++++++ 2 files changed, 66 insertions(+), 28 deletions(-) create mode 100755 bin/ks diff --git a/bin/ko b/bin/ko index 4c99384fa..7e6b473db 100755 --- a/bin/ko +++ b/bin/ko @@ -50,9 +50,20 @@ usage() exit 1 } -###################################### -#### Scripting time ################## -###################################### +# 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 +} if [ $# -eq 1 -o $# -gt 2 ]; then usage @@ -64,7 +75,7 @@ if [ $UID -ne 0 ]; then fi if [ $# -lt 2 ]; then - echo -n "Kullancı: " + echo -n "Kullanıcı: " read name echo -n "Uzun ismi: " read description @@ -94,18 +105,11 @@ done i=0 while [ -n "${default_groups[i]}" ]; do if grep "${default_groups[i]}" /etc/group > /dev/null ; then - if [ -z "$user_groups" ]; then - user_groups="${default_groups[i]}" - else - user_groups="$user_groups,${default_groups[i]}" - fi -# echo "groupes : $user_groups" -# else -# echo 1>&2 ' Veuillez installez un gestionnaire de fenetre, -# redemarrer la machine dans ce gestionnaire, -# et relancer cette commande. -#' -# exit 1 + if [ -z "$user_groups" ]; then + user_groups="${default_groups[i]}" + else + user_groups="$user_groups,${default_groups[i]}" + fi fi i=$((i+1)) done @@ -113,9 +117,33 @@ done echo 1>&2 " $name kullanıcısının oluşturulması. " -if [ -f /root/.xinitrc ]; then - cp /root/.xinitrc /home/${name}/ + + + +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 +if [ -f /root/.xinitrc ]; then + cp /root/.xinitrc /home/${name} +fi + + +passwd "$name" + +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 @@ -124,14 +152,4 @@ if [ -d /home/${name} ]; then setfacl -m u:${name}:rw /dev/snd/* fi -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 - - - -passwd "$name" - exit 0 diff --git a/bin/ks b/bin/ks new file mode 100755 index 000000000..a40ab971a --- /dev/null +++ b/bin/ks @@ -0,0 +1,20 @@ +#!/bin/bash +# kullanıcı silme +kullanici_sil(){ + if [ $1 ];then + _isim=$1 + if [ "$_isim" == "`cat /etc/passwd | grep $_isim | cut -d':' -f1`" ];then + userdel -f $_isim + echo "kullanıcı dizini silinecek" + [ -d /home/$_isim ] && rm -rf /home/$_isim || echo "kullanıcı dizini bulunamadı" + else + echo "$_isim kullanıcısı bulunamadı" + fi + else + echo "kullanıcı parametresi eksik" + fi +} + +kullanici_sil $1 + +exit 0