Admin SMB

[サーバーへ接続]ファイル共有ゲストでの接続方法

Screen_486x2312x

smb://guest:guest@192.168.0.1:445/Shared
smb://guest:guest@192.168.0.1/Shared

cifs://guest:guest@192.168.0.1:139/Shared
cifs://guest:guest@192.168.0.1/Shared

XXXXXXXはホスト名
afp://;AUTH=No%20User%20Authent@XXXXXXX._afpovertcp._tcp.local/Shared

afp://;AUTH=No%20User%20Authent@192.168.0.1:548/Shared
afp://;AUTH=No%20User%20Authent@192.168.0.1/Shared

ftp://anonymous:anonymous@adobe.com@ftp.adobe.com
ftps://anonymous:anonymous@adobe.com@ftp.adobe.com

nfs://guest:guest@192.168.0.1/Shared
nfs://guest:guest@192.168.0.1:2049/Shared

|

[HOSTNAME]ホスト名設定(macOS14対応)


【スクリプトエディタで開く】|

#!/bin/bash
#com.cocolog-nifty.quicktimer.icefloe

#################################################
###設定項目
STR_SET_NAME="XXXXXXXXXXXX"

/bin/echo "0-9 a-z A-Z と - ハイフンのみで63文字まで"
/bin/echo "設定するホスト名 : " "$STR_SET_NAME"

#################################################
###管理者インストールしているか?チェック
USER_WHOAMI=$(/usr/bin/whoami)
/bin/echo "実行ユーザー(whoami): $USER_WHOAMI"
if [ "$USER_WHOAMI" != "root" ]; then
  /bin/echo "このスクリプトを実行するには管理者権限が必要です。"
  /bin/echo "sudo で実行してください"
  ### path to me
  SCRIPT_PATH="${BASH_SOURCE[0]}"
  /bin/echo "/usr/bin/sudo \"$SCRIPT_PATH\""
  /bin/echo "↑を実行してください"
  exit 1
else
  ###STAT
  CONSOLE_USER=$(/usr/bin/stat -f%Su /dev/console)
  /bin/echo "STAT_USR(console): $CONSOLE_USER"
fi

#############################################
STR_COMPUTERNAME=$(/usr/sbin/scutil --get ComputerName)
STR_LOCALHOSTNAME=$(/usr/sbin/scutil --get LocalHostName)
STR_HOSTNAME=$(/usr/sbin/scutil --get HostName)

/bin/echo "ComputerName: " "$STR_COMPUTERNAME"
/bin/echo "LocalHostName: " "$STR_LOCALHOSTNAME"
/bin/echo "HostName: " "$STR_HOSTNAME"
#
/usr/bin/sudo /usr/sbin/scutil  --set  ComputerName  "$STR_SET_NAME"
/usr/bin/sudo /usr/sbin/scutil  --set  LocalHostName  "$STR_SET_NAME"
/usr/bin/sudo /usr/sbin/scutil  --set  HostName  "$STR_SET_NAME"
#
STR_COMPUTERNAME=$(/usr/sbin/scutil --get ComputerName)
STR_LOCALHOSTNAME=$(/usr/sbin/scutil --get LocalHostName)
STR_HOSTNAME=$(/usr/sbin/scutil --get HostName)

/bin/echo "ComputerName: " "$STR_COMPUTERNAME"
/bin/echo "LocalHostName: " "$STR_LOCALHOSTNAME"
/bin/echo "HostName: " "$STR_HOSTNAME"

#############################################

STR_COMPUTERNAME=$(/usr/bin/sudo /usr/sbin/systemsetup -getcomputername)
/bin/echo "getcomputername: " "$STR_COMPUTERNAME"
## InternetServices.m Line:379のエラーが出る事がある
/usr/bin/sudo /usr/sbin/systemsetup -setcomputername "$STR_SET_NAME"

STR_COMPUTERNAME=$(/usr/bin/sudo /usr/sbin/systemsetup -getcomputername)
/bin/echo "getcomputername: " "$STR_COMPUTERNAME"

#############################################
/usr/bin/sudo touch "/Library/Preferences/SystemConfiguration/com.apple.smb.server.plist"
STR_NETBIOSNAME=$(/usr/bin/defaults read /Library/Preferences/SystemConfiguration/com.apple.smb.server NetBIOSName)
STR_SERVERDESCRIPTION=$(/usr/bin/defaults read /Library/Preferences/SystemConfiguration/com.apple.smb.server ServerDescription)
STR_DOSCODEPAGE=$(/usr/bin/defaults read /Library/Preferences/SystemConfiguration/com.apple.smb.server DOSCodePage)
/bin/echo "NetBIOSName: " "$STR_NETBIOSNAME"
/bin/echo "ServerDescription: " "$STR_SERVERDESCRIPTION"
/bin/echo "DOSCodePage: " "$STR_DOSCODEPAGE"

/usr/bin/sudo  /bin/launchctl stop -w /System/Library/LaunchDaemons/com.apple.smbd.plist
/bin/echo "STOP SMB"

/usr/bin/sudo /usr/bin/defaults write /Library/Preferences/SystemConfiguration/com.apple.smb.server NetBIOSName   -string "$STR_SET_NAME"
/usr/bin/sudo /usr/bin/defaults write /Library/Preferences/SystemConfiguration/com.apple.smb.server ServerDescription  -string "$STR_SET_NAME"
/usr/bin/sudo /usr/bin/defaults write /Library/Preferences/SystemConfiguration/com.apple.smb.server DOSCodePage  -string "932" 

/usr/bin/sudo /usr/bin/defaults  write /Library/Preferences/SystemConfiguration/com.apple.smb.server.plist EnabledServices -array disk

STR_NETBIOSNAME=$(/usr/bin/defaults read /Library/Preferences/SystemConfiguration/com.apple.smb.server NetBIOSName)
STR_SERVERDESCRIPTION=$(/usr/bin/defaults read /Library/Preferences/SystemConfiguration/com.apple.smb.server ServerDescription)
STR_DOSCODEPAGE=$(/usr/bin/defaults read /Library/Preferences/SystemConfiguration/com.apple.smb.server DOSCodePage)
/bin/echo "NetBIOSName: " "$STR_NETBIOSNAME"
/bin/echo "ServerDescription: " "$STR_SERVERDESCRIPTION"
/bin/echo "DOSCodePage: " "$STR_DOSCODEPAGE"
#############################################
STR_COMPUTERNAME=$(/usr/sbin/networksetup -getcomputername)
/bin/echo "getcomputername: " "$STR_COMPUTERNAME"

/usr/bin/sudo /usr/sbin/networksetup -setcomputername  "$STR_SET_NAME"

STR_COMPUTERNAME=$(/usr/sbin/networksetup -getcomputername)
/bin/echo "getcomputername: " "$STR_COMPUTERNAME"

/usr/bin/dscacheutil -flushcache
/bin/echo "Done systemsetup flushcache"
#############################################


STR_HOST_NAME=$(/usr/bin/uname -n)
/bin/echo "uname : " "$STR_HOST_NAME"
STR_HOST_NAME=$(/bin/hostname -f)
/bin/echo "hostname : " "$STR_HOST_NAME"
STR_HOST_NAME=$(/bin/echo $HOSTNAME)
echo "$HOSTNAME : $STR_HOST_NAME"


exit 0
##共通つける時用
/usr/bin/sudo  /bin/launchctl start -w /System/Library/LaunchDaemons/com.apple.smbd.plist
/bin/echo "START SMB"





|

[SMB] サーバー起動 停止 再起動

#!/usr/bin/env osascript
----+----1----+----2----+-----3----+----4----+----5----+----6----+----7
#
#
#
#
# com.cocolog-nifty.quicktimer.icefloe
----+----1----+----2----+-----3----+----4----+----5----+----6----+----7
##自分環境がos12なので2.8にしているだけです
use AppleScript version "2.8"
use framework "Foundation"
use scripting additions


##################################
##### 現在の smb status
##################################

set boolSMBserverStatus to missing value
####コマンド整形
set strCommandText to "/usr/bin/sudo  /bin/launchctl list | grep com.apple.smbd" as text
try
    ###コマンド実行 管理者権限
    set strResiponse to do shell script strCommandText with administrator privileges
    ###戻り値ある=SMBサーバー起動中
    set boolSMBserverStatus to true as boolean
    log "SMBサーバー起動中"
on error number 1
    log "SMBサーバー未起動"
    ####戻り値エラーになる場合=SMBサーバー未起動
    set boolSMBserverStatus to false as boolean
    set strResiponse to missing value
end try

##################################
##### ダイアログ
##################################
###メッセージ分岐
if boolSMBserverStatus is false then
    set strResponse to "SMBサーバー停止中です\n起動しますか?" as text
else if boolSMBserverStatus is true then
    set strResponse to "SMBサーバー起動中です\n停止しますか?" as text
end if
##ICONパス
set aliasIconPath to POSIX file "/System/Library/CoreServices/CoreTypes.bundle/Contents/Resources/GenericFileServerIcon.icns" as alias
try
    ###ダイアログ
    set recordResponse to (display dialog strResponse with title "選んでください" buttons {"OK", "SMB再起動", "キャンセル"} default button "OK" cancel button "キャンセル" with icon aliasIconPath giving up after 60 without hidden answer)
on error
    log "エラー キャンセルしました"
    return "エラー キャンセルしました"
    error number -128
end try
if true is equal to (gave up of recordResponse) then
    return "時間切れですやりなおしてください"
    error number -128
end if
##########処理分岐
if (button returned of recordResponse) is "OK" then
    
    if boolSMBserverStatus is false then
        set strCommandText to "/usr/bin/sudo  /bin/launchctl load -w /System/Library/LaunchDaemons/com.apple.smbd.plist" as text
        ###コマンド実行 管理者権限
        try
            set strResiponse to do shell script strCommandText with administrator privileges
        on error number 3
            set strCommandText to "/usr/bin/sudo  /bin/launchctl start -w /System/Library/LaunchDaemons/com.apple.smbd.plist" as text
            ###コマンド実行 管理者権限
            set strResiponse to do shell script strCommandText with administrator privileges
        end try
    else if boolSMBserverStatus is true then
        set strCommandText to "/usr/bin/sudo  /bin/launchctl stop  -w /System/Library/LaunchDaemons/com.apple.smbd.plist" as text
        ###コマンド実行 管理者権限
        try
            set strResiponse to do shell script strCommandText with administrator privileges
        on error number 3
            set strCommandText to "/usr/bin/sudo  /bin/launchctl unload -w /System/Library/LaunchDaemons/com.apple.smbd.plist" as text
            ###コマンド実行 管理者権限
            set strResiponse to do shell script strCommandText with administrator privileges
        end try
    end if
    ##########処理分岐
else if (button returned of recordResponse) is "SMB再起動" then
    set strCommandText to "/usr/bin/sudo  /bin/launchctl stop  -w /System/Library/LaunchDaemons/com.apple.smbd.plist" as text
    ###コマンド実行 管理者権限
    try
        set strResiponse to do shell script strCommandText with administrator privileges
    on error number 3
        set strCommandText to "/usr/bin/sudo  /bin/launchctl unload -w /System/Library/LaunchDaemons/com.apple.smbd.plist" as text
        ###コマンド実行 管理者権限
        set strResiponse to do shell script strCommandText with administrator privileges
    end try
    set strCommandText to "/usr/bin/sudo  /bin/launchctl load -w /System/Library/LaunchDaemons/com.apple.smbd.plist" as text
    ###コマンド実行 管理者権限
    try
        set strResiponse to do shell script strCommandText with administrator privileges
    on error number 3
        set strCommandText to "/usr/bin/sudo  /bin/launchctl start -w /System/Library/LaunchDaemons/com.apple.smbd.plist" as text
        ###コマンド実行 管理者権限
        set strResiponse to do shell script strCommandText with administrator privileges
    end try
    
    
end if

|

[SMB]共有ポイント(共有されている箇所)を調べる

#!/usr/bin/env osascript
----+----1----+----2----+-----3----+----4----+----5----+----6----+----7
#
#
#
#
# com.cocolog-nifty.quicktimer.icefloe
----+----1----+----2----+-----3----+----4----+----5----+----6----+----7
##自分環境がos12なので2.8にしているだけです
use AppleScript version "2.8"
use framework "Foundation"
use scripting additions

property refMe : a reference to current application
property refNSString : a reference to refMe's NSString
property refNSData : a reference to refMe's NSData
property refNSURL : a reference to refMe's NSURL
property refNSDictionary : a reference to refMe's NSDictionary
property refNSJSONSerialization : a reference to refMe's NSJSONSerialization



###URL
set strCommandText to "/usr/sbin/sharing  -l -f json" as text
set strJson to do shell script strCommandText

#####################
###戻り値をデータに
##テキスト
set ocidReadDataJson to refNSString's stringWithString:strJson
###UTF8データにして
set ocidReadDataUTF to ocidReadDataJson's dataUsingEncoding:(refMe's NSUTF8StringEncoding)
###データにする
set ocidReadData to (refNSData's alloc()'s initWithData:ocidReadDataUTF)

#####################
###JSON初期化
set listJSONSerialization to (refNSJSONSerialization's JSONObjectWithData:ocidReadData options:0 |error|:(reference))
set ocidJsonData to item 1 of listJSONSerialization
#####レコードに格納
set ocidJsonResponse to (refNSDictionary's alloc()'s initWithDictionary:ocidJsonData)

log ocidJsonResponse as record
log "共有ポイントは" & (count of ocidJsonResponse) & "箇所あります"

|

[SMB]ファイル共有用にフォルダを作成する

ドロップボックス(投げ込み専用)
読み取り専用
読み書き禁止
読み書き可のそれぞれを作成します



#!/usr/bin/env osascript
----+----1----+----2----+-----3----+----4----+----5----+----6----+----7
#
#
#
#
# com.cocolog-nifty.quicktimer.icefloe
----+----1----+----2----+-----3----+----4----+----5----+----6----+----7
##自分環境がos12なので2.8にしているだけです
use AppleScript version "2.8"
use framework "Foundation"
use scripting additions

property refMe : a reference to current application
property refNSString : a reference to refMe's NSString
property refNSURL : a reference to refMe's NSURL
property refNSData : a reference to refMe's NSData

set objFileManager to refMe's NSFileManager's defaultManager()



####パブリックフォルダ 
set ocidUserPublicPath to (objFileManager's URLsForDirectory:(refMe's NSSharedPublicDirectory) inDomains:(refMe's NSUserDomainMask))'s objectAtIndex:0
log ocidUserPublicPath as text
log className() of ocidUserPublicPath as text
set strUserPublicPath to (ocidUserPublicPath's |path|()) as text


######削除禁止にするPublicフォルダが禁止になるだけで中身は対象外
set strCommandText to "/bin/chmod -R +a \"group:everyone allow list,add_file,search,add_subdirectory,delete_child,readattr,writeattr,readextattr,writeextattr,readsecurity,file_inherit,directory_inherit\" \"" & strUserPublicPath & "\""
do shell script strCommandText
######削除禁止にするPublicフォルダが禁止になるだけで中身は対象外
set strCommandText to "/bin/chmod -R +a \"group:_guest allow list,add_file,search,add_subdirectory,delete_child,readattr,writeattr,readextattr,writeextattr,readsecurity,file_inherit,directory_inherit\" \"" & strUserPublicPath & "\""
do shell script strCommandText
######削除禁止にするPublicフォルダが禁止になるだけで中身は対象外
set strCommandText to "/bin/chmod -R +a \"group:_unknown allow list,add_file,search,add_subdirectory,delete_child,readattr,writeattr,readextattr,writeextattr,readsecurity,file_inherit,directory_inherit\" \"" & strUserPublicPath & "\""
do shell script strCommandText
######削除禁止にするPublicフォルダが禁止になるだけで中身は対象外
set strCommandText to "/bin/chmod -R +a \"group:nobody allow list,add_file,search,add_subdirectory,delete_child,readattr,writeattr,readextattr,writeextattr,readsecurity,file_inherit,directory_inherit\" \"" & strUserPublicPath & "\""
do shell script strCommandText

########################################
####パブリックフォルダの中に書類フォルダを作る  -->オーナーだけ読み書き可 他はアクアセス禁止
set ocidMakeDirPathURL to ocidUserPublicPath's URLByAppendingPathComponent:"Documents" isDirectory:true
####日本語表示用のlocalizedファイルのパス
set ocidLocalizedPathURL to ocidMakeDirPathURL's URLByAppendingPathComponent:".localized" isDirectory:false
set ocidLocalizedPath to ocidLocalizedPathURL's |path|() as text
log ocidLocalizedPath as text

###作るフォルダの属性
(*
###主要なモード NSFilePosixPermissions
777-->511
775-->509
770-->504
755-->493
750-->488
700-->448
555-->365
333-->219
#####NSFileGroupOwnerAccountID
ゲストのGID
201-->_guest
99-->_unknown
-2-->nobody
*)
#######フォルダを作る
set boolMakeNewFolder to (objFileManager's createDirectoryAtURL:ocidMakeDirPathURL withIntermediateDirectories:true attributes:({NSFilePosixPermissions:448}) |error|:(missing value))
log boolMakeNewFolder as boolean
#######ファイルを作る
set ocidBlankData to refNSData's alloc()'s init() -->空のデータ
set boolMakeNewFile to objFileManager's createFileAtPath:ocidLocalizedPath |contents|:ocidBlankData attributes:({NSFilePosixPermissions:493})
log boolMakeNewFile as boolean

########################################
####パブリックフォルダの中にGroupsフォルダを作る  -->読み書き可
set ocidMakeDirPathURL to ocidUserPublicPath's URLByAppendingPathComponent:"Groups" isDirectory:true
set ocidMakeDirPath to (ocidMakeDirPathURL's |path|()) as text
####日本語表示用のlocalizedファイルのパス
set ocidLocalizedPathURL to ocidMakeDirPathURL's URLByAppendingPathComponent:".localized" isDirectory:false
set ocidLocalizedPath to (ocidLocalizedPathURL's |path|()) as text
log ocidLocalizedPath as text
#######フォルダを作る
set boolMakeNewFolder to (objFileManager's createDirectoryAtURL:ocidMakeDirPathURL withIntermediateDirectories:true attributes:({NSFilePosixPermissions:511}) |error|:(missing value))
log boolMakeNewFolder as boolean
#######ファイルを作る
set ocidBlankData to refNSData's alloc()'s init()
set boolMakeNewFile to objFileManager's createFileAtPath:ocidLocalizedPath |contents|:ocidBlankData attributes:({NSFilePosixPermissions:493})
log boolMakeNewFile as boolean

######削除禁止にするGroupsフォルダが禁止になるだけで中身は対象外
set strCommandText to "/bin/chmod +a \"group:everyone deny delete\" \"" & ocidMakeDirPath & "\""
do shell script strCommandText
######削除禁止にするGroupsフォルダが禁止になるだけで中身は対象外
set strCommandText to "/bin/chmod -R +a \"group:everyone allow list,add_file,search,add_subdirectory,delete_child,readattr,writeattr,readextattr,writeextattr,readsecurity,file_inherit,directory_inherit\" \"" & ocidMakeDirPath & "\""
do shell script strCommandText




########################################
####パブリックフォルダの中にSharedフォルダを作る -->リードオンリー
set ocidMakeDirPathURL to ocidUserPublicPath's URLByAppendingPathComponent:"Shared" isDirectory:true
####日本語表示用のlocalizedファイルのパス
set ocidLocalizedPathURL to ocidMakeDirPathURL's URLByAppendingPathComponent:".localized" isDirectory:false
set ocidLocalizedPath to ocidLocalizedPathURL's |path|() as text
log ocidLocalizedPath as text
#######フォルダを作る
set boolMakeNewFolder to (objFileManager's createDirectoryAtURL:ocidMakeDirPathURL withIntermediateDirectories:true attributes:({NSFilePosixPermissions:493}) |error|:(missing value))
log boolMakeNewFolder as boolean
#######ファイルを作る
set ocidBlankData to refNSData's alloc()'s init()
set boolMakeNewFile to objFileManager's createFileAtPath:ocidLocalizedPath |contents|:ocidBlankData attributes:({NSFilePosixPermissions:493})
log boolMakeNewFile as boolean


########################################
####パブリックフォルダの中にDrop Boxフォルダを作る
set ocidMakeDirPathURL to ocidUserPublicPath's URLByAppendingPathComponent:"Drop Box" isDirectory:true
####日本語表示用のlocalizedファイルのパス
set ocidLocalizedPathURL to ocidMakeDirPathURL's URLByAppendingPathComponent:".localized" isDirectory:false
set ocidLocalizedPath to ocidLocalizedPathURL's |path|() as text
log ocidLocalizedPath as text
#######フォルダを作る
set boolMakeNewFolder to (objFileManager's createDirectoryAtURL:ocidMakeDirPathURL withIntermediateDirectories:true attributes:({NSFilePosixPermissions:484}) |error|:(missing value))
log boolMakeNewFolder as boolean
#######ファイルを作る
set ocidBlankData to refNSData's alloc()'s init()
set boolMakeNewFile to objFileManager's createFileAtPath:ocidLocalizedPath |contents|:ocidBlankData attributes:({NSFilePosixPermissions:493})
log boolMakeNewFile as boolean


######削除禁止にするDrop Boxフォルダ ファイル投入のみ出来るアクアセス権
set strCommandText to "/bin/chmod +a \"group:everyone deny delete\" \"" & ocidMakeDirPath & "\""
do shell script strCommandText

set strCommandText to "/bin/chmod +a \"user:admin allow list,add_file,search,delete,add_subdirectory,delete_child,readattr,writeattr,readextattr,writeextattr,readsecurity,writesecurity,chown,file_inherit,directory_inherit\" \"" & ocidMakeDirPath & "\""
do shell script strCommandText

|

[SMB]基本設定(サーバー設定)

set strSMBhostName to "HOST-NAME" as text

###SMBホスト名
set strComandText to ("/usr/bin/sudo /usr/bin/defaults write /Library/Preferences/SystemConfiguration/com.apple.smb.server NetBIOSName -string \"" & strSMBhostName & "\"") as text
do shell script strComandText as text with administrator privileges and altering line endings

####説明分
set strComandText to ("/usr/bin/sudo /usr/bin/defaults write /Library/Preferences/SystemConfiguration/com.apple.smb.server ServerDescription -string \"MacOSsmbServer\"") as text
do shell script strComandText as text with administrator privileges and altering line endings

####ゲストアクセス
set strComandText to ("/usr/bin/sudo /usr/bin/defaults write /Library/Preferences/SystemConfiguration/com.apple.smb.server AllowGuestAccess -boolean false") as text
do shell script strComandText as text with administrator privileges and altering line endings

####コードベージ
set strComandText to ("/usr/bin/sudo /usr/bin/defaults write /Library/Preferences/SystemConfiguration/com.apple.smb.server DOSCodePage -string \"850\"") as text
do shell script strComandText as text with administrator privileges and altering line endings

(*
437:IBM PC US
708:Arabic
720:Arabic
737:MS-DOS Greek
775:MS-DOS Baltic Rim
850:MS-DOS Latin 1.
852:MS-DOS Latin 2
855:MS-DOS Cyrillic
857:MS-DOS Turkish
858:Western European with euro sign
860:MS-DOS Portuguese
861:MS-DOS Icelandic
862:MS-DOS Hebrew
863:MS-DOS French Canada
864:Arabic
865:MS-DOS Nordic
866:MS-DOS Cyrillic Russian
869:MS-DOS Greek 2
874:Thai
932:Japanese S-JIS
936:Chinese (simplified)GBK
949:Korean
950:Chinese (Big5 )
951:Chinese (Big5-HKSCS)
*)

|

[SMB]ゲストユーザーに共有フォルダへの接続

allow guest users to connect to shared folders
ゲストユーザーに共有フォルダへの接続を許可


#!/usr/bin/env osascript
----+----1----+----2----+-----3----+----4----+----5----+----6----+----7
#
#
#error number -128
#
# com.cocolog-nifty.quicktimer.icefloe
----+----1----+----2----+-----3----+----4----+----5----+----6----+----7
##自分環境がos12なので2.8にしているだけです
use AppleScript version "2.8"
use framework "Foundation"
use scripting additions

property refMe : a reference to current application
property refNSString : a reference to refMe's NSString
property refNSMutableString : a reference to refMe's NSMutableString
property refNSURL : a reference to refMe's NSURL

(*
共有フォルダへの『ゲスト』アクセス
不可
Disallow guest users to connect to shared folders
/usr/bin/sudo /usr/bin/defaults write /Library/Preferences/SystemConfiguration/com.apple.smb.server AllowGuestAccess -boolean false
allow guest users to connect to shared folders
/usr/bin/sudo /usr/bin/defaults write /Library/Preferences/SystemConfiguration/com.apple.smb.server AllowGuestAccess -boolean true

*)

set strCommandText to "/usr/bin/sudo /usr/bin/defaults write /Library/Preferences/SystemConfiguration/com.apple.smb.server AllowGuestAccess -boolean false"
do shell script strCommandText with prompt "ゲストアクセスの設定を変更します管理者パスワードが必要です" with administrator privileges and altering line endings




display notification "処理終了" with title "処理が終了" subtitle "処理が終了しました" sound name "Sonumi"
log ">>>>>>>>>>>>処理終了<<<<<<<<<<<<<<<"
return ">>>>>>>>>>>>処理終了<<<<<<<<<<<<<<<"

|

[SMB]スタートとストップ

com.apple.smbd
/System/Library/LaunchDaemons/com.apple.smbd.plistを操作します



#!/bin/bash




/usr/bin/sudo  /bin/launchctl stop -w /System/Library/LaunchDaemons/com.apple.smbd.plist


/usr/bin/sudo  /bin/launchctl unload -w /System/Library/LaunchDaemons/com.apple.smbd.plist



/usr/bin/sudo  /bin/launchctl load -w /System/Library/LaunchDaemons/com.apple.smbd.plist


/usr/bin/sudo  /bin/launchctl start -w /System/Library/LaunchDaemons/com.apple.smbd.plist


|

[sharing]ファイル共有用の Share Pointを作成する

この部分です
20220324113855_1280x1042



#!/bin/bash



/usr/sbin/sharing  -l



strLongUserName=`id -F`


#####共有フォルダを作成する

strCommandText="/usr/bin/sudo  /usr/sbin/sharing  -a $HOME/Public -n \"${strLongUserName}のパブリックフォルダ\" -S \"${strLongUserName}のパブリックフォルダ\" -A \"${strLongUserName}のパブリックフォルダ\""

eval $strCommandText


#####共有ステータスを1にする(true

strCommandText="/usr/bin/sudo  /usr/sbin/sharing  -e  \"${strLongUserName}のパブリックフォルダ\" -s 001"

eval $strCommandText


#####ゲストアクセスを1にする(true) 許可

strCommandText="/usr/bin/sudo  /usr/sbin/sharing  -e  \"${strLongUserName}のパブリックフォルダ\" -g 001"

eval $strCommandText


#####リードオンリーを0にする(false=書き込み可能)

strCommandText="/usr/bin/sudo  /usr/sbin/sharing  -e  \"${strLongUserName}のパブリックフォルダ\" -R 000"

eval $strCommandText


#####暗号化する(false=暗号化しない) 暗号化サポートはsmb3から

strCommandText="/usr/bin/sudo  /usr/sbin/sharing  -e  \"${strLongUserName}のパブリックフォルダ\" -E 000"

eval $strCommandText






/usr/sbin/sharing  -l



exit



|

[com.apple.smb.server]DOSCodePage

DOSCodePage

Code PageDefinition
437 Latin (United States)
737Windows 95 Greek
850 Latin 1 (Western European)
852 Latin 2 (Eastern European)
861 Icelandic
866 Cyrillic (Russian)
932 Japanese Shift-JIS
936 Simplified Chinese
949 Korean Hangul
950 Traditional Chinese

/usr/bin/sudo /usr/bin/defaults write /Library/Preferences/SystemConfiguration/com.apple.smb.server DOSCodePage 932 

|

その他のカテゴリー

Accessibility Acrobat Acrobat 2020 Acrobat AddOn Acrobat Annotation Acrobat ARMDC Acrobat AV2 Acrobat BookMark Acrobat Classic Acrobat DC Acrobat Dialog Acrobat Distiller Acrobat Form Acrobat JS Acrobat Manifest Acrobat Menu Acrobat Open Acrobat Plugin Acrobat Preferences Acrobat Preflight Acrobat python Acrobat Reader Acrobat SCA Acrobat SCA Updater Acrobat Sequ Acrobat Sign Acrobat Stamps Acrobat Watermark Acrobat Windows Acrobat Windows Reader Admin Admin Account Admin Apachectl Admin configCode Admin Device Management Admin LaunchServices Admin Locationd Admin loginitem Admin Maintenance Admin Mobileconfig Admin Permission Admin Pkg Admin Power Management Admin Printer Admin SetUp Admin SMB Admin Support Admin System Information Admin Tools Admin Users Admin Volumes Adobe Adobe FDKO Adobe RemoteUpdateManager AppKit Apple AppleScript AppleScript do shell script AppleScript List AppleScript ObjC AppleScript Osax AppleScript PDF AppleScript Pictures AppleScript record AppleScript Script Editor AppleScript Script Menu AppleScript Shortcuts AppleScript Shortcuts Events AppleScript System Events AppleScript System Events Plist AppleScript Video Applications AppStore Archive Attributes Automator BackUp Barcode Barcode QR Barcode QR Decode Bash Basic Basic Path Bluetooth BOX Browser Calendar CD/DVD Choose Chrome CIImage CityCode CloudStorage Color com.apple.LaunchServices.OpenWith Console Contacts CotEditor CURL current application Date&Time delimiters Desktop Device Diff Disk Dock DropBox Droplet eMail Encode % Encode Decode Encode UTF8 Error EXIFData ffmpeg File Finder Firefox Folder FolderAction Fonts GIF github Guide HTML HTML Entity Icon Illustrator Image Events Image2PDF ImageOptim iPhone iWork Javascript Jedit Json Label Leading Zero List locationd LRC lsappinfo LSSharedFileList m3u8 Mail MakePDF Map Math Media Media AVAsset Media AVconvert Media AVFoundation Media AVURLAsset Media Movie Media Music Memo Messages Microsoft Microsoft Edge Microsoft Excel Mouse Music NetWork Notes NSArray NSArray Sort NSBezierPath NSBitmapImageRep NSBundle NSCFBoolean NSCharacterSet NSColor NSColorList NSData NSDecimalNumber NSDictionary NSError NSEvent NSFileAttributes NSFileManager NSFileManager enumeratorAtURL NSFont NSFontManager NSGraphicsContext NSImage NSIndex NSKeyedArchiver NSKeyedUnarchiver NSLocale NSMutableArray NSMutableDictionary NSMutableString NSNotFound NSNumber NSOpenPanel NSPasteboard NSpoint NSPredicate NSPrintOperation NSRange NSRect NSRegularExpression NSRunningApplication NSScreen NSSize NSString NSString stringByApplyingTransform NSStringCompareOptions NSTask NSTimeZone NSURL NSURL File NSURLBookmark NSURLComponents NSURLResourceKey NSURLSession NSUserDefaults NSUUID NSView NSWorkspace Numbers OAuth OneDrive PDF PDFAnnotation PDFAnnotationWidget PDFContext PDFDisplayBox PDFDocumentPermissions PDFImageRep PDFKit PDFnUP PDFOutline perl Photoshop PlistBuddy pluginkit postalcode PostScript prefPane Preview Python QuickLook QuickTime ReadMe Regular Expression Reminders ReName Repeat RTF Safari SaveFile ScreenCapture ScreenSaver SF Symbols character id SF Symbols Entity sips Skype Slack Sound Spotlight sqlite SRT StandardAdditions Swift System Settings TCC TemporaryItems Terminal Text Text CSV Text MD Text TSV TextEdit Tools Translate Trash Twitter Typography UI Unit Conversion UTType valueForKeyPath Video VisionKit Visual Studio Code Wacom webarchive webp Wifi Windows XML XML EPUB XML OPML XML Plist XML RSS XML savedSearch XML SVG XML TTML XML webloc XML XMP YouTube zoom