/****** Scripting replication configuration. Script Date: 07-02-2021 01:54:03 ******/
/****** Please Note: For security reasons, all password parameters were scripted with either NULL or an empty string. ******/

/****** Installing the server as a Distributor. Script Date: 07-02-2021 01:54:03 ******/
use master
exec sp_adddistributor @distributor = N'servername', @password = N'passphrase'
GO
exec sp_adddistributiondb @database = N'distribution', @data_folder = N'/var/opt/mssql/data', @log_folder = N'/var/opt/mssql/log', @log_file_size = 2, @min_distretention = 0, @max_distretention = 72, @history_retention = 48, @deletebatchsize_xact = 5000, @deletebatchsize_cmd = 2000, @security_mode = 1
GO

use [distribution] 
if (not exists (select * from sysobjects where name = 'UIProperties' and type = 'U '))
	create table UIProperties(id int)
if (exists (select * from ::fn_listextendedproperty('SnapshotFolder', 'user', 'dbo', 'table', 'UIProperties', null, null)))
	EXEC sp_updateextendedproperty N'SnapshotFolder', N'/var/opt/mssql/data/ReplData', 'user', dbo, 'table', 'UIProperties'
else
	EXEC sp_addextendedproperty N'SnapshotFolder', N'/var/opt/mssql/data/ReplData', 'user', dbo, 'table', 'UIProperties'
GO

exec sp_adddistpublisher @publisher = N'servername', @distribution_db = N'distribution', @security_mode = 0, @login = N'sa', @password = N'', @working_directory = N'/var/opt/mssql/data/ReplData', @trusted = N'false', @thirdparty_flag = 0, @publisher_type = N'MSSQLSERVER'
GO