Skip to main content
Code Review

Return to Question

Rollback to Revision 7
Source Link
Vogel612
  • 25.5k
  • 7
  • 59
  • 141

EDIT:

After editing the program it looks like this:

#!/bin/bash -x
# redirect all errors to a file
exec 2>debianConfigVersion3.1ERRORS.txt
exec 3>>cpSuccessCodes.txt
SCRIPTNAME=$(basename "0ドル")
if [ "$#" -eq 0 ]
then
 echo "No arguments supplied"
 echo "Usage: $SCRIPTNAME user1name user2name\(optional\) user3name\(optional\)"
 sleep 10
 exit 27
fi
echo "Here starts the party, START"
sleep 2
echo "Setting up server.........."
sleep 2
CURRENTDIR=/tmp/svaka
BASHRC=.bashrc
NANORC=.nanorc
BASHRCROOT=.bashrcroot
ROOT=root
USER_PROGRAMMER=""
SOURCE=sources.list
echo "Please select/provide the port-number for ssh in iptables and sshd_config:"
read -r port
PORT=$port
############################### make all files writable, executable and readable in the working directory#########
if chmod 777 "$CURRENTDIR"/*
then
 continue
else
 exit 127
fi
################ Users and access settings #####################1
checkIfUser()
{
 for name in "$@"
 do
 if id -u "$name" #>/dev/null 2>&1
 then
 echo "User: $name exists....setting up now!"
 sleep 5
 else
 echo "User: $name does not exists....creating now!"
 useradd -m -s /bin/bash "$name" #>/dev/null 2>&1
 sleep 5
 fi
 done
}
################33 user passwords2
userPass()
{
 for i in "$@"
 do
 if [ "$i" = root ]
 then
 continue
 fi
 if [[ $(passwd --status "$i" | awk '{print 2ドル}') = NP ]]
 then
 echo "$i doesn't have a password."
 echo "Changing password for $i:"
 echo $i:$i"YOURSTRONGPASSWORDHERE12345Áá" | chpasswd
 if [ "$?" = 0 ]
 then
 echo "Password for user $i changed successfully"
 sleep 5
 fi
 fi
 done
}
################################################ setting up iptables ####################3
setUPiptables()
{
 if ! grep -e '-A INPUT -p tcp --dport 80 -j ACCEPT' /etc/iptables.up.rules
 then
 cat << EOT >> /etc/iptables.test.rules
 *filter
 
 $PORT
 IPTABLES CODE HERE
 COMMIT
EOT
 sleep 5
 /sbin/iptables-restore < /etc/iptables.test.rules || exit 127
 sleep 5
 /sbin/iptables-save > /etc/iptables.up.rules || exit 127
 sleep 3
 printf "#!/bin/bash\n/sbin/iptables-restore < /etc/iptables.up.rules" > /etc/network/if-pre-up.d/iptables
 chmod +x /etc/network/if-pre-up.d/iptables
 sleep 6
 fi
}
###################################################33 sshd_config4
setUPsshd()
{
 cp -f "$CURRENTDIR/sshd_config" /etc/ssh/sshd_config
 sed -i "s/Port 34504/Port $PORT/" /etc/ssh/sshd_config
 chmod 644 /etc/ssh/sshd_config
 /etc/init.d/ssh restart
}
#################################################3333 Remove or comment out DVD/cd line from sources.list5
editSources()
{
 sed -i '/deb cdrom:\[Debian GNU\/Linux/s/^/#/' /etc/apt/sources.list
}
####################################################33 update system6
updateSystem()
{
 apt update && apt upgrade -y
}
###############################################################7
############################# check if programs installed and/or install
checkPrograms()
{
 if [ ! -x /usr/bin/git ] || [ ! -x /usr/bin/wget ] || [ ! -x /usr/bin/curl ] || [ ! -x /usr/bin/gcc ] || [ ! -x /usr/bin/make ]
 then
 echo "Some tools with which to work with data not found installing now......................"
 apt install -y git wget curl gcc make
 fi
}
#####################################################3 update sources.list8
updateSources()
{
 cp -f "$CURRENTDIR/$SOURCE" /etc/apt/sources.list || echo "Failed cp \$CURRENTDIR/\$SOURCE"; exit 127
 chmod 644 /etc/apt/sources.list
 wget http://www.deb-multimedia.org/pool/main/d/deb-multimedia-keyring/deb-multimedia-keyring_2016年8月1日_all.deb
 dpkg -i deb-multimedia-keyring_2016年8月1日_all.deb
 wget -q https://www.virtualbox.org/download/oracle_vbox_2016.asc -O- | sudo apt-key add -
 updateSystem
 apt install -y vlc vlc-data browser-plugin-vlc mplayer youtube-dl libdvdcss2 libdvdnav4 libdvdread4 smplayer mencoder
 sleep 5
 updateSystem
 sleep 5
}
#####################################################3 run methods here↓ ###################################################3
##################################################### ###################################################
checkIfUser "$@"
userPass "$@"
setUPiptables
setUPsshd
editSources
updateSystem
checkPrograms
updateSources
########################################################################################################### #####3##
##############################################################################################################3Methods
##########################################3 Disable login www #########
passwd -l www-data
#################################### firmware
apt install -y firmware-linux-nonfree firmware-linux
sleep 5
################ NANO SYNTAX-HIGHLIGHTING #####################3
if [ ! -d "$CURRENTDIR/nanorc" ]
then
 if [ "$UID" != 0 ]
 then
 sudo -u "$ROOT" bash <<'EOF'
 sleep 5
 git clone https://github.com/nanorc/nanorc.git
 sleep 5
 cd nanorc || echo "Couldn't cd nanorc"; exit 127
 make install-global
 sleep 5
 cp -f "$CURRENTDIR/.nanorc" /etc/nanorc
 chown root:root /etc/nanorc
 chmod 644 /etc/nanorc
 if [ "$?" = 0 ]
 then
 echo "Implementing a custom nanorc file succeeded\!"
 else
 echo "Nano setup DID NOT SUCCEED\!"
 fi
EOF
 else
 echo "Doing user: $USER....please, wait\!"
 git clone https://github.com/nanorc/nanorc.git
 sleep 5
 cd nanorc || echo "Couldn't cd nanorc"; exit 127
 sleep 5
 make install-global
 sleep 5
 echo "nanorc" >&3
 cp -f "$CURRENTDIR/$NANORC" /etc/nanorc >&3
 echo $? >&3
 chown root:root /etc/nanorc
 chmod 644 /etc/nanorc
 if [ "$?" = 0 ]
 then
 echo "Implementing a custom nanorc file succeeded\!"
 else
 echo "Nano setup DID NOT SUCCEED\!"
 fi
 fi
fi
echo "Finished setting up nano\!"
################ LS_COLORS SETTINGS #############################
if ! grep 'eval $(dircolors -b $HOME/.dircolors)' /root/.bashrc
then
 if [ "$UID" != 0 ]
 then
 echo "This program should be run as root, exiting! now....."
 exit 1
 # sudo -i -u "$ROOT" CURRENTDIR="$CURRENTDIR" BASHRC="$BASHRCROOT" bash <<'EOF'
 # BASHRCROOT=.bashrcroot
 # cp "$CURRENTDIR/$BASHRCROOT" "$HOME"/.bashrc
 # wget https://raw.github.com/trapd00r/LS_COLORS/master/LS_COLORS -O "$HOME"/.dircolors
 # echo 'eval $(dircolors -b $HOME/.dircolors)' >> "$HOME"/.bashrc
#EOF
 else
 echo "rootBashrc" >&3
 if cp -f "$CURRENTDIR/$BASHRCROOT" "$HOME"/.bashrc >&3
 then
 continue
 else
 echo "Root bashrc cp failed, exiting now!"
 exit 127
 fi
 chown root:root "$HOME/.bashrc"
 chmod 644 "$HOME/.bashrc"
 sleep 5
 wget https://raw.github.com/trapd00r/LS_COLORS/master/LS_COLORS -O "$HOME"/.dircolors
 sleep 5
 echo 'eval $(dircolors -b $HOME/.dircolors)' >> "$HOME"/.bashrc
 fi
fi
for user in "$@"
do
 if [ "$user" = root ]
 then
 continue
 fi
 sudo -i -u "$user" user="$user" CURRENTDIR="$CURRENTDIR" BASHRC="$BASHRC" bash <<'EOF'
 sleep 5
 echo "usersBashrc" >&3
 if cp -f "$CURRENTDIR/$BASHRC" "$HOME/.bashrc" >&3
 then
 continue
 else
 echo "Couldn't cp .bashrc for user $user"
 exit 127
 fi
 chown $user:$user "$HOME/.bashrc"
 chmod 644 "$HOME/.bashrc"
 sleep 5
 wget https://raw.github.com/trapd00r/LS_COLORS/master/LS_COLORS -O "$HOME"/.dircolors
 sleep 5
 echo 'eval $(dircolors -b $HOME/.dircolors)' >> "$HOME"/.bashrc
EOF
done
echo "Finished setting up your system\!"
echo rm -rf /tmp/svaka

@hjpotter92 Thank you for the info on shellcheck.....

EDIT:

After editing the program it looks like this:

#!/bin/bash -x
# redirect all errors to a file
exec 2>debianConfigVersion3.1ERRORS.txt
exec 3>>cpSuccessCodes.txt
SCRIPTNAME=$(basename "0ドル")
if [ "$#" -eq 0 ]
then
 echo "No arguments supplied"
 echo "Usage: $SCRIPTNAME user1name user2name\(optional\) user3name\(optional\)"
 sleep 10
 exit 27
fi
echo "Here starts the party, START"
sleep 2
echo "Setting up server.........."
sleep 2
CURRENTDIR=/tmp/svaka
BASHRC=.bashrc
NANORC=.nanorc
BASHRCROOT=.bashrcroot
ROOT=root
USER_PROGRAMMER=""
SOURCE=sources.list
echo "Please select/provide the port-number for ssh in iptables and sshd_config:"
read -r port
PORT=$port
############################### make all files writable, executable and readable in the working directory#########
if chmod 777 "$CURRENTDIR"/*
then
 continue
else
 exit 127
fi
################ Users and access settings #####################1
checkIfUser()
{
 for name in "$@"
 do
 if id -u "$name" #>/dev/null 2>&1
 then
 echo "User: $name exists....setting up now!"
 sleep 5
 else
 echo "User: $name does not exists....creating now!"
 useradd -m -s /bin/bash "$name" #>/dev/null 2>&1
 sleep 5
 fi
 done
}
################33 user passwords2
userPass()
{
 for i in "$@"
 do
 if [ "$i" = root ]
 then
 continue
 fi
 if [[ $(passwd --status "$i" | awk '{print 2ドル}') = NP ]]
 then
 echo "$i doesn't have a password."
 echo "Changing password for $i:"
 echo $i:$i"YOURSTRONGPASSWORDHERE12345Áá" | chpasswd
 if [ "$?" = 0 ]
 then
 echo "Password for user $i changed successfully"
 sleep 5
 fi
 fi
 done
}
################################################ setting up iptables ####################3
setUPiptables()
{
 if ! grep -e '-A INPUT -p tcp --dport 80 -j ACCEPT' /etc/iptables.up.rules
 then
 cat << EOT >> /etc/iptables.test.rules
 *filter
 
 $PORT
 IPTABLES CODE HERE
 COMMIT
EOT
 sleep 5
 /sbin/iptables-restore < /etc/iptables.test.rules || exit 127
 sleep 5
 /sbin/iptables-save > /etc/iptables.up.rules || exit 127
 sleep 3
 printf "#!/bin/bash\n/sbin/iptables-restore < /etc/iptables.up.rules" > /etc/network/if-pre-up.d/iptables
 chmod +x /etc/network/if-pre-up.d/iptables
 sleep 6
 fi
}
###################################################33 sshd_config4
setUPsshd()
{
 cp -f "$CURRENTDIR/sshd_config" /etc/ssh/sshd_config
 sed -i "s/Port 34504/Port $PORT/" /etc/ssh/sshd_config
 chmod 644 /etc/ssh/sshd_config
 /etc/init.d/ssh restart
}
#################################################3333 Remove or comment out DVD/cd line from sources.list5
editSources()
{
 sed -i '/deb cdrom:\[Debian GNU\/Linux/s/^/#/' /etc/apt/sources.list
}
####################################################33 update system6
updateSystem()
{
 apt update && apt upgrade -y
}
###############################################################7
############################# check if programs installed and/or install
checkPrograms()
{
 if [ ! -x /usr/bin/git ] || [ ! -x /usr/bin/wget ] || [ ! -x /usr/bin/curl ] || [ ! -x /usr/bin/gcc ] || [ ! -x /usr/bin/make ]
 then
 echo "Some tools with which to work with data not found installing now......................"
 apt install -y git wget curl gcc make
 fi
}
#####################################################3 update sources.list8
updateSources()
{
 cp -f "$CURRENTDIR/$SOURCE" /etc/apt/sources.list || echo "Failed cp \$CURRENTDIR/\$SOURCE"; exit 127
 chmod 644 /etc/apt/sources.list
 wget http://www.deb-multimedia.org/pool/main/d/deb-multimedia-keyring/deb-multimedia-keyring_2016年8月1日_all.deb
 dpkg -i deb-multimedia-keyring_2016年8月1日_all.deb
 wget -q https://www.virtualbox.org/download/oracle_vbox_2016.asc -O- | sudo apt-key add -
 updateSystem
 apt install -y vlc vlc-data browser-plugin-vlc mplayer youtube-dl libdvdcss2 libdvdnav4 libdvdread4 smplayer mencoder
 sleep 5
 updateSystem
 sleep 5
}
#####################################################3 run methods here↓ ###################################################3
##################################################### ###################################################
checkIfUser "$@"
userPass "$@"
setUPiptables
setUPsshd
editSources
updateSystem
checkPrograms
updateSources
########################################################################################################### #####3##
##############################################################################################################3Methods
##########################################3 Disable login www #########
passwd -l www-data
#################################### firmware
apt install -y firmware-linux-nonfree firmware-linux
sleep 5
################ NANO SYNTAX-HIGHLIGHTING #####################3
if [ ! -d "$CURRENTDIR/nanorc" ]
then
 if [ "$UID" != 0 ]
 then
 sudo -u "$ROOT" bash <<'EOF'
 sleep 5
 git clone https://github.com/nanorc/nanorc.git
 sleep 5
 cd nanorc || echo "Couldn't cd nanorc"; exit 127
 make install-global
 sleep 5
 cp -f "$CURRENTDIR/.nanorc" /etc/nanorc
 chown root:root /etc/nanorc
 chmod 644 /etc/nanorc
 if [ "$?" = 0 ]
 then
 echo "Implementing a custom nanorc file succeeded\!"
 else
 echo "Nano setup DID NOT SUCCEED\!"
 fi
EOF
 else
 echo "Doing user: $USER....please, wait\!"
 git clone https://github.com/nanorc/nanorc.git
 sleep 5
 cd nanorc || echo "Couldn't cd nanorc"; exit 127
 sleep 5
 make install-global
 sleep 5
 echo "nanorc" >&3
 cp -f "$CURRENTDIR/$NANORC" /etc/nanorc >&3
 echo $? >&3
 chown root:root /etc/nanorc
 chmod 644 /etc/nanorc
 if [ "$?" = 0 ]
 then
 echo "Implementing a custom nanorc file succeeded\!"
 else
 echo "Nano setup DID NOT SUCCEED\!"
 fi
 fi
fi
echo "Finished setting up nano\!"
################ LS_COLORS SETTINGS #############################
if ! grep 'eval $(dircolors -b $HOME/.dircolors)' /root/.bashrc
then
 if [ "$UID" != 0 ]
 then
 echo "This program should be run as root, exiting! now....."
 exit 1
 # sudo -i -u "$ROOT" CURRENTDIR="$CURRENTDIR" BASHRC="$BASHRCROOT" bash <<'EOF'
 # BASHRCROOT=.bashrcroot
 # cp "$CURRENTDIR/$BASHRCROOT" "$HOME"/.bashrc
 # wget https://raw.github.com/trapd00r/LS_COLORS/master/LS_COLORS -O "$HOME"/.dircolors
 # echo 'eval $(dircolors -b $HOME/.dircolors)' >> "$HOME"/.bashrc
#EOF
 else
 echo "rootBashrc" >&3
 if cp -f "$CURRENTDIR/$BASHRCROOT" "$HOME"/.bashrc >&3
 then
 continue
 else
 echo "Root bashrc cp failed, exiting now!"
 exit 127
 fi
 chown root:root "$HOME/.bashrc"
 chmod 644 "$HOME/.bashrc"
 sleep 5
 wget https://raw.github.com/trapd00r/LS_COLORS/master/LS_COLORS -O "$HOME"/.dircolors
 sleep 5
 echo 'eval $(dircolors -b $HOME/.dircolors)' >> "$HOME"/.bashrc
 fi
fi
for user in "$@"
do
 if [ "$user" = root ]
 then
 continue
 fi
 sudo -i -u "$user" user="$user" CURRENTDIR="$CURRENTDIR" BASHRC="$BASHRC" bash <<'EOF'
 sleep 5
 echo "usersBashrc" >&3
 if cp -f "$CURRENTDIR/$BASHRC" "$HOME/.bashrc" >&3
 then
 continue
 else
 echo "Couldn't cp .bashrc for user $user"
 exit 127
 fi
 chown $user:$user "$HOME/.bashrc"
 chmod 644 "$HOME/.bashrc"
 sleep 5
 wget https://raw.github.com/trapd00r/LS_COLORS/master/LS_COLORS -O "$HOME"/.dircolors
 sleep 5
 echo 'eval $(dircolors -b $HOME/.dircolors)' >> "$HOME"/.bashrc
EOF
done
echo "Finished setting up your system\!"
echo rm -rf /tmp/svaka

@hjpotter92 Thank you for the info on shellcheck.....

deleted 3 characters in body
Source Link
#!/bin/bash -x
# redirect all errors to a file
exec 2>debianConfigVersion3.1ERRORS.txt
exec 3>>cpSuccessCodes.txt
SCRIPTNAME=$(basename "0ドル")
if [ "$#" -eq 0 ]
then
 echo "No arguments supplied"
 echo "Usage: $SCRIPTNAME user1name user2name\(optional\) user3name\(optional\)"
 sleep 10
 exit 27
fi
echo "Here starts the party, START"
sleep 2
echo "Setting up server.........."
sleep 2
CURRENTDIR=/tmp/svaka
BASHRC=.bashrc
NANORC=.nanorc
BASHRCROOT=.bashrcroot
ROOT=root
USER_PROGRAMMER=""
SOURCE=sources.list
echo "Please select/provide the port-number for ssh in iptables and sshd_config:"
read -p -r port
PORT=$port
############################### make all files writable, executable and readable in the working directory#########
if chmod 777 "$CURRENTDIR"/*
then
 continue
else
 exit 127
fi
################ Users and access settings #####################1
checkIfUser()
{
 for name in "$@"
 do
 if id -u "$name" #>/dev/null 2>&1
 then
 echo "User: $name exists....setting up now!"
 sleep 5
 else
 echo "User: $name does not exists....creating now!"
 useradd -m -s /bin/bash "$name" #>/dev/null 2>&1
 sleep 5
 fi
 done
}
################33 user passwords2
userPass()
{
 for i in "$@"
 do
 if [ "$i" = root ]
 then
 continue
 fi
 if [[ $(passwd --status "$i" | awk '{print 2ドル}') = NP ]]
 then
 echo "$i doesn't have a password."
 echo "Changing password for $i:"
 echo $i:$i"YOURSTRONGPASSWORDHERE12345Áá" | chpasswd
 if [ "$?" = 0 ]
 then
 echo "Password for user $i changed successfully"
 sleep 5
 fi
 fi
 done
}
################################################ setting up iptables ####################3
setUPiptables()
{
 if ! grep -e '-A INPUT -p tcp --dport 80 -j ACCEPT' /etc/iptables.up.rules
 then
 cat << EOT >> /etc/iptables.test.rules
 *filter
 
 $PORT
 IPTABLES CODE HERE
 COMMIT
EOT
 sleep 5
 /sbin/iptables-restore < /etc/iptables.test.rules || exit 127
 sleep 5
 /sbin/iptables-save > /etc/iptables.up.rules || exit 127
 sleep 3
 printf "#!/bin/bash\n/sbin/iptables-restore < /etc/iptables.up.rules" > /etc/network/if-pre-up.d/iptables
 chmod +x /etc/network/if-pre-up.d/iptables
 sleep 6
 fi
}
###################################################33 sshd_config4
setUPsshd()
{
 cp -f "$CURRENTDIR/sshd_config" /etc/ssh/sshd_config
 sed -i "s/Port 34504/Port $PORT/" /etc/ssh/sshd_config
 chmod 644 /etc/ssh/sshd_config
 /etc/init.d/ssh restart
}
#################################################3333 Remove or comment out DVD/cd line from sources.list5
editSources()
{
 sed -i '/deb cdrom:\[Debian GNU\/Linux/s/^/#/' /etc/apt/sources.list
}
####################################################33 update system6
updateSystem()
{
 apt update && apt upgrade -y
}
###############################################################7
############################# check if programs installed and/or install
checkPrograms()
{
 if [ ! -x /usr/bin/git ] || [ ! -x /usr/bin/wget ] || [ ! -x /usr/bin/curl ] || [ ! -x /usr/bin/gcc ] || [ ! -x /usr/bin/make ]
 then
 echo "Some tools with which to work with data not found installing now......................"
 apt install -y git wget curl gcc make
 fi
}
#####################################################3 update sources.list8
updateSources()
{
 cp -f "$CURRENTDIR/$SOURCE" /etc/apt/sources.list || echo "Failed cp \$CURRENTDIR/\$SOURCE"; exit 127
 chmod 644 /etc/apt/sources.list
 wget http://www.deb-multimedia.org/pool/main/d/deb-multimedia-keyring/deb-multimedia-keyring_2016年8月1日_all.deb
 dpkg -i deb-multimedia-keyring_2016年8月1日_all.deb
 wget -q https://www.virtualbox.org/download/oracle_vbox_2016.asc -O- | sudo apt-key add -
 updateSystem
 apt install -y vlc vlc-data browser-plugin-vlc mplayer youtube-dl libdvdcss2 libdvdnav4 libdvdread4 smplayer mencoder
 sleep 5
 updateSystem
 sleep 5
}
#####################################################3 run methods here↓ ###################################################3
##################################################### ###################################################
checkIfUser "$@"
userPass "$@"
setUPiptables
setUPsshd
editSources
updateSystem
checkPrograms
updateSources
########################################################################################################### #####3##
##############################################################################################################3Methods
##########################################3 Disable login www #########
passwd -l www-data
#################################### firmware
apt install -y firmware-linux-nonfree firmware-linux
sleep 5
################ NANO SYNTAX-HIGHLIGHTING #####################3
if [ ! -d "$CURRENTDIR/nanorc" ]
then
 if [ "$UID" != 0 ]
 then
 sudo -u "$ROOT" bash <<'EOF'
 sleep 5
 git clone https://github.com/nanorc/nanorc.git
 sleep 5
 cd nanorc || echo "Couldn't cd nanorc"; exit 127
 make install-global
 sleep 5
 cp -f "$CURRENTDIR/.nanorc" /etc/nanorc
 chown root:root /etc/nanorc
 chmod 644 /etc/nanorc
 if [ "$?" = 0 ]
 then
 echo "Implementing a custom nanorc file succeeded\!"
 else
 echo "Nano setup DID NOT SUCCEED\!"
 fi
EOF
 else
 echo "Doing user: $USER....please, wait\!"
 git clone https://github.com/nanorc/nanorc.git
 sleep 5
 cd nanorc || echo "Couldn't cd nanorc"; exit 127
 sleep 5
 make install-global
 sleep 5
 echo "nanorc" >&3
 cp -f "$CURRENTDIR/$NANORC" /etc/nanorc >&3
 echo $? >&3
 chown root:root /etc/nanorc
 chmod 644 /etc/nanorc
 if [ "$?" = 0 ]
 then
 echo "Implementing a custom nanorc file succeeded\!"
 else
 echo "Nano setup DID NOT SUCCEED\!"
 fi
 fi
fi
echo "Finished setting up nano\!"
################ LS_COLORS SETTINGS #############################
if ! grep 'eval $(dircolors -b $HOME/.dircolors)' /root/.bashrc
then
 if [ "$UID" != 0 ]
 then
 echo "This program should be run as root, exiting! now....."
 exit 1
 # sudo -i -u "$ROOT" CURRENTDIR="$CURRENTDIR" BASHRC="$BASHRCROOT" bash <<'EOF'
 # BASHRCROOT=.bashrcroot
 # cp "$CURRENTDIR/$BASHRCROOT" "$HOME"/.bashrc
 # wget https://raw.github.com/trapd00r/LS_COLORS/master/LS_COLORS -O "$HOME"/.dircolors
 # echo 'eval $(dircolors -b $HOME/.dircolors)' >> "$HOME"/.bashrc
#EOF
 else
 echo "rootBashrc" >&3
 if cp -f "$CURRENTDIR/$BASHRCROOT" "$HOME"/.bashrc >&3
 then
 continue
 else
 echo "Root bashrc cp failed, exiting now!"
 exit 127
 fi
 chown root:root "$HOME/.bashrc"
 chmod 644 "$HOME/.bashrc"
 sleep 5
 wget https://raw.github.com/trapd00r/LS_COLORS/master/LS_COLORS -O "$HOME"/.dircolors
 sleep 5
 echo 'eval $(dircolors -b $HOME/.dircolors)' >> "$HOME"/.bashrc
 fi
fi
for user in "$@"
do
 if [ "$user" = root ]
 then
 continue
 fi
 sudo -i -u "$user" user="$user" CURRENTDIR="$CURRENTDIR" BASHRC="$BASHRC" bash <<'EOF'
 sleep 5
 echo "usersBashrc" >&3
 if cp -f "$CURRENTDIR/$BASHRC" "$HOME/.bashrc" >&3
 then
 continue
 else
 echo "Couldn't cp .bashrc for user $user"
 exit 127
 fi
 chown $user:$user "$HOME/.bashrc"
 chmod 644 "$HOME/.bashrc"
 sleep 5
 wget https://raw.github.com/trapd00r/LS_COLORS/master/LS_COLORS -O "$HOME"/.dircolors
 sleep 5
 echo 'eval $(dircolors -b $HOME/.dircolors)' >> "$HOME"/.bashrc
EOF
done
echo "Finished setting up your system\!"
echo rm -rf /tmp/svaka
#!/bin/bash -x
# redirect all errors to a file
exec 2>debianConfigVersion3.1ERRORS.txt
exec 3>>cpSuccessCodes.txt
SCRIPTNAME=$(basename "0ドル")
if [ "$#" -eq 0 ]
then
 echo "No arguments supplied"
 echo "Usage: $SCRIPTNAME user1name user2name\(optional\) user3name\(optional\)"
 sleep 10
 exit 27
fi
echo "Here starts the party, START"
sleep 2
echo "Setting up server.........."
sleep 2
CURRENTDIR=/tmp/svaka
BASHRC=.bashrc
NANORC=.nanorc
BASHRCROOT=.bashrcroot
ROOT=root
USER_PROGRAMMER=""
SOURCE=sources.list
echo "Please select/provide the port-number for ssh in iptables and sshd_config:"
read -p -r port
PORT=$port
############################### make all files writable, executable and readable in the working directory#########
if chmod 777 "$CURRENTDIR"/*
then
 continue
else
 exit 127
fi
################ Users and access settings #####################1
checkIfUser()
{
 for name in "$@"
 do
 if id -u "$name" #>/dev/null 2>&1
 then
 echo "User: $name exists....setting up now!"
 sleep 5
 else
 echo "User: $name does not exists....creating now!"
 useradd -m -s /bin/bash "$name" #>/dev/null 2>&1
 sleep 5
 fi
 done
}
################33 user passwords2
userPass()
{
 for i in "$@"
 do
 if [ "$i" = root ]
 then
 continue
 fi
 if [[ $(passwd --status "$i" | awk '{print 2ドル}') = NP ]]
 then
 echo "$i doesn't have a password."
 echo "Changing password for $i:"
 echo $i:$i"YOURSTRONGPASSWORDHERE12345Áá" | chpasswd
 if [ "$?" = 0 ]
 then
 echo "Password for user $i changed successfully"
 sleep 5
 fi
 fi
 done
}
################################################ setting up iptables ####################3
setUPiptables()
{
 if ! grep -e '-A INPUT -p tcp --dport 80 -j ACCEPT' /etc/iptables.up.rules
 then
 cat << EOT >> /etc/iptables.test.rules
 *filter
 
 $PORT
 IPTABLES CODE HERE
 COMMIT
EOT
 sleep 5
 /sbin/iptables-restore < /etc/iptables.test.rules || exit 127
 sleep 5
 /sbin/iptables-save > /etc/iptables.up.rules || exit 127
 sleep 3
 printf "#!/bin/bash\n/sbin/iptables-restore < /etc/iptables.up.rules" > /etc/network/if-pre-up.d/iptables
 chmod +x /etc/network/if-pre-up.d/iptables
 sleep 6
 fi
}
###################################################33 sshd_config4
setUPsshd()
{
 cp -f "$CURRENTDIR/sshd_config" /etc/ssh/sshd_config
 sed -i "s/Port 34504/Port $PORT/" /etc/ssh/sshd_config
 chmod 644 /etc/ssh/sshd_config
 /etc/init.d/ssh restart
}
#################################################3333 Remove or comment out DVD/cd line from sources.list5
editSources()
{
 sed -i '/deb cdrom:\[Debian GNU\/Linux/s/^/#/' /etc/apt/sources.list
}
####################################################33 update system6
updateSystem()
{
 apt update && apt upgrade -y
}
###############################################################7
############################# check if programs installed and/or install
checkPrograms()
{
 if [ ! -x /usr/bin/git ] || [ ! -x /usr/bin/wget ] || [ ! -x /usr/bin/curl ] || [ ! -x /usr/bin/gcc ] || [ ! -x /usr/bin/make ]
 then
 echo "Some tools with which to work with data not found installing now......................"
 apt install -y git wget curl gcc make
 fi
}
#####################################################3 update sources.list8
updateSources()
{
 cp -f "$CURRENTDIR/$SOURCE" /etc/apt/sources.list || echo "Failed cp \$CURRENTDIR/\$SOURCE"; exit 127
 chmod 644 /etc/apt/sources.list
 wget http://www.deb-multimedia.org/pool/main/d/deb-multimedia-keyring/deb-multimedia-keyring_2016年8月1日_all.deb
 dpkg -i deb-multimedia-keyring_2016年8月1日_all.deb
 wget -q https://www.virtualbox.org/download/oracle_vbox_2016.asc -O- | sudo apt-key add -
 updateSystem
 apt install -y vlc vlc-data browser-plugin-vlc mplayer youtube-dl libdvdcss2 libdvdnav4 libdvdread4 smplayer mencoder
 sleep 5
 updateSystem
 sleep 5
}
#####################################################3 run methods here↓ ###################################################3
##################################################### ###################################################
checkIfUser "$@"
userPass "$@"
setUPiptables
setUPsshd
editSources
updateSystem
checkPrograms
updateSources
########################################################################################################### #####3##
##############################################################################################################3Methods
##########################################3 Disable login www #########
passwd -l www-data
#################################### firmware
apt install -y firmware-linux-nonfree firmware-linux
sleep 5
################ NANO SYNTAX-HIGHLIGHTING #####################3
if [ ! -d "$CURRENTDIR/nanorc" ]
then
 if [ "$UID" != 0 ]
 then
 sudo -u "$ROOT" bash <<'EOF'
 sleep 5
 git clone https://github.com/nanorc/nanorc.git
 sleep 5
 cd nanorc || echo "Couldn't cd nanorc"; exit 127
 make install-global
 sleep 5
 cp -f "$CURRENTDIR/.nanorc" /etc/nanorc
 chown root:root /etc/nanorc
 chmod 644 /etc/nanorc
 if [ "$?" = 0 ]
 then
 echo "Implementing a custom nanorc file succeeded\!"
 else
 echo "Nano setup DID NOT SUCCEED\!"
 fi
EOF
 else
 echo "Doing user: $USER....please, wait\!"
 git clone https://github.com/nanorc/nanorc.git
 sleep 5
 cd nanorc || echo "Couldn't cd nanorc"; exit 127
 sleep 5
 make install-global
 sleep 5
 echo "nanorc" >&3
 cp -f "$CURRENTDIR/$NANORC" /etc/nanorc >&3
 echo $? >&3
 chown root:root /etc/nanorc
 chmod 644 /etc/nanorc
 if [ "$?" = 0 ]
 then
 echo "Implementing a custom nanorc file succeeded\!"
 else
 echo "Nano setup DID NOT SUCCEED\!"
 fi
 fi
fi
echo "Finished setting up nano\!"
################ LS_COLORS SETTINGS #############################
if ! grep 'eval $(dircolors -b $HOME/.dircolors)' /root/.bashrc
then
 if [ "$UID" != 0 ]
 then
 echo "This program should be run as root, exiting! now....."
 exit 1
 # sudo -i -u "$ROOT" CURRENTDIR="$CURRENTDIR" BASHRC="$BASHRCROOT" bash <<'EOF'
 # BASHRCROOT=.bashrcroot
 # cp "$CURRENTDIR/$BASHRCROOT" "$HOME"/.bashrc
 # wget https://raw.github.com/trapd00r/LS_COLORS/master/LS_COLORS -O "$HOME"/.dircolors
 # echo 'eval $(dircolors -b $HOME/.dircolors)' >> "$HOME"/.bashrc
#EOF
 else
 echo "rootBashrc" >&3
 if cp -f "$CURRENTDIR/$BASHRCROOT" "$HOME"/.bashrc >&3
 then
 continue
 else
 echo "Root bashrc cp failed, exiting now!"
 exit 127
 fi
 chown root:root "$HOME/.bashrc"
 chmod 644 "$HOME/.bashrc"
 sleep 5
 wget https://raw.github.com/trapd00r/LS_COLORS/master/LS_COLORS -O "$HOME"/.dircolors
 sleep 5
 echo 'eval $(dircolors -b $HOME/.dircolors)' >> "$HOME"/.bashrc
 fi
fi
for user in "$@"
do
 if [ "$user" = root ]
 then
 continue
 fi
 sudo -i -u "$user" user="$user" CURRENTDIR="$CURRENTDIR" BASHRC="$BASHRC" bash <<'EOF'
 sleep 5
 echo "usersBashrc" >&3
 if cp -f "$CURRENTDIR/$BASHRC" "$HOME/.bashrc" >&3
 then
 continue
 else
 echo "Couldn't cp .bashrc for user $user"
 exit 127
 fi
 chown $user:$user "$HOME/.bashrc"
 chmod 644 "$HOME/.bashrc"
 sleep 5
 wget https://raw.github.com/trapd00r/LS_COLORS/master/LS_COLORS -O "$HOME"/.dircolors
 sleep 5
 echo 'eval $(dircolors -b $HOME/.dircolors)' >> "$HOME"/.bashrc
EOF
done
echo "Finished setting up your system\!"
echo rm -rf /tmp/svaka
#!/bin/bash -x
# redirect all errors to a file
exec 2>debianConfigVersion3.1ERRORS.txt
exec 3>>cpSuccessCodes.txt
SCRIPTNAME=$(basename "0ドル")
if [ "$#" -eq 0 ]
then
 echo "No arguments supplied"
 echo "Usage: $SCRIPTNAME user1name user2name\(optional\) user3name\(optional\)"
 sleep 10
 exit 27
fi
echo "Here starts the party, START"
sleep 2
echo "Setting up server.........."
sleep 2
CURRENTDIR=/tmp/svaka
BASHRC=.bashrc
NANORC=.nanorc
BASHRCROOT=.bashrcroot
ROOT=root
USER_PROGRAMMER=""
SOURCE=sources.list
echo "Please select/provide the port-number for ssh in iptables and sshd_config:"
read -r port
PORT=$port
############################### make all files writable, executable and readable in the working directory#########
if chmod 777 "$CURRENTDIR"/*
then
 continue
else
 exit 127
fi
################ Users and access settings #####################1
checkIfUser()
{
 for name in "$@"
 do
 if id -u "$name" #>/dev/null 2>&1
 then
 echo "User: $name exists....setting up now!"
 sleep 5
 else
 echo "User: $name does not exists....creating now!"
 useradd -m -s /bin/bash "$name" #>/dev/null 2>&1
 sleep 5
 fi
 done
}
################33 user passwords2
userPass()
{
 for i in "$@"
 do
 if [ "$i" = root ]
 then
 continue
 fi
 if [[ $(passwd --status "$i" | awk '{print 2ドル}') = NP ]]
 then
 echo "$i doesn't have a password."
 echo "Changing password for $i:"
 echo $i:$i"YOURSTRONGPASSWORDHERE12345Áá" | chpasswd
 if [ "$?" = 0 ]
 then
 echo "Password for user $i changed successfully"
 sleep 5
 fi
 fi
 done
}
################################################ setting up iptables ####################3
setUPiptables()
{
 if ! grep -e '-A INPUT -p tcp --dport 80 -j ACCEPT' /etc/iptables.up.rules
 then
 cat << EOT >> /etc/iptables.test.rules
 *filter
 
 $PORT
 IPTABLES CODE HERE
 COMMIT
EOT
 sleep 5
 /sbin/iptables-restore < /etc/iptables.test.rules || exit 127
 sleep 5
 /sbin/iptables-save > /etc/iptables.up.rules || exit 127
 sleep 3
 printf "#!/bin/bash\n/sbin/iptables-restore < /etc/iptables.up.rules" > /etc/network/if-pre-up.d/iptables
 chmod +x /etc/network/if-pre-up.d/iptables
 sleep 6
 fi
}
###################################################33 sshd_config4
setUPsshd()
{
 cp -f "$CURRENTDIR/sshd_config" /etc/ssh/sshd_config
 sed -i "s/Port 34504/Port $PORT/" /etc/ssh/sshd_config
 chmod 644 /etc/ssh/sshd_config
 /etc/init.d/ssh restart
}
#################################################3333 Remove or comment out DVD/cd line from sources.list5
editSources()
{
 sed -i '/deb cdrom:\[Debian GNU\/Linux/s/^/#/' /etc/apt/sources.list
}
####################################################33 update system6
updateSystem()
{
 apt update && apt upgrade -y
}
###############################################################7
############################# check if programs installed and/or install
checkPrograms()
{
 if [ ! -x /usr/bin/git ] || [ ! -x /usr/bin/wget ] || [ ! -x /usr/bin/curl ] || [ ! -x /usr/bin/gcc ] || [ ! -x /usr/bin/make ]
 then
 echo "Some tools with which to work with data not found installing now......................"
 apt install -y git wget curl gcc make
 fi
}
#####################################################3 update sources.list8
updateSources()
{
 cp -f "$CURRENTDIR/$SOURCE" /etc/apt/sources.list || echo "Failed cp \$CURRENTDIR/\$SOURCE"; exit 127
 chmod 644 /etc/apt/sources.list
 wget http://www.deb-multimedia.org/pool/main/d/deb-multimedia-keyring/deb-multimedia-keyring_2016年8月1日_all.deb
 dpkg -i deb-multimedia-keyring_2016年8月1日_all.deb
 wget -q https://www.virtualbox.org/download/oracle_vbox_2016.asc -O- | sudo apt-key add -
 updateSystem
 apt install -y vlc vlc-data browser-plugin-vlc mplayer youtube-dl libdvdcss2 libdvdnav4 libdvdread4 smplayer mencoder
 sleep 5
 updateSystem
 sleep 5
}
#####################################################3 run methods here↓ ###################################################3
##################################################### ###################################################
checkIfUser "$@"
userPass "$@"
setUPiptables
setUPsshd
editSources
updateSystem
checkPrograms
updateSources
########################################################################################################### #####3##
##############################################################################################################3Methods
##########################################3 Disable login www #########
passwd -l www-data
#################################### firmware
apt install -y firmware-linux-nonfree firmware-linux
sleep 5
################ NANO SYNTAX-HIGHLIGHTING #####################3
if [ ! -d "$CURRENTDIR/nanorc" ]
then
 if [ "$UID" != 0 ]
 then
 sudo -u "$ROOT" bash <<'EOF'
 sleep 5
 git clone https://github.com/nanorc/nanorc.git
 sleep 5
 cd nanorc || echo "Couldn't cd nanorc"; exit 127
 make install-global
 sleep 5
 cp -f "$CURRENTDIR/.nanorc" /etc/nanorc
 chown root:root /etc/nanorc
 chmod 644 /etc/nanorc
 if [ "$?" = 0 ]
 then
 echo "Implementing a custom nanorc file succeeded\!"
 else
 echo "Nano setup DID NOT SUCCEED\!"
 fi
EOF
 else
 echo "Doing user: $USER....please, wait\!"
 git clone https://github.com/nanorc/nanorc.git
 sleep 5
 cd nanorc || echo "Couldn't cd nanorc"; exit 127
 sleep 5
 make install-global
 sleep 5
 echo "nanorc" >&3
 cp -f "$CURRENTDIR/$NANORC" /etc/nanorc >&3
 echo $? >&3
 chown root:root /etc/nanorc
 chmod 644 /etc/nanorc
 if [ "$?" = 0 ]
 then
 echo "Implementing a custom nanorc file succeeded\!"
 else
 echo "Nano setup DID NOT SUCCEED\!"
 fi
 fi
fi
echo "Finished setting up nano\!"
################ LS_COLORS SETTINGS #############################
if ! grep 'eval $(dircolors -b $HOME/.dircolors)' /root/.bashrc
then
 if [ "$UID" != 0 ]
 then
 echo "This program should be run as root, exiting! now....."
 exit 1
 # sudo -i -u "$ROOT" CURRENTDIR="$CURRENTDIR" BASHRC="$BASHRCROOT" bash <<'EOF'
 # BASHRCROOT=.bashrcroot
 # cp "$CURRENTDIR/$BASHRCROOT" "$HOME"/.bashrc
 # wget https://raw.github.com/trapd00r/LS_COLORS/master/LS_COLORS -O "$HOME"/.dircolors
 # echo 'eval $(dircolors -b $HOME/.dircolors)' >> "$HOME"/.bashrc
#EOF
 else
 echo "rootBashrc" >&3
 if cp -f "$CURRENTDIR/$BASHRCROOT" "$HOME"/.bashrc >&3
 then
 continue
 else
 echo "Root bashrc cp failed, exiting now!"
 exit 127
 fi
 chown root:root "$HOME/.bashrc"
 chmod 644 "$HOME/.bashrc"
 sleep 5
 wget https://raw.github.com/trapd00r/LS_COLORS/master/LS_COLORS -O "$HOME"/.dircolors
 sleep 5
 echo 'eval $(dircolors -b $HOME/.dircolors)' >> "$HOME"/.bashrc
 fi
fi
for user in "$@"
do
 if [ "$user" = root ]
 then
 continue
 fi
 sudo -i -u "$user" user="$user" CURRENTDIR="$CURRENTDIR" BASHRC="$BASHRC" bash <<'EOF'
 sleep 5
 echo "usersBashrc" >&3
 if cp -f "$CURRENTDIR/$BASHRC" "$HOME/.bashrc" >&3
 then
 continue
 else
 echo "Couldn't cp .bashrc for user $user"
 exit 127
 fi
 chown $user:$user "$HOME/.bashrc"
 chmod 644 "$HOME/.bashrc"
 sleep 5
 wget https://raw.github.com/trapd00r/LS_COLORS/master/LS_COLORS -O "$HOME"/.dircolors
 sleep 5
 echo 'eval $(dircolors -b $HOME/.dircolors)' >> "$HOME"/.bashrc
EOF
done
echo "Finished setting up your system\!"
echo rm -rf /tmp/svaka
added 3 characters in body
Source Link
#!/bin/bash -x
# redirect all errors to a file
exec 2>debianConfigVersion3.1ERRORS.txt
exec 3>>cpSuccessCodes.txt
SCRIPTNAME=$(basename "0ドル")
if [ "$#" -eq 0 ]
then
 echo "No arguments supplied"
 echo "Usage: $SCRIPTNAME user1name user2name\(optional\) user3name\(optional\)"
 sleep 10
 exit 27
fi
echo "Here starts the party, START"
sleep 2
echo "Setting up server.........."
sleep 2
CURRENTDIR=/tmp/svaka
BASHRC=.bashrc
NANORC=.nanorc
BASHRCROOT=.bashrcroot
ROOT=root
USER_PROGRAMMER=""
SOURCE=sources.list
echo "Please select/provide the port-number for ssh in iptables and sshd_config:"
read -p -r port
PORT=$port
############################### make all files writable, executable and readable in the working directory#########
if chmod 777 "$CURRENTDIR"/*
then
 continue
else
 exit 127
fi
################ Users and access settings #####################1
checkIfUser()
{
 for name in "$@"
 do
 if id -u "$name" #>/dev/null 2>&1
 then
 echo "User: $name exists....setting up now!"
 sleep 5
 else
 echo "User: $name does not exists....creating now!"
 useradd -m -s /bin/bash "$name" #>/dev/null 2>&1
 sleep 5
 fi
 done
}
################33 user passwords2
userPass()
{
 for i in "$@"
 do
 if [ "$i" = root ]
 then
 continue
 fi
 if [[ $(passwd --status "$i" | awk '{print 2ドル}') = NP ]]
 then
 echo "$i doesn't have a password."
 echo "Changing password for $i:"
 echo $i:$i"YOURSTRONGPASSWORDHERE12345Áá" | chpasswd
 if [ "$?" = 0 ]
 then
 echo "Password for user $i changed successfully"
 sleep 5
 fi
 fi
 done
}
################################################ setting up iptables ####################3
setUPiptables()
{
 if ! grep -e '-A INPUT -p tcp --dport 80 -j ACCEPT' /etc/iptables.up.rules
 then
 cat << EOT >> /etc/iptables.test.rules
 *filter
 
 $PORT
 IPTABLES CODE HERE
 COMMIT
EOT
 sleep 5
 /sbin/iptables-restore < /etc/iptables.test.rules || exit 127
 sleep 5
 /sbin/iptables-save > /etc/iptables.up.rules || exit 127
 sleep 3
 printf "#!/bin/bash\n/sbin/iptables-restore < /etc/iptables.up.rules" > /etc/network/if-pre-up.d/iptables
 chmod +x /etc/network/if-pre-up.d/iptables
 sleep 6
 fi
}
###################################################33 sshd_config4
setUPsshd()
{
 cp -f "$CURRENTDIR/sshd_config" /etc/ssh/sshd_config
 sed -i "s/Port 34504/Port $PORT/" /etc/ssh/sshd_config
 chmod 644 /etc/ssh/sshd_config
 /etc/init.d/ssh restart
}
#################################################3333 Remove or comment out DVD/cd line from sources.list5
editSources()
{
 sed -i '/deb cdrom:\[Debian GNU\/Linux/s/^/#/' /etc/apt/sources.list
}
####################################################33 update system6
updateSystem()
{
 apt update && apt upgrade -y
}
###############################################################7
############################# check if programs installed and/or install
checkPrograms()
{
 if [ ! -x /usr/bin/git ] || [ ! -x /usr/bin/wget ] || [ ! -x /usr/bin/curl ] || [ ! -x /usr/bin/gcc ] || [ ! -x /usr/bin/make ]
 then
 echo "Some tools with which to work with data not found installing now......................"
 apt install -y git wget curl gcc make
 fi
}
#####################################################3 update sources.list8
updateSources()
{
 cp -f "$CURRENTDIR/$SOURCE" /etc/apt/sources.list || echo "Failed cp \$CURRENTDIR/\$SOURCE"; exit 127
 chmod 644 /etc/apt/sources.list
 wget http://www.deb-multimedia.org/pool/main/d/deb-multimedia-keyring/deb-multimedia-keyring_2016年8月1日_all.deb
 dpkg -i deb-multimedia-keyring_2016年8月1日_all.deb
 wget -q https://www.virtualbox.org/download/oracle_vbox_2016.asc -O- | sudo apt-key add -
 updateSystem
 apt install -y vlc vlc-data browser-plugin-vlc mplayer youtube-dl libdvdcss2 libdvdnav4 libdvdread4 smplayer mencoder
 sleep 5
 updateSystem
 sleep 5
}
#####################################################3 run methods here↓ ###################################################3
##################################################### ###################################################
checkIfUser "$@"
userPass "$@"
setUPiptables
setUPsshd
editSources
updateSystem
checkPrograms
updateSources
########################################################################################################### #####3##
##############################################################################################################3Methods
##########################################3 Disable login www #########
passwd -l www-data
#################################### firmware
apt install -y firmware-linux-nonfree firmware-linux
sleep 5
################ NANO SYNTAX-HIGHLIGHTING #####################3
if [ ! -d "$CURRENTDIR/nanorc" ]
then
 if [ "$UID" != 0 ]
 then
 sudo -u "$ROOT" bash <<'EOF'
 sleep 5
 git clone https://github.com/nanorc/nanorc.git
 sleep 5
 cd nanorc || echo "Couldn't cd nanorc"; exit 127
 make install-global
 sleep 5
 cp -f "$CURRENTDIR/.nanorc" /etc/nanorc
 chown root:root /etc/nanorc
 chmod 644 /etc/nanorc
 if [ "$?" = 0 ]
 then
 echo "Implementing a custom nanorc file succeeded\!"
 else
 echo "Nano setup DID NOT SUCCEED\!"
 fi
EOF
 else
 echo "Doing user: $USER....please, wait\!"
 git clone https://github.com/nanorc/nanorc.git
 sleep 5
 cd nanorc || echo "Couldn't cd nanorc"; exit 127
 sleep 5
 make install-global
 sleep 5
 echo "nanorc" >&3
 cp -f "$CURRENTDIR/$NANORC" /etc/nanorc >&3
 echo $? >&3
 chown root:root /etc/nanorc
 chmod 644 /etc/nanorc
 if [ "$?" = 0 ]
 then
 echo "Implementing a custom nanorc file succeeded\!"
 else
 echo "Nano setup DID NOT SUCCEED\!"
 fi
 fi
fi
echo "Finished setting up nano\!"
################ LS_COLORS SETTINGS #############################
if ! grep 'eval $(dircolors -b $HOME/.dircolors)' /root/.bashrc
then
 if [ "$UID" != 0 ]
 then
 echo "This program should be run as root, exiting! now....."
 exit 1
 # sudo -i -u "$ROOT" CURRENTDIR="$CURRENTDIR" BASHRC="$BASHRCROOT" bash <<'EOF'
 # BASHRCROOT=.bashrcroot
 # cp "$CURRENTDIR/$BASHRCROOT" "$HOME"/.bashrc
 # wget https://raw.github.com/trapd00r/LS_COLORS/master/LS_COLORS -O "$HOME"/.dircolors
 # echo 'eval $(dircolors -b $HOME/.dircolors)' >> "$HOME"/.bashrc
#EOF
 else
 echo "rootBashrc" >&3
 if cp -f "$CURRENTDIR/$BASHRCROOT" "$HOME"/.bashrc >&3
 then
 continue
 else
 echo "Root bashrc cp failed, exiting now!"
 exit 127
 fi
 chown root:root "$HOME/.bashrc"
 chmod 644 "$HOME/.bashrc"
 sleep 5
 wget https://raw.github.com/trapd00r/LS_COLORS/master/LS_COLORS -O "$HOME"/.dircolors
 sleep 5
 echo 'eval $(dircolors -b $HOME/.dircolors)' >> "$HOME"/.bashrc
 fi
fi
for user in "$@"
do
 if [ "$user" = root ]
 then
 continue
 fi
 sudo -i -u "$user" user="$user" CURRENTDIR="$CURRENTDIR" BASHRC="$BASHRC" bash <<'EOF'
 sleep 5
 echo "usersBashrc" >&3
 if cp -f "$CURRENTDIR/$BASHRC" "$HOME/.bashrc" >&3
 then
 continue
 else
 echo "Couldn't cp .bashrc for user $user"
 exit 127
 fi
 chown $user:$user "$HOME/.bashrc"
 chmod 644 "$HOME/.bashrc"
 sleep 5
 wget https://raw.github.com/trapd00r/LS_COLORS/master/LS_COLORS -O "$HOME"/.dircolors
 sleep 5
 echo 'eval $(dircolors -b $HOME/.dircolors)' >> "$HOME"/.bashrc
EOF
done
echo "Finished setting up your system\!"
echo rm -rf /tmp/svaka
#!/bin/bash -x
# redirect all errors to a file
exec 2>debianConfigVersion3.1ERRORS.txt
exec 3>>cpSuccessCodes.txt
SCRIPTNAME=$(basename "0ドル")
if [ "$#" -eq 0 ]
then
 echo "No arguments supplied"
 echo "Usage: $SCRIPTNAME user1name user2name\(optional\) user3name\(optional\)"
 sleep 10
 exit 27
fi
echo "Here starts the party, START"
sleep 2
echo "Setting up server.........."
sleep 2
CURRENTDIR=/tmp/svaka
BASHRC=.bashrc
NANORC=.nanorc
BASHRCROOT=.bashrcroot
ROOT=root
USER_PROGRAMMER=""
SOURCE=sources.list
echo "Please select/provide the port-number for ssh in iptables and sshd_config:"
read -p -r port
PORT=$port
############################### make all files writable, executable and readable in the working directory#########
if chmod 777 "$CURRENTDIR"/*
then
 continue
else
 exit 127
fi
################ Users and access settings #####################1
checkIfUser()
{
 for name in "$@"
 do
 if id -u "$name" #>/dev/null 2>&1
 then
 echo "User: $name exists....setting up now!"
 sleep 5
 else
 echo "User: $name does not exists....creating now!"
 useradd -m -s /bin/bash "$name" #>/dev/null 2>&1
 sleep 5
 fi
 done
}
################33 user passwords2
userPass()
{
 for i in "$@"
 do
 if [ "$i" = root ]
 then
 continue
 fi
 if [[ $(passwd --status "$i" | awk '{print 2ドル}') = NP ]]
 then
 echo "$i doesn't have a password."
 echo "Changing password for $i:"
 echo $i:$i"YOURSTRONGPASSWORDHERE12345Áá" | chpasswd
 if [ "$?" = 0 ]
 then
 echo "Password for user $i changed successfully"
 sleep 5
 fi
 fi
 done
}
################################################ setting up iptables ####################3
setUPiptables()
{
 if ! grep '-A INPUT -p tcp --dport 80 -j ACCEPT' /etc/iptables.up.rules
 then
 cat << EOT >> /etc/iptables.test.rules
 *filter
 
 $PORT
 IPTABLES CODE HERE
 COMMIT
EOT
 sleep 5
 /sbin/iptables-restore < /etc/iptables.test.rules || exit 127
 sleep 5
 /sbin/iptables-save > /etc/iptables.up.rules || exit 127
 sleep 3
 printf "#!/bin/bash\n/sbin/iptables-restore < /etc/iptables.up.rules" > /etc/network/if-pre-up.d/iptables
 chmod +x /etc/network/if-pre-up.d/iptables
 sleep 6
 fi
}
###################################################33 sshd_config4
setUPsshd()
{
 cp -f "$CURRENTDIR/sshd_config" /etc/ssh/sshd_config
 sed -i "s/Port 34504/Port $PORT/" /etc/ssh/sshd_config
 chmod 644 /etc/ssh/sshd_config
 /etc/init.d/ssh restart
}
#################################################3333 Remove or comment out DVD/cd line from sources.list5
editSources()
{
 sed -i '/deb cdrom:\[Debian GNU\/Linux/s/^/#/' /etc/apt/sources.list
}
####################################################33 update system6
updateSystem()
{
 apt update && apt upgrade -y
}
###############################################################7
############################# check if programs installed and/or install
checkPrograms()
{
 if [ ! -x /usr/bin/git ] || [ ! -x /usr/bin/wget ] || [ ! -x /usr/bin/curl ] || [ ! -x /usr/bin/gcc ] || [ ! -x /usr/bin/make ]
 then
 echo "Some tools with which to work with data not found installing now......................"
 apt install -y git wget curl gcc make
 fi
}
#####################################################3 update sources.list8
updateSources()
{
 cp -f "$CURRENTDIR/$SOURCE" /etc/apt/sources.list || echo "Failed cp \$CURRENTDIR/\$SOURCE"; exit 127
 chmod 644 /etc/apt/sources.list
 wget http://www.deb-multimedia.org/pool/main/d/deb-multimedia-keyring/deb-multimedia-keyring_2016年8月1日_all.deb
 dpkg -i deb-multimedia-keyring_2016年8月1日_all.deb
 wget -q https://www.virtualbox.org/download/oracle_vbox_2016.asc -O- | sudo apt-key add -
 updateSystem
 apt install -y vlc vlc-data browser-plugin-vlc mplayer youtube-dl libdvdcss2 libdvdnav4 libdvdread4 smplayer mencoder
 sleep 5
 updateSystem
 sleep 5
}
#####################################################3 run methods here↓ ###################################################3
##################################################### ###################################################
checkIfUser "$@"
userPass "$@"
setUPiptables
setUPsshd
editSources
updateSystem
checkPrograms
updateSources
########################################################################################################### #####3##
##############################################################################################################3Methods
##########################################3 Disable login www #########
passwd -l www-data
#################################### firmware
apt install -y firmware-linux-nonfree firmware-linux
sleep 5
################ NANO SYNTAX-HIGHLIGHTING #####################3
if [ ! -d "$CURRENTDIR/nanorc" ]
then
 if [ "$UID" != 0 ]
 then
 sudo -u "$ROOT" bash <<'EOF'
 sleep 5
 git clone https://github.com/nanorc/nanorc.git
 sleep 5
 cd nanorc || echo "Couldn't cd nanorc"; exit 127
 make install-global
 sleep 5
 cp -f "$CURRENTDIR/.nanorc" /etc/nanorc
 chown root:root /etc/nanorc
 chmod 644 /etc/nanorc
 if [ "$?" = 0 ]
 then
 echo "Implementing a custom nanorc file succeeded\!"
 else
 echo "Nano setup DID NOT SUCCEED\!"
 fi
EOF
 else
 echo "Doing user: $USER....please, wait\!"
 git clone https://github.com/nanorc/nanorc.git
 sleep 5
 cd nanorc || echo "Couldn't cd nanorc"; exit 127
 sleep 5
 make install-global
 sleep 5
 echo "nanorc" >&3
 cp -f "$CURRENTDIR/$NANORC" /etc/nanorc >&3
 echo $? >&3
 chown root:root /etc/nanorc
 chmod 644 /etc/nanorc
 if [ "$?" = 0 ]
 then
 echo "Implementing a custom nanorc file succeeded\!"
 else
 echo "Nano setup DID NOT SUCCEED\!"
 fi
 fi
fi
echo "Finished setting up nano\!"
################ LS_COLORS SETTINGS #############################
if ! grep 'eval $(dircolors -b $HOME/.dircolors)' /root/.bashrc
then
 if [ "$UID" != 0 ]
 then
 echo "This program should be run as root, exiting! now....."
 exit 1
 # sudo -i -u "$ROOT" CURRENTDIR="$CURRENTDIR" BASHRC="$BASHRCROOT" bash <<'EOF'
 # BASHRCROOT=.bashrcroot
 # cp "$CURRENTDIR/$BASHRCROOT" "$HOME"/.bashrc
 # wget https://raw.github.com/trapd00r/LS_COLORS/master/LS_COLORS -O "$HOME"/.dircolors
 # echo 'eval $(dircolors -b $HOME/.dircolors)' >> "$HOME"/.bashrc
#EOF
 else
 echo "rootBashrc" >&3
 if cp -f "$CURRENTDIR/$BASHRCROOT" "$HOME"/.bashrc >&3
 then
 continue
 else
 echo "Root bashrc cp failed, exiting now!"
 exit 127
 fi
 chown root:root "$HOME/.bashrc"
 chmod 644 "$HOME/.bashrc"
 sleep 5
 wget https://raw.github.com/trapd00r/LS_COLORS/master/LS_COLORS -O "$HOME"/.dircolors
 sleep 5
 echo 'eval $(dircolors -b $HOME/.dircolors)' >> "$HOME"/.bashrc
 fi
fi
for user in "$@"
do
 if [ "$user" = root ]
 then
 continue
 fi
 sudo -i -u "$user" user="$user" CURRENTDIR="$CURRENTDIR" BASHRC="$BASHRC" bash <<'EOF'
 sleep 5
 echo "usersBashrc" >&3
 if cp -f "$CURRENTDIR/$BASHRC" "$HOME/.bashrc" >&3
 then
 continue
 else
 echo "Couldn't cp .bashrc for user $user"
 exit 127
 fi
 chown $user:$user "$HOME/.bashrc"
 chmod 644 "$HOME/.bashrc"
 sleep 5
 wget https://raw.github.com/trapd00r/LS_COLORS/master/LS_COLORS -O "$HOME"/.dircolors
 sleep 5
 echo 'eval $(dircolors -b $HOME/.dircolors)' >> "$HOME"/.bashrc
EOF
done
echo "Finished setting up your system\!"
echo rm -rf /tmp/svaka
#!/bin/bash -x
# redirect all errors to a file
exec 2>debianConfigVersion3.1ERRORS.txt
exec 3>>cpSuccessCodes.txt
SCRIPTNAME=$(basename "0ドル")
if [ "$#" -eq 0 ]
then
 echo "No arguments supplied"
 echo "Usage: $SCRIPTNAME user1name user2name\(optional\) user3name\(optional\)"
 sleep 10
 exit 27
fi
echo "Here starts the party, START"
sleep 2
echo "Setting up server.........."
sleep 2
CURRENTDIR=/tmp/svaka
BASHRC=.bashrc
NANORC=.nanorc
BASHRCROOT=.bashrcroot
ROOT=root
USER_PROGRAMMER=""
SOURCE=sources.list
echo "Please select/provide the port-number for ssh in iptables and sshd_config:"
read -p -r port
PORT=$port
############################### make all files writable, executable and readable in the working directory#########
if chmod 777 "$CURRENTDIR"/*
then
 continue
else
 exit 127
fi
################ Users and access settings #####################1
checkIfUser()
{
 for name in "$@"
 do
 if id -u "$name" #>/dev/null 2>&1
 then
 echo "User: $name exists....setting up now!"
 sleep 5
 else
 echo "User: $name does not exists....creating now!"
 useradd -m -s /bin/bash "$name" #>/dev/null 2>&1
 sleep 5
 fi
 done
}
################33 user passwords2
userPass()
{
 for i in "$@"
 do
 if [ "$i" = root ]
 then
 continue
 fi
 if [[ $(passwd --status "$i" | awk '{print 2ドル}') = NP ]]
 then
 echo "$i doesn't have a password."
 echo "Changing password for $i:"
 echo $i:$i"YOURSTRONGPASSWORDHERE12345Áá" | chpasswd
 if [ "$?" = 0 ]
 then
 echo "Password for user $i changed successfully"
 sleep 5
 fi
 fi
 done
}
################################################ setting up iptables ####################3
setUPiptables()
{
 if ! grep -e '-A INPUT -p tcp --dport 80 -j ACCEPT' /etc/iptables.up.rules
 then
 cat << EOT >> /etc/iptables.test.rules
 *filter
 
 $PORT
 IPTABLES CODE HERE
 COMMIT
EOT
 sleep 5
 /sbin/iptables-restore < /etc/iptables.test.rules || exit 127
 sleep 5
 /sbin/iptables-save > /etc/iptables.up.rules || exit 127
 sleep 3
 printf "#!/bin/bash\n/sbin/iptables-restore < /etc/iptables.up.rules" > /etc/network/if-pre-up.d/iptables
 chmod +x /etc/network/if-pre-up.d/iptables
 sleep 6
 fi
}
###################################################33 sshd_config4
setUPsshd()
{
 cp -f "$CURRENTDIR/sshd_config" /etc/ssh/sshd_config
 sed -i "s/Port 34504/Port $PORT/" /etc/ssh/sshd_config
 chmod 644 /etc/ssh/sshd_config
 /etc/init.d/ssh restart
}
#################################################3333 Remove or comment out DVD/cd line from sources.list5
editSources()
{
 sed -i '/deb cdrom:\[Debian GNU\/Linux/s/^/#/' /etc/apt/sources.list
}
####################################################33 update system6
updateSystem()
{
 apt update && apt upgrade -y
}
###############################################################7
############################# check if programs installed and/or install
checkPrograms()
{
 if [ ! -x /usr/bin/git ] || [ ! -x /usr/bin/wget ] || [ ! -x /usr/bin/curl ] || [ ! -x /usr/bin/gcc ] || [ ! -x /usr/bin/make ]
 then
 echo "Some tools with which to work with data not found installing now......................"
 apt install -y git wget curl gcc make
 fi
}
#####################################################3 update sources.list8
updateSources()
{
 cp -f "$CURRENTDIR/$SOURCE" /etc/apt/sources.list || echo "Failed cp \$CURRENTDIR/\$SOURCE"; exit 127
 chmod 644 /etc/apt/sources.list
 wget http://www.deb-multimedia.org/pool/main/d/deb-multimedia-keyring/deb-multimedia-keyring_2016年8月1日_all.deb
 dpkg -i deb-multimedia-keyring_2016年8月1日_all.deb
 wget -q https://www.virtualbox.org/download/oracle_vbox_2016.asc -O- | sudo apt-key add -
 updateSystem
 apt install -y vlc vlc-data browser-plugin-vlc mplayer youtube-dl libdvdcss2 libdvdnav4 libdvdread4 smplayer mencoder
 sleep 5
 updateSystem
 sleep 5
}
#####################################################3 run methods here↓ ###################################################3
##################################################### ###################################################
checkIfUser "$@"
userPass "$@"
setUPiptables
setUPsshd
editSources
updateSystem
checkPrograms
updateSources
########################################################################################################### #####3##
##############################################################################################################3Methods
##########################################3 Disable login www #########
passwd -l www-data
#################################### firmware
apt install -y firmware-linux-nonfree firmware-linux
sleep 5
################ NANO SYNTAX-HIGHLIGHTING #####################3
if [ ! -d "$CURRENTDIR/nanorc" ]
then
 if [ "$UID" != 0 ]
 then
 sudo -u "$ROOT" bash <<'EOF'
 sleep 5
 git clone https://github.com/nanorc/nanorc.git
 sleep 5
 cd nanorc || echo "Couldn't cd nanorc"; exit 127
 make install-global
 sleep 5
 cp -f "$CURRENTDIR/.nanorc" /etc/nanorc
 chown root:root /etc/nanorc
 chmod 644 /etc/nanorc
 if [ "$?" = 0 ]
 then
 echo "Implementing a custom nanorc file succeeded\!"
 else
 echo "Nano setup DID NOT SUCCEED\!"
 fi
EOF
 else
 echo "Doing user: $USER....please, wait\!"
 git clone https://github.com/nanorc/nanorc.git
 sleep 5
 cd nanorc || echo "Couldn't cd nanorc"; exit 127
 sleep 5
 make install-global
 sleep 5
 echo "nanorc" >&3
 cp -f "$CURRENTDIR/$NANORC" /etc/nanorc >&3
 echo $? >&3
 chown root:root /etc/nanorc
 chmod 644 /etc/nanorc
 if [ "$?" = 0 ]
 then
 echo "Implementing a custom nanorc file succeeded\!"
 else
 echo "Nano setup DID NOT SUCCEED\!"
 fi
 fi
fi
echo "Finished setting up nano\!"
################ LS_COLORS SETTINGS #############################
if ! grep 'eval $(dircolors -b $HOME/.dircolors)' /root/.bashrc
then
 if [ "$UID" != 0 ]
 then
 echo "This program should be run as root, exiting! now....."
 exit 1
 # sudo -i -u "$ROOT" CURRENTDIR="$CURRENTDIR" BASHRC="$BASHRCROOT" bash <<'EOF'
 # BASHRCROOT=.bashrcroot
 # cp "$CURRENTDIR/$BASHRCROOT" "$HOME"/.bashrc
 # wget https://raw.github.com/trapd00r/LS_COLORS/master/LS_COLORS -O "$HOME"/.dircolors
 # echo 'eval $(dircolors -b $HOME/.dircolors)' >> "$HOME"/.bashrc
#EOF
 else
 echo "rootBashrc" >&3
 if cp -f "$CURRENTDIR/$BASHRCROOT" "$HOME"/.bashrc >&3
 then
 continue
 else
 echo "Root bashrc cp failed, exiting now!"
 exit 127
 fi
 chown root:root "$HOME/.bashrc"
 chmod 644 "$HOME/.bashrc"
 sleep 5
 wget https://raw.github.com/trapd00r/LS_COLORS/master/LS_COLORS -O "$HOME"/.dircolors
 sleep 5
 echo 'eval $(dircolors -b $HOME/.dircolors)' >> "$HOME"/.bashrc
 fi
fi
for user in "$@"
do
 if [ "$user" = root ]
 then
 continue
 fi
 sudo -i -u "$user" user="$user" CURRENTDIR="$CURRENTDIR" BASHRC="$BASHRC" bash <<'EOF'
 sleep 5
 echo "usersBashrc" >&3
 if cp -f "$CURRENTDIR/$BASHRC" "$HOME/.bashrc" >&3
 then
 continue
 else
 echo "Couldn't cp .bashrc for user $user"
 exit 127
 fi
 chown $user:$user "$HOME/.bashrc"
 chmod 644 "$HOME/.bashrc"
 sleep 5
 wget https://raw.github.com/trapd00r/LS_COLORS/master/LS_COLORS -O "$HOME"/.dircolors
 sleep 5
 echo 'eval $(dircolors -b $HOME/.dircolors)' >> "$HOME"/.bashrc
EOF
done
echo "Finished setting up your system\!"
echo rm -rf /tmp/svaka
After getting advice in an answer I updated the code
Source Link
Loading
Tweeted twitter.com/StackCodeReview/status/1036992806961770496
Removed off-topic enhancement requests; edited title
Source Link
200_success
  • 145.6k
  • 22
  • 190
  • 479
Loading
added 13 characters in body
Source Link
Loading
added 2 characters in body
Source Link
Loading
Spelling fixes
Source Link
Toby Speight
  • 87.9k
  • 14
  • 104
  • 325
Loading
added information about the program
Source Link
Loading
added 215 characters in body
Source Link
Loading
Source Link
Loading
lang-bash

AltStyle によって変換されたページ (->オリジナル) /