1
1
Fork 0

initial commit

This commit is contained in:
David Starzengruber 2010-06-26 02:43:02 +02:00
commit 8c10beba82
2 changed files with 213 additions and 0 deletions

137
addaccount.sh Executable file
View File

@ -0,0 +1,137 @@
#!/bin/bash
##########################################
## aec ftp/sftp account creation script ##
## written by david ##
##########################################
## script configuration section
# do not use an tailing slash here
accpath="/media/storage"
acchost="newftp.aec.at"
sftpgroup="sftpusers" # must exist
ftpgroup="ftpusers" # must exist
logging=1
logpath="/media/storage/logs"
logfile="accounts.log"
jabberlog=1
jabberwatchdogs="david@aec.at david@socialnerds.org"
jabberuser="david"
jabberserver="jabber.aec.at"
jabberpass="somepassword"
## am i root?
if [ "$(whoami)" != 'root' ]; then
echo "only root can do this"
exit 1;
fi
## check for dependencys
# not yet implemented (sendxmpp, ssh, vsftpd, ..)
clear
echo "Welcome to the AEC FTP/sFTP Creation Script"
echo ""
## choose ftp or sftp
echo "which type of account you want to create? [sftp|ftp]"
read acctype
if [ $acctype = "sftp" ]; then
echo ""
else
if [ $acctype = "ftp" ]; then
echo ""
else
#clear
echo "I'm sorry, i need to break this up right now."
echo "It seams you can't understand some simple instructions.."
exit 1;
fi
fi
echo "Enter the Accountname:"
read accname
## quota
accquota="quota not yet implemented"
## requester
echo ""
echo "Who orderd this account? (I'm tracking this for greater good)"
read accrequester
## set $accport
if [ $acctype = "sftp" ]; then
accport="22"
else
accport="21"
fi
## get timestamp
acctimestamp=$(date)
## gen password (acpass)
accpass=$(pwgen -sync 10 1)
## create home, set its permissions and add the user to sftp/ftpgroup
if [ $acctype = "sftp" ]; then
mkdir -p $accpath/$acctype"_accounts"/$accname/data
# create the actual user (sftp)
useradd -d /data -M -U -s /usr/lib/sftp-server -p $accpass $accname
chown -R $accname\: $accpath/$acctype"_accounts"/$accname/data
adduser $accname $sftpgroup
else
mkdir -p $accpath/$acctype"_accounts"/$accname
# create the actual user (ftp)
useradd -d $accpath/$acctype"_accounts"/$accname -M -U -s /bin/false -p $accpass $accname
chown -R $accname\: $accpath/$acctype"_accounts"/$accname
adduser $accname $ftpgroup
fi
## logging (log type, name, pass, quota, requester and timestamp)
if [ $logging = 1 ]; then
if [ -e $logpath/$logfile ]; then
cd $logpath
echo $acctype $accname $accpass $accquota $accrequester $acctimestamp >> $logfile
else
mkdir -p $logpath
cd $logpath
touch $logfile
echo "type name pass quota reguester timestamp" >> $logfile
echo $acctype $accname $accpass $accquota $accrequester $acctimestamp >> $logfile
fi
else
echo ""
fi
## jabber notification
if [ $jabberlog = 1 ]; then
echo "
This is Lieutenant Sulu,
a "$acctype" account was just created.
Accountname:" $accname "
Quota:" $accquota "
Requester:" $accrequester | sendxmpp -u $jabberuser -j $jabberserver -p $jabberpass $jabberwatchdogs
else
echo ""
fi
## account data output
clear
echo ""
echo "Account data"
echo ""
echo "Host:" $acchost
echo "Port:" $accport
echo "Username:" $accname
echo "Password:" $accpass
echo "Quota:" $accquota
echo "Directory:" $accpath/$acctype"_accounts"/$accname
echo "Requester:" $accrequester
echo ""
echo "Everything is done"

76
usihelper.sh Executable file
View File

@ -0,0 +1,76 @@
#!/bin/bash
# hello message
echo "
##
## Ubuntu Software Install
## Helper Script
## v0.01
##
## Author: David Starzengruber
##
###########################################"
# am_i_root check
if [ $USER != "root" ]; then
echo "Sorry $USER, you need to run this script as user root! (try: sudo ./usihelper.sh)"
else
echo "Getting root privileges.."
fi
# var init
i="run"
do_systemupgrade="somethingelse"
echo "Updateing package sources.."
sudo apt-get update > /dev/null
# systemupgrade?
while [ $i == "run" ]; do
echo "Do you want to perform a full system upgrade first?(yes/no)"; read do_systemupgrade
if [ $do_systemupgrade == "yes" ]; then
sudo apt-get -y dist-upgrade | grep upgraded
i="upgraded"
else
if [ $do_systemupgrade == "no" ]; then
echo "Systemupgrade skipped!"
i="skipped"
else
echo "You need to type exactly yes or no!"
i="run"
fi
fi
done
i="run"
# choose softwarepackages (desktop, server, virtserver)
while [ $i == "run" ]; do
echo "Which sofware package you want to install? (desktop, server, virtserver)"; read package
if [ $package = "desktop" ]; then
echo "Installing desktop packages.."
sudo apt-get install -y htop nload nmap ncdu flashplugin-nonfree icedtea6-plugin vlc gimp discus | grep upgraded
i="desktop"
else
if [ $package = "server" ]; then
echo "Installing server packages.."
sudo apt-get install -y htop nload nmap ncdu discus ssh
i="server"
else
if [ $package = "virtserver" ]; then
echo "Installing virtual server packages.."
sudo apt-get install -y htop nload nmap ncdu discus ssh bash-completion
i="virtserver"
else
echo "You must use one of the possible values!"
i="run"
fi
fi
fi
done
echo "Cleaning up!"
sudo apt-get -y autoremove > /dev/null
echo "Everything is done!"
exit