logging added to script
This commit is contained in:
parent
4dc3d041e1
commit
4cd9d452c6
|
@ -1,19 +1,35 @@
|
||||||
#!/usr/bin/env bash
|
#!/usr/bin/env bash
|
||||||
|
|
||||||
function main(){
|
function main(){
|
||||||
|
mkdir -p $HOME/.photoshopCCV19
|
||||||
|
mkdir -p $HOME/.cache/photoshopCCV19
|
||||||
|
setup_log "================| script executed |================"
|
||||||
check_arg $1
|
check_arg $1
|
||||||
is64
|
is64
|
||||||
package_installed aria2c
|
package_installed aria2c
|
||||||
package_installed wine
|
package_installed wine
|
||||||
|
|
||||||
|
|
||||||
|
}
|
||||||
|
|
||||||
|
function setup_log(){
|
||||||
|
echo -e "$(date) : $@" >> $HOME/.photoshopCCV19/setuplog.log
|
||||||
|
}
|
||||||
|
|
||||||
|
function show_message(){
|
||||||
|
echo -e "$@"
|
||||||
|
setup_log "$@"
|
||||||
}
|
}
|
||||||
|
|
||||||
function error(){
|
function error(){
|
||||||
echo -e "\033[1;31merror:\e[0m $@"
|
echo -e "\033[1;31merror:\e[0m $@"
|
||||||
|
setup_log "$@"
|
||||||
exit 1
|
exit 1
|
||||||
}
|
}
|
||||||
|
|
||||||
function warning(){
|
function warning(){
|
||||||
echo -e "\033[1;33mWarning:\e[0m $@"
|
echo -e "\033[1;33mWarning:\e[0m $@"
|
||||||
|
setup_log "$@"
|
||||||
}
|
}
|
||||||
|
|
||||||
function check_arg(){
|
function check_arg(){
|
||||||
|
@ -21,7 +37,7 @@ function check_arg(){
|
||||||
then
|
then
|
||||||
error "It haven't any parameter just execute script"
|
error "It haven't any parameter just execute script"
|
||||||
fi
|
fi
|
||||||
echo "argument checked..."
|
show_message "argument checked..."
|
||||||
}
|
}
|
||||||
|
|
||||||
function is64(){
|
function is64(){
|
||||||
|
@ -30,17 +46,17 @@ function is64(){
|
||||||
warning "your distro is not 64 bit"
|
warning "your distro is not 64 bit"
|
||||||
read -r -p "Would you continue? [N/y] " response
|
read -r -p "Would you continue? [N/y] " response
|
||||||
if [[ ! "$response" =~ ^([yY][eE][sS]|[yY])$ ]];then
|
if [[ ! "$response" =~ ^([yY][eE][sS]|[yY])$ ]];then
|
||||||
echo "Good By!"
|
echo "Good Bye!"
|
||||||
exit 0
|
exit 0
|
||||||
fi
|
fi
|
||||||
fi
|
fi
|
||||||
echo "is64 checked..."
|
show_message "is64 checked..."
|
||||||
}
|
}
|
||||||
|
|
||||||
function package_installed(){
|
function package_installed(){
|
||||||
local which=$(which $1 2>/dev/null)
|
local which=$(which $1 2>/dev/null)
|
||||||
if [ "$which" == "/usr/bin/$1" ];then
|
if [ "$which" == "/usr/bin/$1" ];then
|
||||||
echo -e "package\033[1;36m $1\e[0m is installed..."
|
show_message "package\033[1;36m $1\e[0m is installed..."
|
||||||
else
|
else
|
||||||
error "package\033[1;33m $1\e[0m is not installed.\nplease install it and Try again"
|
error "package\033[1;33m $1\e[0m is not installed.\nplease install it and Try again"
|
||||||
fi
|
fi
|
||||||
|
|
Loading…
Reference in New Issue