diff --git a/README.md b/README.md index 45b77c6..b640361 100644 --- a/README.md +++ b/README.md @@ -18,18 +18,6 @@ Run the following command in your terminal and then, enter your amFOSS CMS Crede wget https://raw.githubusercontent.com/amfoss/attendance-tracker/master/install.sh -O install.sh ; bash -e install.sh ``` -## For Mac - -You have add your absolute path in 3 places after running the above command -``` -* config -* install.sh -* attendance.py -``` - -To get Absolute path just -```pwd``` - ## Update Your Credentials This should be done whenever you change your password. diff --git a/attendance/attendance.py b/attendance/attendance.py index 5a21723..e8df892 100755 --- a/attendance/attendance.py +++ b/attendance/attendance.py @@ -13,7 +13,7 @@ if _platform == "linux" or _platform == "linux2": file_path = "/opt/attendance/" elif _platform == "darwin": - file_path = f"{expanduser('~')}/.attendance/" + file_path = f"/Users/{sys.argv[1]}/.attendance/" def get_credentials(): diff --git a/attendance/config b/attendance/config.sh similarity index 77% rename from attendance/config rename to attendance/config.sh index 4664d6b..0270678 100755 --- a/attendance/config +++ b/attendance/config.sh @@ -10,7 +10,7 @@ case "${unameOut}" in esac if [[ "$machine" = "Mac" ]];then - python3 "$HOME"/.attendance/attendance.py >/tmp/stdout.log 2>/tmp/stderr.log + /usr/local/bin/python3 /Users/"$1"/.attendance/attendance.py "$1" >/tmp/stdout.log 2>/tmp/stderr.log else python3 /opt/attendance/attendance.py &> /opt/attendance/attendance.log diff --git a/install.sh b/install.sh index f3e0ddd..36b5430 100755 --- a/install.sh +++ b/install.sh @@ -11,14 +11,23 @@ esac # install pip, git and requests if [[ "$machine" = "Mac" ]]; then - /usr/bin/ruby -e "$(curl -fsSL https://raw.githubusercontent.com/Homebrew/install/master/install)" + if [[ $(command -v brew) == "" ]]; then + /usr/bin/ruby -e "$(curl -fsSL https://raw.githubusercontent.com/Homebrew/install/master/install)" + fi brew install python3 pip3 install requests - readonly attendance_folder_path="$HOME/.attendance" + readonly attendance_folder_path="/Users/$(logname)/.attendance" else - sudo apt install python3-pip git -y - sudo -H pip3 install requests - readonly attendance_folder_path="/opt/attendance" + if [[ $(command -v pacman) == "" ]]; then + # linux install (no arch linux) + sudo apt install python3-pip git -y + sudo -H pip3 install requests + readonly attendance_folder_path="/opt/attendance" + else + # arch linux install, python3 is default python, iwlist is in core/wireless_tools + sudo pacman -S git python-requests wireless_tools + readonly attendance_folder_path="/opt/attendance" + fi fi # clone the repo @@ -35,7 +44,8 @@ sudo cp -r attendance-tracker/attendance/. "$attendance_folder_path"/. sudo chmod +x "$attendance_folder_path"/config "$attendance_folder_path"/get_ssid_names.sh # Add a new cron-job -croncmd="*/1 * * * * ${attendance_folder_path}/config" +username=$(logname) +croncmd="*/1 * * * * ${attendance_folder_path}/config $username" # write out current crontab sudo crontab -l > mycron || touch mycron # echo new cron into cron file if it does not exist, @@ -54,4 +64,4 @@ rm install.sh # fetch creds from user and store them cd "$attendance_folder_path" sudo python3 get_and_save_credentials.py -cd ~ \ No newline at end of file +cd ~