« [exiftool] exiftoolのhtmlDumpの内容をHTMLで保存する(画像系専用) | トップページ | [bash]gifskiインストール »

[bash]libwebpインストール


#!/bin/bash
#com.cocolog-nifty.quicktimer.icefloe
#ユーザー ~/binにインストールする

########################################
###管理者インストールしているか?チェック
USER_WHOAMI=$(/usr/bin/whoami)
/bin/echo "実行ユーザーは:$USER_WHOAMI"
###実行しているユーザー名
CONSOLE_USER=$(/bin/echo "show State:/Users/ConsoleUser" | /usr/sbin/scutil | /usr/bin/awk '/Name :/ { print $3 }')
/bin/echo "コンソールユーザー:$CONSOLE_USER"
###ログイン名ユーザー名※Visual Studio Codeの出力パネルではrootになる設定がある
LOGIN_NAME=$(/usr/bin/logname)
/bin/echo "ログイン名:$LOGIN_NAME"
###UID
USER_NAME=$(/usr/bin/id -un)
/bin/echo "ユーザー名:$USER_NAME"
###SUDOUSER
/bin/echo "SUDO_USER: $SUDO_USER"
########################################
##OS
PLIST_PATH="/System/Library/CoreServices/SystemVersion.plist"
STR_OS_VER=$(/usr/bin/defaults read "$PLIST_PATH" ProductVersion)
/bin/echo "OS VERSION :" "$STR_OS_VER"
STR_MAJOR_VERSION="${STR_OS_VER%%.*}"
/bin/echo "STR_MAJOR_VERSION :" "$STR_MAJOR_VERSION"
STR_MINOR_VERSION="${STR_OS_VER#*.}"
/bin/echo "STR_MINOR_VERSION :" "$STR_MINOR_VERSION"
########################################
###ダウンロード起動時に削除する項目
USER_TEMP_DIR=$(/usr/bin/mktemp -d)
/bin/echo "起動時に削除されるディレクトリ:" "$USER_TEMP_DIR"
########################################
##デバイス
#起動ディスクの名前を取得する
/bin/mkdir -p "/Users/$CONSOLE_USER/Documents/Apple/IOPlatformUUID"
/usr/bin/touch "/Users/$CONSOLE_USER/Documents/Apple/IOPlatformUUID/diskutil.plist"
/usr/sbin/chown -R "$CONSOLE_USER" "/Users/$CONSOLE_USER/Documents/Apple/IOPlatformUUID"
/bin/chmod -Rf 700 "/Users/$CONSOLE_USER/Documents/Apple"
/usr/sbin/diskutil info -plist / >"/Users/$CONSOLE_USER/Documents/Apple/IOPlatformUUID/diskutil.plist"
STARTUPDISK_NAME=$(/usr/bin/defaults read "/Users/$CONSOLE_USER/Documents/Apple/IOPlatformUUID/diskutil.plist" VolumeName)
/bin/echo "ボリューム名:" "$STARTUPDISK_NAME"
############################################################
############################################################
###ユーザーbinディレクトリを作っておく
/bin/mkdir -p "/Users/$CONSOLE_USER/bin/"
for ((numTimes = 1; numTimes <= 3; numTimes++)); do
sleep 1
/bin/mkdir -p "/Users/$CONSOLE_USER/bin/"
/usr/bin/touch "/Users/$CONSOLE_USER/bin/"
/usr/sbin/chown "$CONSOLE_USER" "/Users/$CONSOLE_USER/bin/"
/bin/chmod 700 "/Users/$CONSOLE_USER/bin/"
done
# binは不可視にする
/usr/bin/chflags hidden "/Users/$CONSOLE_USER/bin"
/usr/bin/SetFile -a V "/Users/$CONSOLE_USER/bin"
###########################
###ダウンロードURL
STR_URL="https://storage.googleapis.com/downloads.webmproject.org/releases/webp/libwebp-1.3.2-mac-arm64.tar.gz"
###ファイル名を取得
DL_FILE_NAME=$(/usr/bin/curl -s -L -I -o /dev/null -w '%{url_effective}' "$STR_URL" | /usr/bin/rev | /usr/bin/cut -d'/' -f1 | /usr/bin/rev)
/bin/echo "DL_FILE_NAME:$DL_FILE_NAME"
###ダウンロード
if ! /usr/bin/curl -L -o "$USER_TEMP_DIR/$DL_FILE_NAME" "$STR_URL" --connect-timeout 20; then
/bin/echo "ファイルのダウンロードに失敗しました HTTP1.1で再トライします"
  if ! /usr/bin/curl -L -o "$USER_TEMP_DIR/$DL_FILE_NAME" "$STR_URL" --http1.1 --connect-timeout 20; then
/bin/echo "ファイルのダウンロードに失敗しました"
exit 1
  fi
fi
##全ユーザー実行可能にしておく
/bin/chmod 755 "$USER_TEMP_DIR/$DL_FILE_NAME"
/bin/echo "ダウンロードOK"

############################################################
#########
/bin/echo "インストール開始:" "$CONSOLE_USER"
#コピー先を作っておく
/bin/mkdir -p "/Users/$CONSOLE_USER/bin/libwebp"
/usr/bin/touch "/Users/$CONSOLE_USER/bin/libwebp"
/usr/sbin/chown "$CONSOLE_USER" "/Users/$CONSOLE_USER/bin/libwebp"
/bin/chmod 700 "/Users/$CONSOLE_USER/bin/libwebp"
#解凍
/usr/bin/bsdtar -xzf "$USER_TEMP_DIR/$DL_FILE_NAME" -C "$USER_TEMP_DIR"
sleep 1
STR_DIRNAME=$(/usr/bin/basename -s .tar.gz "$USER_TEMP_DIR/$DL_FILE_NAME")
#コピー
/usr/bin/ditto "$USER_TEMP_DIR/$STR_DIRNAME" "/Users/$CONSOLE_USER/bin/libwebp"
#ディレクトリを開く
open "/Users/$CONSOLE_USER/bin/libwebp"
exit 0


|

« [exiftool] exiftoolのhtmlDumpの内容をHTMLで保存する(画像系専用) | トップページ | [bash]gifskiインストール »

webp」カテゴリの記事