Skip to content

Commit

Permalink
Add files via upload
Browse files Browse the repository at this point in the history
  • Loading branch information
AmirrezaFiroozi committed May 9, 2016
1 parent 1873822 commit 88051b5
Show file tree
Hide file tree
Showing 2 changed files with 96 additions and 0 deletions.
17 changes: 17 additions & 0 deletions installer.sh
@@ -0,0 +1,17 @@
#!/bin/bash
#author : Amirreza Firooz
#installer of wttr
clear
echo -e "******************************\nWelcome to installer of wttr \n *************************** \n Installing ..."
sudo cp -R "wttr" /usr/bin
st_0=$?
cd /usr/bin
echo -e "******************************\n Giving permission ..."
sudo chmod +x wttr
st_1=$?
if [ $st_0 == 0 ] && [ $st_1 == 0 ];then
echo -e "\n********* Congratulations!!! installation has just completed *********\n"
wttr -h
else
echo -e "\n There were some problems while installing :(\n Installation failed :( "
fi
79 changes: 79 additions & 0 deletions wttr
@@ -0,0 +1,79 @@
#!/bin/bash
#Author : Amirreza Firoozi
#name : wttr

wttr_ver="1.2" #define script version
if [ -f "$HOME/.wttr/default.txt" ];then #check if user set default city or not . if user did load it to variable def
cd $HOME/.wttr
def=$(cat default.txt)

elif [ ! -d $HOME/.wttr ];then #if he/she didn`t make a blank file
mkdir ".wttr"
echo "" > default.txt
def=""
fi
if [ "$#" == "0" ] && [ "$def" == "" ];then
echo -e "You have not entered any parameters \n Needs help? try wttr -h"
elif [ "$#" -gt "2" ];then

echo -e "too many parameters. \n Needs help? try wttr -h"
else
case $1 in
"-h") #showing help
echo -e "\n This is a simple app to check weather condition.\n wttr is under GPL3 License. source is available on Github : https://Github.com/AmirrezaFiroozi/wttr \n Created by : Amirreza Firoozi \n Thanks to : Jadi & Alireza Amirsamimi & Mostafa Asadi \n Write wttr {your city name} to check the weather condition of your city. example : wttr fasa \n -m for photo of moon \n -h for some help (this page) \n -v for script version \n -i to install curl which is necessary for script to run correctly\n -rm to remove the script :( \n -sdef to define a city as your default city \n Any bugs? Any suggestions? Contact us : firoozi128.af&gmail.com "
;;
"-v")
echo -e " wttr_VERSION is : "$wttr_ver" "
;;
"-m")
curl http://wttr.in/moon
;;
"-i")
sudo apt install curl
;;
"-rm")
read -p "Do you Really want to remove wttr?(y/n)" response
if [ "$response" == "y" ];then
cd /usr/bin
sudo rm -R "wttr"
if [ -d "$HOME/.wttr" ];then
sudo rm -d "$HOME/.wttr"
fi
echo -e "Script has deleted :("
else
echo -e "Opration canceled"
fi
;;
"-sdef") # set the default city
if [ ! -d $HOME/.wttr ];then
cd $HOME
mkdir ".wttr"
fi
if [ "$#" == "2" ];then
cd $HOME/.wttr
echo "$2" > default.txt
else
read -p " Enter your city name to set as the default city (example : fasa) : " def
if [ "$def" == "" ] && [ "$#" -ls "2" ];then
echo "you did NOT enter anything ..."
else
cd $HOME/.wttr
echo $def > default.txt
fi
fi #end of the second if
echo -e "\n Congratulations!! we set $def as your default city. You can check its weather condition by typing only wttr Since now :)"
;;
"")
cd $HOME
curl http://wttr.in/"$def"
;;
*)

curl http://wttr.in/"$1"

;;
esac
fi



0 comments on commit 88051b5

Please sign in to comment.