Never been to DZone Snippets before?

Snippets is a public source code repository. Easily build up your personal collection of code snippets, categorize them with tags / keywords, and share them with the world

« Newer Snippets
Older Snippets »
Showing 1-4 of 4 total  RSS 

Add many users in a Debian system v0.2

Create many users in a Debian system using a text file as argument

#!/bin/bash

#******************************************************************************#
# AddManyUsers-deb.sh - Create many users in a Debian system using a text file #
# 			as argument					       #
#   Copyright (C) 2008 - written by flynets - <flynets<at>autistici<dot>org>   # 
#   AddManyUsers-deb 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 3 of the License, or          #
#   any later version.							       #
#									       #
#   AddManyUsers-deb 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, see <http://www.gnu.org/licenses/>.      #
#******************************************************************************#

# Checks if you have the right privileges
if [ "$USER" = "root" ]
then

# CHANGE THIS PARAMETERS FOR A PARTICULAR USE
PERS_HOME="/home/"
PERS_SH="/bin/bash"

   # Checks if there is an argument
   [ $# -eq 0 ] && { echo >&2 ERROR: You may enter as an argument a text file containing users, one per line. ; exit 1; }
   # checks if there a regular file
   [ -f "$1" ] || { echo >&2 ERROR: The input file does not exists. ; exit 1; }
   TMPIN=$(mktemp)
   # Remove blank lines and delete duplicates 
   sed '/^$/d' "$1"| sort -g | uniq > "$TMPIN"
   
   NOW=$(date +"%Y-%m-%d-%X")
   LOGFILE="AMU-log-$NOW.log"
   
   for user in $(more "$TMPIN"); do
      # Checks if the user already exists.
      cut -d: -f1 /etc/passwd | grep "$user" > /dev/null
      OUT=$?
      if [ $OUT -eq 0 ];then
   	 echo >&2 "ERROR: User account: \"$user\" already exists."
	 echo >&2 "ERROR: User account: \"$user\" already exists." >> "$LOGFILE"
      else
	 # Create a new user
         /usr/sbin/useradd -d "$PERS_HOME""$user" -s "$PERS_SH" -m "$user"
	 # gpw must be installed on debian system
	 pass=$(gpw 1 8)
         echo $user:$pass | chpasswd
	 # save user and password in a file
	 echo -e $user"\t"$pass >> "$LOGFILE"
	 echo "The user \"$user\" has been created and has the password: $pass"
      fi
   done
   rm -f "$TMPIN"
   exit 0
else
   echo >&2 "ERROR: You must be a root user to execute this script."
   exit 1
fi

Making applications installed from source uninstallable



# Install checkinstall and auto-apt if they aren't already installed.
sudo apt-get install checkinstall auto-apt


auto-apt run ./configure
make
sudo checkinstall # instead of "make install"

Subversion service for low-load (personal?) sources repository

Create separate user and insert svnserve into inetd.

# useradd -g root -s /bin/false -d /dev/null -c "SubVersion Daemon" svnserve
# mkdir /var/svn
# chown -R svnserve /var/svn
# update-inetd --add 'svn\tstream\ttcp\tnowait\tsvnserve\t/usr/sbin/tcpd\t/usr/bin/svnserve --inetd --root /var/svn'


/var/svn - root of repository.
update-inetd - standart tool in debian and ubuntu linux distros

You must run svnadmin as svnserve user for manage your repository

$ sudo sudo -u svnserve svnadmin <command>


debian qmail install(remove exim)

# dpkg --force-depends --purge exim4-daemon-light
# dpkg -i qmail_1.03-36_i386.deb
« Newer Snippets
Older Snippets »
Showing 1-4 of 4 total  RSS