mirror of
https://github.com/restic/restic.git
synced 2025-03-16 00:00:05 +01:00
Fix SMB test setup for Mac
This commit is contained in:
parent
c9dba2cdd7
commit
2882872736
4 changed files with 50 additions and 8 deletions
48
.github/workflows/tests.yml
vendored
48
.github/workflows/tests.yml
vendored
|
@ -21,30 +21,34 @@ jobs:
|
|||
- job_name: Windows
|
||||
go: 1.19.x
|
||||
os: windows-latest
|
||||
test_smb: true
|
||||
|
||||
- job_name: macOS
|
||||
go: 1.19.x
|
||||
os: macOS-latest
|
||||
test_fuse: false
|
||||
test_smb: false
|
||||
test_smb: true
|
||||
|
||||
- job_name: Linux
|
||||
go: 1.19.x
|
||||
os: ubuntu-latest
|
||||
test_cloud_backends: true
|
||||
test_fuse: true
|
||||
test_smb: true
|
||||
check_changelog: true
|
||||
|
||||
- job_name: Linux (race)
|
||||
go: 1.19.x
|
||||
os: ubuntu-latest
|
||||
test_fuse: true
|
||||
test_smb: true
|
||||
test_opts: "-race"
|
||||
|
||||
- job_name: Linux
|
||||
go: 1.18.x
|
||||
os: ubuntu-latest
|
||||
test_fuse: true
|
||||
test_smb: true
|
||||
|
||||
name: ${{ matrix.job_name }} Go ${{ matrix.go }}
|
||||
runs-on: ${{ matrix.os }}
|
||||
|
@ -83,11 +87,45 @@ jobs:
|
|||
chmod 755 $HOME/bin/rclone
|
||||
rm -rf rclone*
|
||||
|
||||
echo "install samba"
|
||||
user="smbuser"
|
||||
pass="mGoWwqvgdnwtmh07"
|
||||
smbuser="smbuser"
|
||||
smbpass="mGoWwqvgdnwtmh07"
|
||||
|
||||
if [ "$RUNNER_OS" != "macOS" ]; then
|
||||
if [ "$RUNNER_OS" == "macOS" ]; then
|
||||
smbhome=/Users/$smbuser
|
||||
echo "Get computer name"
|
||||
computername=$(sudo -S scutil --get ComputerName)
|
||||
echo "Create smb user"
|
||||
sudo dscl . -create $smbhome
|
||||
sudo dscl . -create $smbhome UserShell /bin/bash
|
||||
sudo dscl . -create $smbhome RealName $smbuser
|
||||
LastID=`dscl . -list /Users UniqueID | awk '{print $2}' | sort -n | tail -1`
|
||||
NextID=$((LastID + 1))
|
||||
sudo dscl . -create $smbhome UniqueID $NextID
|
||||
sudo dscl . -create $smbhome PrimaryGroupID 80
|
||||
sudo dscl . -create $smbhome NFSHomeDirectory $smbhome
|
||||
sudo dscl . -passwd $smbhome $smbpass
|
||||
sudo dscl . -append /Groups/admin GroupMembership $smbuser
|
||||
echo "Make home dir"
|
||||
cd /Users/
|
||||
sudo createhomedir -u $smbuser -c
|
||||
sudo mkdir $smbhome/smbshare
|
||||
sudo chown -R $smbuser $smbhome
|
||||
sudo chmod -R 755 $smbhome
|
||||
echo "Setup smb share"
|
||||
sudo sharing -a $smbhome/smbshare -S smbuser -n smbuser -s 001
|
||||
echo "Enable share for os user"
|
||||
sudo pwpolicy -u $smbuser -sethashtypes SMB-NT off
|
||||
sudo pwpolicy -u $smbuser -enableuser
|
||||
echo "Export domain"
|
||||
if [[ $computername != *.local ]]; then computername=$computername".local"; fi
|
||||
export RESTIC_SMB_DOMAIN=$computername
|
||||
sudo pwpolicy -u $smbuser -sethashtypes SMB-NT on
|
||||
sudo dscl . -passwd /Users/$smbuser $smbpass
|
||||
sudo launchctl load -w /System/Library/LaunchDaemons/com.apple.smbd.plist
|
||||
sudo defaults write /Library/Preferences/SystemConfiguration/com.apple.smb.server.plist EnabledServices -array disk
|
||||
|
||||
else
|
||||
echo "install samba"
|
||||
sudo apt-get update
|
||||
sudo apt-get install samba -y
|
||||
|
||||
|
|
|
@ -11,7 +11,7 @@ import (
|
|||
"github.com/restic/restic/internal/debug"
|
||||
)
|
||||
|
||||
// Parts of this code have been copied from Rclone (https://github.com/rclone)
|
||||
// Parts of this code have been adapted from Rclone (https://github.com/rclone)
|
||||
// Copyright (C) 2012 by Nick Craig-Wood http://www.craig-wood.com/nick/
|
||||
|
||||
// Permission is hereby granted, free of charge, to any person obtaining a copy
|
||||
|
|
|
@ -23,7 +23,7 @@ import (
|
|||
"github.com/restic/restic/internal/restic"
|
||||
)
|
||||
|
||||
// Parts of this code have been copied from Rclone (https://github.com/rclone)
|
||||
// Parts of this code have been adapted from Rclone (https://github.com/rclone)
|
||||
// Copyright (C) 2012 by Nick Craig-Wood http://www.craig-wood.com/nick/
|
||||
|
||||
// Permission is hereby granted, free of charge, to any person obtaining a copy
|
||||
|
|
|
@ -2,6 +2,7 @@ package smb_test
|
|||
|
||||
import (
|
||||
"context"
|
||||
"os"
|
||||
"testing"
|
||||
|
||||
"github.com/google/uuid"
|
||||
|
@ -26,7 +27,10 @@ func newTestSuite(t testing.TB) *test.Suite {
|
|||
cfg.Connections = smb.DefaultConnections
|
||||
timeout := smb.DefaultIdleTimeout
|
||||
cfg.IdleTimeout = timeout
|
||||
cfg.Domain = smb.DefaultDomain
|
||||
domain := os.Getenv("RESTIC_SMB_DOMAIN")
|
||||
if domain == "" {
|
||||
cfg.Domain = smb.DefaultDomain
|
||||
}
|
||||
|
||||
t.Logf("create new backend at %v", cfg.Host+"/"+cfg.ShareName)
|
||||
|
||||
|
|
Loading…
Add table
Reference in a new issue