Skip to content

Commit

Permalink
PID Parsing Bugfix/Updater added to lockAccounts
Browse files Browse the repository at this point in the history
  • Loading branch information
joshumax committed Dec 3, 2013
1 parent 265d956 commit 74e48cc
Show file tree
Hide file tree
Showing 3 changed files with 33 additions and 4 deletions.
4 changes: 2 additions & 2 deletions UsefulScriptUpdater/usu.sh
Original file line number Diff line number Diff line change
Expand Up @@ -65,12 +65,12 @@ usu_do_update() {
# Use md5sum to see if the script needs an update
elif [ "$compstr1" != "$compstr2" ]; then

echo "INFO: Update found... Type 'y' to apply it!"
echo "[USU Mode] INFO: Update found... Type 'y' to apply it!"
read -n 1 input # Check and see if the user wants to continue

if [ $input = "y" ]; then # All hail the nested if statements

echo -e "\nUPDATING..."
echo -e "\n[USU Mode] UPDATING..."
# Run a simple sanity check to see if the file downloaded correctly

if [ $(head -n 1 $temp_save_file) != "#!/bin/bash" ]; then
Expand Down
31 changes: 30 additions & 1 deletion lockAccounts/lockAccounts.sh
Original file line number Diff line number Diff line change
@@ -1,5 +1,8 @@
#!/bin/bash

# lockAccounts
# Copyright (C) 2013 Seth Johnson and Josh Max
#
# This program 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
Expand All @@ -14,6 +17,29 @@
# along with this program; if not, write to the Free Software
# Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA.

run_updater() {

#Download and run the USU updater script
if ! [ -w "/tmp/" ]; then

echo "ERROR: /tmp/ is not writable! Cannot continue."
return -1
fi

# Hard-coded program updater URL
echo "Downloading updater..."
updater_url="https://raw.github.com/CP-Team-06-0003/Useful-Scripts/master/UsefulScriptUpdater/usu.sh"
temp_usu_save_file="/tmp/usu_updater_$RANDOM.sh"
curl -# $updater_url > $temp_usu_save_file
chmod 755 $temp_usu_save_file

# Start USU
# Aguments: Remote Script Dir, Remote Script Filename, Local Script Filename, Arguments/(Git commit)
bash -c "$temp_usu_save_file lockAccounts lockAccounts.sh $(readlink -f $0) $2"
exit

}

show_usage() {

echo "Uses passwd -l to lock all the user accounts passed as arguments"
Expand All @@ -39,7 +65,10 @@ init() {
elif [ "$1" = "--help" ]; then

show_usage
else
elif [ "$1" = "--update" ]; then

run_updater "$1" "$2" # Check for script updates (Advanced options) force an update to a certain revision
else

run $@
fi
Expand Down
2 changes: 1 addition & 1 deletion pid2cmd/pid2cmd.sh
Original file line number Diff line number Diff line change
Expand Up @@ -53,7 +53,7 @@ run_updater() {
get_cmd() {

# Make sure the argument is an integer
if ! [ ! -z "${1###[!0-9]#}" ]; then
if ! [ "$1" -eq "$1" ] 2>/dev/null; then

echo -e "Error, argument is not a valid PID!\n"
show_usage;
Expand Down

0 comments on commit 74e48cc

Please sign in to comment.