users

Here you can exchange scripts that you created or have permission to share with other users.
Message
Author
User avatar
Jerry3904
Administrator
Posts: 21962
Joined: Wed Jul 19, 2006 6:13 am

users

#1 Post by Jerry3904 »

I am trying to build a script to put behind a MX-14 menu entry to make simple user management possible. I really don't know how to do it, so am using what examples I find in a web search. But I have reached my limit and would appreciate some help.

Here is my draft, where code borrowed from an old source is still partially visible. I need ATM to retrieve the selection correctly and associate it with the two commands adduser and deluser:

Code: Select all

deleted
Production: 5.10, MX-23 Xfce, AMD FX-4130 Quad-Core, GeForce GT 630/PCIe/SSE2, 16 GB, SSD 120 GB, Data 1TB
Personal: Lenovo X1 Carbon with MX-23 Fluxbox and Windows 10
Other: Raspberry Pi 5 with MX-23 Xfce Raspberry Pi Respin

User avatar
Jerry3904
Administrator
Posts: 21962
Joined: Wed Jul 19, 2006 6:13 am

Re: users

#2 Post by Jerry3904 »

Running out of time, I have a simple solution that at least will work for now:

Code: Select all

#!/bin/bash
DIALOG=${DIALOG=dialog}

#must be root
chk_root () {
 
  if [ ! $( id -u ) -eq 0 ]; then
    dialog --title "Permission" --msgbox "Must be run as root" 8 30
    exit
  fi
 
}
 
chk_root
 
DURATION=$1

$DIALOG --title "Simple user management" --clear \
        --yesno "This gives you a simple means of managing users for common situations. If you need more functionality, consider installing something like gnome-system-tools. \n Would you like to continue?" 20 40
# Get exit status
# 0 means user wants to add a user
# 1 means user does not want to add a user
# 255 means user hit [Esc] key.
response=$?
case $response in
   0) dialog --title "Method" --msgbox "You will be returned to a root prompt, where you need to enter a command:  \n
      TO ADD NEW USER: adduser new-user-name  \n
      TO SPECIFY GROUP (optional): \n 
      adduser -G name-of-group new-user-name \n
      TO DELETE: deluser user-name" 20 80;;
   1) exit;;
   255) dialog --title "Exit" --msgbox "[ESC] key pressed." 8 30;; 
esac

exit
I couldn't figure out how to make the dialog input boxes work, but will return to it later. Is this too stupid to use?

EDIT: having trouble figuring out how to run this correctly in Xfce, works fine in M12
Production: 5.10, MX-23 Xfce, AMD FX-4130 Quad-Core, GeForce GT 630/PCIe/SSE2, 16 GB, SSD 120 GB, Data 1TB
Personal: Lenovo X1 Carbon with MX-23 Fluxbox and Windows 10
Other: Raspberry Pi 5 with MX-23 Xfce Raspberry Pi Respin

User avatar
dolphin_oracle
Developer
Posts: 20032
Joined: Sun Dec 16, 2007 1:17 pm

Re: users

#3 Post by dolphin_oracle »

I didn't have any problems running it from the terminal, but click in thunar did not work. THe instructions are not necessairly correct if you don't run the script as root but rather use sudo. If you use sudo, you do not exit to a root prompt.


the connectshares scripts may give the answer. dialog has to run in a terminal window. the connectshares script launches a simple terminal window and then runs connectshares.sh inside that terminal.
.
http://www.youtube.com/runwiththedolphin
lenovo ThinkPad X1 Extreme Gen 4 - MX-23
FYI: mx "test" repo is not the same thing as debian testing repo.

User avatar
Jerry3904
Administrator
Posts: 21962
Joined: Wed Jul 19, 2006 6:13 am

Re: users

#4 Post by Jerry3904 »

Thanks for looking at it!

MX-14 is set for su by default. I think if someone wants to change to sudo they are going to have to make cascading changes as well. Like vice versa with all the annoying apps and scripts written for Ubu

(Rut haven't I seen something about putting "sudo=su" somewhere?)

This will be run out of a menu entry, where the terminal command will probably have to be included.
Production: 5.10, MX-23 Xfce, AMD FX-4130 Quad-Core, GeForce GT 630/PCIe/SSE2, 16 GB, SSD 120 GB, Data 1TB
Personal: Lenovo X1 Carbon with MX-23 Fluxbox and Windows 10
Other: Raspberry Pi 5 with MX-23 Xfce Raspberry Pi Respin

User avatar
dolphin_oracle
Developer
Posts: 20032
Joined: Sun Dec 16, 2007 1:17 pm

Re: users

#5 Post by dolphin_oracle »

you can use xfce4-terminal -x then the command to run it in a terminal.

I realize we all use su by default, but sudo is enabled, and its possible to run that way. Launching from the menu, you'll need to launch as root for the root prompt to appear when you are done.

It might make more sense just to launch a terminal beside the instructions so a user can "follow along" to add the user.
http://www.youtube.com/runwiththedolphin
lenovo ThinkPad X1 Extreme Gen 4 - MX-23
FYI: mx "test" repo is not the same thing as debian testing repo.

User avatar
oldhoghead
Posts: 18
Joined: Sat Sep 09, 2006 1:29 pm

Re: users

#6 Post by oldhoghead »

Jerry,

Have you considered the user-management script in antiX13.2?

located in:

Code: Select all

/usr/loca/bin
cheers,
ohh
Laptop Toshiba Satellite A205-S4777
Desktop iMac 5,1 V 1.0

User avatar
Jerry3904
Administrator
Posts: 21962
Joined: Wed Jul 19, 2006 6:13 am

Re: users

#7 Post by Jerry3904 »

Nope--will look at it. anti has not said a word about it...

EDIT: not there in MX-14, so not really available to me.
Production: 5.10, MX-23 Xfce, AMD FX-4130 Quad-Core, GeForce GT 630/PCIe/SSE2, 16 GB, SSD 120 GB, Data 1TB
Personal: Lenovo X1 Carbon with MX-23 Fluxbox and Windows 10
Other: Raspberry Pi 5 with MX-23 Xfce Raspberry Pi Respin

User avatar
oldhoghead
Posts: 18
Joined: Sat Sep 09, 2006 1:29 pm

Re: users

#8 Post by oldhoghead »

Jerry,

I see no problems using it, :)

Code: Select all

#!/bin/bash
# File Name: user-management
# Version: 1.2.5
# Purpose:  USERS ( adding, removing, recovering, repairing, and login options )
#			GROUPS ( adding, removing, and adding users )
#			PASSWORDS ( changing user passwords )
# Authors: Dave and minor modifications by anticapitalista
# Acknowledgements: AntiX forum users for suggestions, testing, and input
# Special Acknowledgements: anticapitalista for testing, suggestions, input

# Copyright (C) Tuesday, Feb. 7, 2011  by Dave / david.dejong02@gmail.com
# License: gplv2
# This file is free software; you can redistribute it and/or modify it
# under the terms of the GNU General Public License as published by
# the Free Software Foundation; either version 2 of the License, or
# (at your option) any later version.
#
# This program is distributed in the hope that it will be useful, but
# WITHOUT ANY WARRANTY; without even the implied warranty of
# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
# General Public License for more details.
#
# You should have received a copy of the GNU General Public License
# along with this program; if not, write to the Free Software
# Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA.
#################################################################################################################################################
cheers,
ohh
Laptop Toshiba Satellite A205-S4777
Desktop iMac 5,1 V 1.0

User avatar
oldhoghead
Posts: 18
Joined: Sat Sep 09, 2006 1:29 pm

Re: users

#9 Post by oldhoghead »

I can email you a copy.

ohh
Laptop Toshiba Satellite A205-S4777
Desktop iMac 5,1 V 1.0

User avatar
Jerry3904
Administrator
Posts: 21962
Joined: Wed Jul 19, 2006 6:13 am

Re: users

#10 Post by Jerry3904 »

you can use xfce4-terminal -x then the command to run it in a terminal
Worked if I added gksu in front, but then the "exit" command just kills it. Could try "shell" instead, I guess.
Production: 5.10, MX-23 Xfce, AMD FX-4130 Quad-Core, GeForce GT 630/PCIe/SSE2, 16 GB, SSD 120 GB, Data 1TB
Personal: Lenovo X1 Carbon with MX-23 Fluxbox and Windows 10
Other: Raspberry Pi 5 with MX-23 Xfce Raspberry Pi Respin

Post Reply

Return to “Scripts”