> For the complete documentation index, see [llms.txt](https://docs.liman.dev/tayfa/llms.txt). Markdown versions of documentation pages are available by appending `.md` to page URLs; this page is available as [Markdown](https://docs.liman.dev/tayfa/kaptan-sunucu-kurulumu.md).

# Kaptan Sunucu Kurulumu

## Database Hazırlanması

#### Postgre Kurulumu <a href="#kullan-c4-b1c-c4-b1-olu-c5-9fturma" id="kullan-c4-b1c-c4-b1-olu-c5-9fturma"></a>

```
sudo sh -c 'echo "deb http://apt.postgresql.org/pub/repos/apt $(lsb_release -cs)-pgdg main" > /etc/apt/sources.list.d/pgdg.list'
sudo apt install gnupg2 ca-certificates -y
wget -O- https://www.postgresql.org/media/keys/ACCC4CF8.asc | gpg --dearmor > pgsql.gpg
sudo mv pgsql.gpg /etc/apt/trusted.gpg.d/pgsql.gpg
sudo apt update
apt install postgresql -y
```

#### Kullanıcı Oluşturma <a href="#kullan-c4-b1c-c4-b1-olu-c5-9fturma" id="kullan-c4-b1c-c4-b1-olu-c5-9fturma"></a>

```
sudo -u postgres createuser kaptan
```

Bu örnekte *kaptan* adında bir kullanıcı oluşturmuş olduk.

#### Database Oluşturma <a href="#database-olu-c5-9fturma" id="database-olu-c5-9fturma"></a>

```
sudo -u postgres createdb kaptan
```

Bu örnekte *kaptan* adında bir database oluşturmuş olduk.

#### Kullanıcıya Şifre Verme <a href="#kullan-c4-b1c-c4-b1ya-c5-9fifre-verme" id="kullan-c4-b1c-c4-b1ya-c5-9fifre-verme"></a>

```
sudo -u postgres psql

psql=# alter user <username> with encrypted password '<password>';

```

Komuttaki **username** oluşturduğunuz kullanıcı adıdır. Bizim örneğimizde bu kaptan'dır.\
Komuttaki **password** oluşturduğumuz kullanıcıya atamak istediğiniz şifredir.

Bu örnekte *kaptan* adında kullanıcıya şifre ataması gerçekleştirdik.

## Kaptan Kurulumu

* Öncelikle .deb uzantılı paket şu komut ile indirilir:

```
sudo apt install ./kaptan.deb
```

Paket isimlendirmenize göre *kaptan.deb* değişkenlik gösterebilir.

* Paket indirildikten sonra **/usr/share/kaptan/kaptan.conf** dosyasının içine girilir:

```
sudo nano /usr/share/kaptan/kaptan.conf
```

**kaptan.conf** dosyamıza kendi yapılandırmalarımıza göre aşağıdaki satırları ekleyelim.<br>

```
[kaptan]
hostname-check = n
postgresql-server-ip =  192.168.122.16
ad-server-address = 192.168.122.15
key-path=/usr/share/kaptan/
db-path=/usr/share/kaptan/
log-dir=/usr/share/kaptan/log/
client-log-dir = /usr/share/kaptan/clientlogs/
db-type=postgresql
```

**postgresql-server-ip:** Kaptan için PostgreSQL database'i kullanılacak makinenin IP adresi yazılır.\
**ad-server-address:** AD için kullanacağınız makinenin IP adresi yazılır.

**kaptan.conf** dosyamız şu şekilde gözükecektir:

<figure><img src="https://media.dev.to/cdn-cgi/image/width=800%2Cheight=%2Cfit=scale-down%2Cgravity=auto%2Cformat=auto/https%3A%2F%2Fdev-to-uploads.s3.amazonaws.com%2Fuploads%2Farticles%2Fc8nxx42j5zqw2i6s3bsp.png" alt=""><figcaption></figcaption></figure>

Sonrasında **Kaptan** sunucumuzda şu komut ile PostgreSQL bilgileri eklenir:

```
kaptan -q postgresql_username
```

Bizim örneğimizde *postgresql\_username* = kaptan olarak belirlenmişti. (*kaptan -q kaptan*)

* Bu komut girildikten sonra şifre istenecektir, db oluşturulurken girilien şifre girilir.
* Daha sonra servis yeniden başlatılır

```
systemctl restart kaptan
```

## Lisans İşlemleri

* Şu komut ile makinenin ID'si kontrol edilir ve ardından HAVELSAN A.Ş.'den veya yetkili bir satıcıdan alınan lisans istenir:

```
kaptan -i
```

* **/usr/share/kaptan/licence** dosyasının içine girilir ve lisans eklenip kaydedilir:

```
nano /usr/share/kaptan/licence
```

* Son olarak şu komut ile lisans'ın yolu verilerek lisans eklenir:

```
kaptan -l /usr/share/kaptan/licence
```

* Ayrıca **Kaptan**'ın sağlık durumunu kontrol edebilirsiniz:

{% hint style="warning" %} <mark style="color:orange;">**Kontrol Noktası**</mark>

Servisin çıktısınnda aşağıdaki gibi "**Error codes db init succes"** yazmalı.

```bash
kaptan# systemctl status kaptan
● kaptan.service - kaptan service
Loaded: loaded (/etc/systemd/system/kaptan.service; enabled; vendor
preset: enabled)
Active: active (running) since Thu 2021-07-01 15:45:52 +03; 7s ago
Main PID: 890 (kaptan)
Tasks: 3 (limit: 1135)
Memory: 19.1M
CGroup: /system.slice/kaptan.service
└─890 /usr/bin/kaptan
Jul 01 15:45:54 kaptan kaptan[890]: NOTICE:
column "ipaddress" of relation
"MACHINE" already exists, skipping
Jul 01 15:45:54 kaptan kaptan[890]: NOTICE:
column "tayfaversion" of
relation "MACHINE" already exists, skipping
Jul 01 15:45:54 kaptan kaptan[890]: NOTICE:
column "accesstime" of relation
"MACHINE" already exists, skipping
Jul 01 15:45:54 kaptan kaptan[890]: NOTICE:
column "domainname" of relation
"MACHINE" already exists, skipping
Jul 01 15:45:54 kaptan kaptan[890]: Machine db init success
Jul 01 15:45:54 kaptan kaptan[890]: NOTICE:
column "lastlogin" of relation
"USER" already exists, skipping
Jul 01 15:45:54 kaptan kaptan[890]: Machine db init success
Jul 01 15:45:54 kaptan kaptan[890]: Updating error codes database
Jul 01 15:45:56 kaptan kaptan[890]: Error codes db init succes
```

{% endhint %}

{% hint style="warning" %} <mark style="color:orange;">**Kontrol Noktası**</mark>

Kaptan sağlık durumu kontrol edilmeli

```
sudo kaptan -a
```

Çıktısında aşağıdaki değerlerin hepsinden geçmiş olması gerekmektedir.

> Postgresql connection is ok
>
> Current licence is valid
>
> This server is master
>
> All controls passed successfully
> {% endhint %}


---

# Agent Instructions
This documentation is published with GitBook. GitBook is the documentation platform designed so that both humans and AI agents can read, navigate, and reason over technical content effectively. Learn more at gitbook.com.

## Querying This Documentation
If you need additional information that is not directly available in this page, you can query the documentation dynamically by asking a question.

Perform an HTTP GET request on the current page URL with the `ask` query parameter, and the optional `goal` query parameter:

```
GET https://docs.liman.dev/tayfa/kaptan-sunucu-kurulumu.md?ask=<question>&goal=<endgoal>
```

`ask` is the immediate question: it should be specific, self-contained, and written in natural language.
`goal` is optional and describes the broader end goal you are ultimately trying to accomplish on behalf of the user. GitBook uses it to tailor the answer towards what is most useful for that goal.

The response will contain a direct answer to the question and relevant excerpts and sources from the documentation.

Use this mechanism when the answer is not explicitly present in the current page, you need clarification or additional context, or you want to retrieve related documentation sections.
