https://wiki.alpinelinux.org/w/api.php?action=feedcontributions&user=Zoot&feedformat=atom
Alpine Linux - User contributions [en]
2024-03-28T09:15:21Z
User contributions
MediaWiki 1.40.0
https://wiki.alpinelinux.org/w/index.php?title=UniFi_Controller&diff=14228
UniFi Controller
2017-12-11T22:14:47Z
<p>Zoot: /* Introduction */ added var/log/unifi</p>
<hr />
<div>= Introduction =<br />
<br />
This guide explains how to install the generic Unix UniFi Controller, as available from [http://www.ubnt.com/ Ubiquity Networks]. At the time of writing this, a native Alpine Linux package is not available.<br />
<br />
Furthermore, this guide uses the incredibly reliable and efficient [http://www.skarnet.org/software/s6/ s6] supervision suite to start and control the UniFi Controller.<br />
<br />
A summarised schematic of what will be installed on the filesystem.<br />
<br />
The choice of <code>/srv</code> for the UniFi Controller's root directory is based on the fact that it contains both run-time and configuration data, so installing to <code>/usr/local</code>, <code>/opt</code> or <code>/home</code> didn't seem apt. Feel free to adjust the steps below, replacing <code>/srv/unifi</code> with wherever you would prefer to install the UniFi Controller software.<br />
<br />
<pre><br />
/<br />
`--etc<br />
|-- unifi<br />
| `-- log<br />
|-- srv<br />
| `-- unifi<br />
| |-- bin<br />
| |-- conf<br />
| |-- data<br />
| |-- dl<br />
| |-- lib<br />
| |-- logs<br />
| |-- run<br />
| `-- webapps<br />
|-- run<br />
| `-- openrc<br />
| `-- s6-scan<br />
| `-- unifi --> /etc/unifi<br />
`-- var<br />
`-- log<br />
`-- unifi<br />
</pre><br />
<br />
= Prerequisite Packages =<br />
<br />
== OpenJDK 8 JRE ==<br />
<br />
Install <code>openjdk8-jre</code> from the community repository.<br />
<br />
Edit <code>/etc/apk/respositories</code> and uncomment the appropriate community repository for your Alpine version:<br />
<br />
<code>http://host.name/alpine_version/community</code><br />
<br />
Update the package cache.<br />
<br />
<code>apk update</code><br />
<br />
Install the package.<br />
<br />
<code>apk add openjdk8-jre</code><br />
<br />
== MongoDB ==<br />
<br />
Install MongoDB<br />
<br />
<code>apk add mongodb</code><br />
<br />
== s6 ==<br />
<br />
Install [http://www.skarnet.org/software/s6/ s6]<br />
<br />
<code>apk add s6</code> which is a service supervision suite, for reliably and efficiently starting, stopping and keeping services running.<br />
<br />
The below shows a schematic process tree of how the UniFi Controller will be started and supervised by s6. The controller is written in Java, hence the Java process and it in turn, launches a dedicated instance of MongoDB to store its configuration and run-time data.<br />
<br />
<pre><br />
init<br />
`-- s6-svscan<br />
`-- s6-supervise<br />
|-- s6-log<br />
`-- java<br />
`-- mongod<br />
</pre><br />
<br />
= Install UniFi Controller =<br />
<br />
Create the <code>unifi</code> user and group.<br />
<br />
<code>adduser -D -H /srv/unifi unifi</code><br />
<br />
Change to the parent folder within which you wish to install the UniFi Controller.<br />
<br />
<code>cd /srv</code><br />
<br />
Download the generic unix archive of the <code>VERSION</code> you wish to install.<br />
<br />
<code>wget http://www.ubnt.com/downloads/unifi/VERSION/UniFi.unix.zip</code><br />
<br />
Unpack the archive.<br />
<br />
<code>unzip UniFi.unix.zip</code><br />
<br />
Rename the unpacked directory.<br />
<br />
<code>mv UniFi unifi</code><br />
<br />
Change ownership.<br />
<br />
<code>chown unifi:unifi unifi</code><br />
<br />
Lock down permissions.<br />
<br />
<code>chmod o-rwx unifi</code><br />
<br />
Change into the UniFi bin directory.<br />
<br />
<code>cd /srv/unifi/bin</code><br />
<br />
Remove the existing file.<br />
<br />
<code>rm mongod</code><br />
<br />
Create a symlink to <code>/usr/bin/mongod</code><br />
<br />
<code>ln -s /usr/bin/mongod</code><br />
<br />
= Configure Service Management =<br />
<br />
== Create UniFi Service Directory and Files ==<br />
<br />
Create an s6 service directory for UniFi.<br />
<br />
<code>mkdir -p /etc/unifi/log</code><br />
<br />
Add the <code>run</code> script, using your favourite editor.<br />
<br />
<code>vim /etc/unifi/run</code><br />
<br />
Copy and paste the following into it.<br />
<br />
<pre><br />
#!/bin/ash<br />
<br />
user='unifi'<br />
group='unifi'<br />
<br />
exec 2>&1<br />
<br />
base='/srv/unifi'<br />
<br />
if [ -d $base ]; then<br />
cd $base<br />
chown -R $user:$group .<br />
version=`head -1 webapps/ROOT/app-unifi/.version`<br />
echo "Starting UniFi Controller $version"<br />
exec s6-setuidgid $user java -jar lib/ace.jar start<br />
else<br />
echo "Missing $base ... aborting"<br />
touch down<br />
fi<br />
</pre><br />
<br />
Ensure that the <code>run</code> script is executable:<br />
<br />
<code>chmod 755 /etc/unifi/run</code><br />
<br />
Add the <code>log/run</code> script, using your favourite editor.<br />
<br />
<code>vim /etc/unifi/log/run</code><br />
<br />
Copy and paste the following into it.<br />
<br />
<pre><br />
#!/bin/ash<br />
<br />
log_user='log'<br />
<br />
exec s6-setuidgid $log_user s6-log -b n20 s1000000 t /var/log/unifi<br />
</pre><br />
<br />
Ensure that the log/run script is executable:<br />
<br />
<code>chmod 755 /etc/unifi/run</code><br />
<br />
== Create log User and Directory ==<br />
<br />
Create the <code>log</code> user and group.<br />
<br />
<code>adduser -D -H /var/log log</code><br />
<br />
Create the <code>/var/log/unifi</code> directory<br />
<br />
<code>mkdir -p /var/log/unifi</code><br />
<br />
Update the directory ownership.<br />
<br />
<code>chown log:log /var/log/unifi</code><br />
<br />
Lock down the permissions.<br />
<br />
<code>chmod 750 /var/log/unifi</code><br />
<br />
== Create the OpenRC Service Script ==<br />
<br />
Open the script file using your favourite editor.<br />
<br />
<code>vim /etc/init.d/unifi</code><br />
<br />
Paste the following into it.<br />
<br />
<pre><br />
#!/sbin/openrc-run<br />
<br />
name="unifi"<br />
supervisor=s6<br />
s6_service_path="${RC_SVCDIR}/s6-scan/${name}"<br />
<br />
depend() {<br />
need net s6-svscan<br />
after firewall<br />
}<br />
<br />
start_pre() {<br />
if [ ! -L "${RC_SVCDIR}/s6-scan/${name}" ]; then<br />
ln -s "/etc/${name}" "${RC_SVCDIR}/s6-scan/${name}"<br />
fi<br />
}<br />
</pre><br />
<br />
Ensure that the script is executable.<br />
<br />
<code>chmod 755 /etc/init.d/unifi</code><br />
<br />
== Start the UniFi Controller Service ==<br />
<br />
<code>rc-service unifi start</code><br />
<br />
== Configure the UniFi Controller Service to start on boot ==<br />
<br />
<code>rc-update add unifi boot</code><br />
<br />
= Simple Backup Script =<br />
<br />
Create <code>/usr/local/bin/unifi-backup</code> using your favourite editor.<br />
<br />
'''Note:''' This script assumes the use of s6-svc to control unifi. I will modify it in time, to use rc-service instead.<br />
<br />
Paste the following into the file.<br />
<br />
<pre><br />
#!/bin/ash<br />
<br />
conf_dir='/etc/unifi'<br />
backup_dir='/srv/backup/unifi'<br />
service_dir='/run/openrc/s6-scan/unifi'<br />
<br />
start_state='down'<br />
<br />
if s6-svok $service_dir; then<br />
if s6-svstat -o up,ready $service_dir | grep -q true; then<br />
echo 'Stopping the UniFi Controller'<br />
start_state='up'<br />
s6-svc -d $service_dir<br />
sleep 3<br />
fi<br />
else<br />
echo 'Warning: The UniFi Controller is not supervised'<br />
exit 1<br />
fi<br />
<br />
if s6-svstat -o up $service_dir | grep -q false; then<br />
echo 'Success: The UniFi Controller was stopped'<br />
else<br />
echo 'Error: The UniFi Controller is still running'<br />
exit 1<br />
fi<br />
<br />
stamp=`date +%Y-%m-%d_%H%M%S`<br />
<br />
mkdir -p $backup_dir<br />
cd $backup_dir<br />
mkdir "data-$stamp"<br />
<br />
echo "Backing up to /srv/backup/unifi/data-$stamp.tar.gz"<br />
<br />
if rsync -az /srv/unifi/data/ "data-$stamp"; then<br />
echo '* rsync succeeded'<br />
if tar czf "data-$stamp.tar.gz" "data-$stamp"; then<br />
echo '* tar succeeded'<br />
rm -rf "data-$stamp"<br />
echo 'Backup succeeded'<br />
else<br />
echo 'Backup failed: tar failed'<br />
exit 1<br />
fi<br />
fi<br />
<br />
if [ "$start_state" == 'up' ]; then<br />
echo 'Starting the UniFi Controller'<br />
s6-svc -u $service_dir<br />
sleep 5<br />
s6-svstat $service_dir<br />
fi<br />
</pre></div>
Zoot
https://wiki.alpinelinux.org/w/index.php?title=UniFi_Controller&diff=14227
UniFi Controller
2017-12-11T09:40:38Z
<p>Zoot: /* Simple Backup Script */ - note regarding use of s6-svc instead of rc-service</p>
<hr />
<div>= Introduction =<br />
<br />
This guide explains how to install the generic Unix UniFi Controller, as available from [http://www.ubnt.com/ Ubiquity Networks]. At the time of writing this, a native Alpine Linux package is not available.<br />
<br />
Furthermore, this guide uses the incredibly reliable and efficient [http://www.skarnet.org/software/s6/ s6] supervision suite to start and control the UniFi Controller.<br />
<br />
A summarised schematic of what will be installed on the filesystem.<br />
<br />
The choice of <code>/srv</code> for the UniFi Controller's root directory is based on the fact that it contains both run-time and configuration data, so installing to <code>/usr/local</code>, <code>/opt</code> or <code>/home</code> didn't seem apt. Feel free to adjust the steps below, replacing <code>/srv/unifi</code> with wherever you would prefer to install the UniFi Controller software.<br />
<br />
<pre><br />
/<br />
`--etc<br />
|-- unifi<br />
| `-- log<br />
|-- srv<br />
| `-- unifi<br />
| |-- bin<br />
| |-- conf<br />
| |-- data<br />
| |-- dl<br />
| |-- lib<br />
| |-- logs<br />
| |-- run<br />
| `-- webapps<br />
`-- run<br />
`-- openrc<br />
`-- s6-scan<br />
`-- unifi --> /etc/unifi<br />
</pre><br />
<br />
= Prerequisite Packages =<br />
<br />
== OpenJDK 8 JRE ==<br />
<br />
Install <code>openjdk8-jre</code> from the community repository.<br />
<br />
Edit <code>/etc/apk/respositories</code> and uncomment the appropriate community repository for your Alpine version:<br />
<br />
<code>http://host.name/alpine_version/community</code><br />
<br />
Update the package cache.<br />
<br />
<code>apk update</code><br />
<br />
Install the package.<br />
<br />
<code>apk add openjdk8-jre</code><br />
<br />
== MongoDB ==<br />
<br />
Install MongoDB<br />
<br />
<code>apk add mongodb</code><br />
<br />
== s6 ==<br />
<br />
Install [http://www.skarnet.org/software/s6/ s6]<br />
<br />
<code>apk add s6</code> which is a service supervision suite, for reliably and efficiently starting, stopping and keeping services running.<br />
<br />
The below shows a schematic process tree of how the UniFi Controller will be started and supervised by s6. The controller is written in Java, hence the Java process and it in turn, launches a dedicated instance of MongoDB to store its configuration and run-time data.<br />
<br />
<pre><br />
init<br />
`-- s6-svscan<br />
`-- s6-supervise<br />
|-- s6-log<br />
`-- java<br />
`-- mongod<br />
</pre><br />
<br />
= Install UniFi Controller =<br />
<br />
Create the <code>unifi</code> user and group.<br />
<br />
<code>adduser -D -H /srv/unifi unifi</code><br />
<br />
Change to the parent folder within which you wish to install the UniFi Controller.<br />
<br />
<code>cd /srv</code><br />
<br />
Download the generic unix archive of the <code>VERSION</code> you wish to install.<br />
<br />
<code>wget http://www.ubnt.com/downloads/unifi/VERSION/UniFi.unix.zip</code><br />
<br />
Unpack the archive.<br />
<br />
<code>unzip UniFi.unix.zip</code><br />
<br />
Rename the unpacked directory.<br />
<br />
<code>mv UniFi unifi</code><br />
<br />
Change ownership.<br />
<br />
<code>chown unifi:unifi unifi</code><br />
<br />
Lock down permissions.<br />
<br />
<code>chmod o-rwx unifi</code><br />
<br />
Change into the UniFi bin directory.<br />
<br />
<code>cd /srv/unifi/bin</code><br />
<br />
Remove the existing file.<br />
<br />
<code>rm mongod</code><br />
<br />
Create a symlink to <code>/usr/bin/mongod</code><br />
<br />
<code>ln -s /usr/bin/mongod</code><br />
<br />
= Configure Service Management =<br />
<br />
== Create UniFi Service Directory and Files ==<br />
<br />
Create an s6 service directory for UniFi.<br />
<br />
<code>mkdir -p /etc/unifi/log</code><br />
<br />
Add the <code>run</code> script, using your favourite editor.<br />
<br />
<code>vim /etc/unifi/run</code><br />
<br />
Copy and paste the following into it.<br />
<br />
<pre><br />
#!/bin/ash<br />
<br />
user='unifi'<br />
group='unifi'<br />
<br />
exec 2>&1<br />
<br />
base='/srv/unifi'<br />
<br />
if [ -d $base ]; then<br />
cd $base<br />
chown -R $user:$group .<br />
version=`head -1 webapps/ROOT/app-unifi/.version`<br />
echo "Starting UniFi Controller $version"<br />
exec s6-setuidgid $user java -jar lib/ace.jar start<br />
else<br />
echo "Missing $base ... aborting"<br />
touch down<br />
fi<br />
</pre><br />
<br />
Ensure that the <code>run</code> script is executable:<br />
<br />
<code>chmod 755 /etc/unifi/run</code><br />
<br />
Add the <code>log/run</code> script, using your favourite editor.<br />
<br />
<code>vim /etc/unifi/log/run</code><br />
<br />
Copy and paste the following into it.<br />
<br />
<pre><br />
#!/bin/ash<br />
<br />
log_user='log'<br />
<br />
exec s6-setuidgid $log_user s6-log -b n20 s1000000 t /var/log/unifi<br />
</pre><br />
<br />
Ensure that the log/run script is executable:<br />
<br />
<code>chmod 755 /etc/unifi/run</code><br />
<br />
== Create log User and Directory ==<br />
<br />
Create the <code>log</code> user and group.<br />
<br />
<code>adduser -D -H /var/log log</code><br />
<br />
Create the <code>/var/log/unifi</code> directory<br />
<br />
<code>mkdir -p /var/log/unifi</code><br />
<br />
Update the directory ownership.<br />
<br />
<code>chown log:log /var/log/unifi</code><br />
<br />
Lock down the permissions.<br />
<br />
<code>chmod 750 /var/log/unifi</code><br />
<br />
== Create the OpenRC Service Script ==<br />
<br />
Open the script file using your favourite editor.<br />
<br />
<code>vim /etc/init.d/unifi</code><br />
<br />
Paste the following into it.<br />
<br />
<pre><br />
#!/sbin/openrc-run<br />
<br />
name="unifi"<br />
supervisor=s6<br />
s6_service_path="${RC_SVCDIR}/s6-scan/${name}"<br />
<br />
depend() {<br />
need net s6-svscan<br />
after firewall<br />
}<br />
<br />
start_pre() {<br />
if [ ! -L "${RC_SVCDIR}/s6-scan/${name}" ]; then<br />
ln -s "/etc/${name}" "${RC_SVCDIR}/s6-scan/${name}"<br />
fi<br />
}<br />
</pre><br />
<br />
Ensure that the script is executable.<br />
<br />
<code>chmod 755 /etc/init.d/unifi</code><br />
<br />
== Start the UniFi Controller Service ==<br />
<br />
<code>rc-service unifi start</code><br />
<br />
== Configure the UniFi Controller Service to start on boot ==<br />
<br />
<code>rc-update add unifi boot</code><br />
<br />
= Simple Backup Script =<br />
<br />
Create <code>/usr/local/bin/unifi-backup</code> using your favourite editor.<br />
<br />
'''Note:''' This script assumes the use of s6-svc to control unifi. I will modify it in time, to use rc-service instead.<br />
<br />
Paste the following into the file.<br />
<br />
<pre><br />
#!/bin/ash<br />
<br />
conf_dir='/etc/unifi'<br />
backup_dir='/srv/backup/unifi'<br />
service_dir='/run/openrc/s6-scan/unifi'<br />
<br />
start_state='down'<br />
<br />
if s6-svok $service_dir; then<br />
if s6-svstat -o up,ready $service_dir | grep -q true; then<br />
echo 'Stopping the UniFi Controller'<br />
start_state='up'<br />
s6-svc -d $service_dir<br />
sleep 3<br />
fi<br />
else<br />
echo 'Warning: The UniFi Controller is not supervised'<br />
exit 1<br />
fi<br />
<br />
if s6-svstat -o up $service_dir | grep -q false; then<br />
echo 'Success: The UniFi Controller was stopped'<br />
else<br />
echo 'Error: The UniFi Controller is still running'<br />
exit 1<br />
fi<br />
<br />
stamp=`date +%Y-%m-%d_%H%M%S`<br />
<br />
mkdir -p $backup_dir<br />
cd $backup_dir<br />
mkdir "data-$stamp"<br />
<br />
echo "Backing up to /srv/backup/unifi/data-$stamp.tar.gz"<br />
<br />
if rsync -az /srv/unifi/data/ "data-$stamp"; then<br />
echo '* rsync succeeded'<br />
if tar czf "data-$stamp.tar.gz" "data-$stamp"; then<br />
echo '* tar succeeded'<br />
rm -rf "data-$stamp"<br />
echo 'Backup succeeded'<br />
else<br />
echo 'Backup failed: tar failed'<br />
exit 1<br />
fi<br />
fi<br />
<br />
if [ "$start_state" == 'up' ]; then<br />
echo 'Starting the UniFi Controller'<br />
s6-svc -u $service_dir<br />
sleep 5<br />
s6-svstat $service_dir<br />
fi<br />
</pre></div>
Zoot
https://wiki.alpinelinux.org/w/index.php?title=UniFi_Controller&diff=14226
UniFi Controller
2017-12-11T08:20:44Z
<p>Zoot: /* Create log User and Directory */ - corrected adduser arguments</p>
<hr />
<div>= Introduction =<br />
<br />
This guide explains how to install the generic Unix UniFi Controller, as available from [http://www.ubnt.com/ Ubiquity Networks]. At the time of writing this, a native Alpine Linux package is not available.<br />
<br />
Furthermore, this guide uses the incredibly reliable and efficient [http://www.skarnet.org/software/s6/ s6] supervision suite to start and control the UniFi Controller.<br />
<br />
A summarised schematic of what will be installed on the filesystem.<br />
<br />
The choice of <code>/srv</code> for the UniFi Controller's root directory is based on the fact that it contains both run-time and configuration data, so installing to <code>/usr/local</code>, <code>/opt</code> or <code>/home</code> didn't seem apt. Feel free to adjust the steps below, replacing <code>/srv/unifi</code> with wherever you would prefer to install the UniFi Controller software.<br />
<br />
<pre><br />
/<br />
`--etc<br />
|-- unifi<br />
| `-- log<br />
|-- srv<br />
| `-- unifi<br />
| |-- bin<br />
| |-- conf<br />
| |-- data<br />
| |-- dl<br />
| |-- lib<br />
| |-- logs<br />
| |-- run<br />
| `-- webapps<br />
`-- run<br />
`-- openrc<br />
`-- s6-scan<br />
`-- unifi --> /etc/unifi<br />
</pre><br />
<br />
= Prerequisite Packages =<br />
<br />
== OpenJDK 8 JRE ==<br />
<br />
Install <code>openjdk8-jre</code> from the community repository.<br />
<br />
Edit <code>/etc/apk/respositories</code> and uncomment the appropriate community repository for your Alpine version:<br />
<br />
<code>http://host.name/alpine_version/community</code><br />
<br />
Update the package cache.<br />
<br />
<code>apk update</code><br />
<br />
Install the package.<br />
<br />
<code>apk add openjdk8-jre</code><br />
<br />
== MongoDB ==<br />
<br />
Install MongoDB<br />
<br />
<code>apk add mongodb</code><br />
<br />
== s6 ==<br />
<br />
Install [http://www.skarnet.org/software/s6/ s6]<br />
<br />
<code>apk add s6</code> which is a service supervision suite, for reliably and efficiently starting, stopping and keeping services running.<br />
<br />
The below shows a schematic process tree of how the UniFi Controller will be started and supervised by s6. The controller is written in Java, hence the Java process and it in turn, launches a dedicated instance of MongoDB to store its configuration and run-time data.<br />
<br />
<pre><br />
init<br />
`-- s6-svscan<br />
`-- s6-supervise<br />
|-- s6-log<br />
`-- java<br />
`-- mongod<br />
</pre><br />
<br />
= Install UniFi Controller =<br />
<br />
Create the <code>unifi</code> user and group.<br />
<br />
<code>adduser -D -H /srv/unifi unifi</code><br />
<br />
Change to the parent folder within which you wish to install the UniFi Controller.<br />
<br />
<code>cd /srv</code><br />
<br />
Download the generic unix archive of the <code>VERSION</code> you wish to install.<br />
<br />
<code>wget http://www.ubnt.com/downloads/unifi/VERSION/UniFi.unix.zip</code><br />
<br />
Unpack the archive.<br />
<br />
<code>unzip UniFi.unix.zip</code><br />
<br />
Rename the unpacked directory.<br />
<br />
<code>mv UniFi unifi</code><br />
<br />
Change ownership.<br />
<br />
<code>chown unifi:unifi unifi</code><br />
<br />
Lock down permissions.<br />
<br />
<code>chmod o-rwx unifi</code><br />
<br />
Change into the UniFi bin directory.<br />
<br />
<code>cd /srv/unifi/bin</code><br />
<br />
Remove the existing file.<br />
<br />
<code>rm mongod</code><br />
<br />
Create a symlink to <code>/usr/bin/mongod</code><br />
<br />
<code>ln -s /usr/bin/mongod</code><br />
<br />
= Configure Service Management =<br />
<br />
== Create UniFi Service Directory and Files ==<br />
<br />
Create an s6 service directory for UniFi.<br />
<br />
<code>mkdir -p /etc/unifi/log</code><br />
<br />
Add the <code>run</code> script, using your favourite editor.<br />
<br />
<code>vim /etc/unifi/run</code><br />
<br />
Copy and paste the following into it.<br />
<br />
<pre><br />
#!/bin/ash<br />
<br />
user='unifi'<br />
group='unifi'<br />
<br />
exec 2>&1<br />
<br />
base='/srv/unifi'<br />
<br />
if [ -d $base ]; then<br />
cd $base<br />
chown -R $user:$group .<br />
version=`head -1 webapps/ROOT/app-unifi/.version`<br />
echo "Starting UniFi Controller $version"<br />
exec s6-setuidgid $user java -jar lib/ace.jar start<br />
else<br />
echo "Missing $base ... aborting"<br />
touch down<br />
fi<br />
</pre><br />
<br />
Ensure that the <code>run</code> script is executable:<br />
<br />
<code>chmod 755 /etc/unifi/run</code><br />
<br />
Add the <code>log/run</code> script, using your favourite editor.<br />
<br />
<code>vim /etc/unifi/log/run</code><br />
<br />
Copy and paste the following into it.<br />
<br />
<pre><br />
#!/bin/ash<br />
<br />
log_user='log'<br />
<br />
exec s6-setuidgid $log_user s6-log -b n20 s1000000 t /var/log/unifi<br />
</pre><br />
<br />
Ensure that the log/run script is executable:<br />
<br />
<code>chmod 755 /etc/unifi/run</code><br />
<br />
== Create log User and Directory ==<br />
<br />
Create the <code>log</code> user and group.<br />
<br />
<code>adduser -D -H /var/log log</code><br />
<br />
Create the <code>/var/log/unifi</code> directory<br />
<br />
<code>mkdir -p /var/log/unifi</code><br />
<br />
Update the directory ownership.<br />
<br />
<code>chown log:log /var/log/unifi</code><br />
<br />
Lock down the permissions.<br />
<br />
<code>chmod 750 /var/log/unifi</code><br />
<br />
== Create the OpenRC Service Script ==<br />
<br />
Open the script file using your favourite editor.<br />
<br />
<code>vim /etc/init.d/unifi</code><br />
<br />
Paste the following into it.<br />
<br />
<pre><br />
#!/sbin/openrc-run<br />
<br />
name="unifi"<br />
supervisor=s6<br />
s6_service_path="${RC_SVCDIR}/s6-scan/${name}"<br />
<br />
depend() {<br />
need net s6-svscan<br />
after firewall<br />
}<br />
<br />
start_pre() {<br />
if [ ! -L "${RC_SVCDIR}/s6-scan/${name}" ]; then<br />
ln -s "/etc/${name}" "${RC_SVCDIR}/s6-scan/${name}"<br />
fi<br />
}<br />
</pre><br />
<br />
Ensure that the script is executable.<br />
<br />
<code>chmod 755 /etc/init.d/unifi</code><br />
<br />
== Start the UniFi Controller Service ==<br />
<br />
<code>rc-service unifi start</code><br />
<br />
== Configure the UniFi Controller Service to start on boot ==<br />
<br />
<code>rc-update add unifi boot</code><br />
<br />
= Simple Backup Script =<br />
<br />
Create <code>/usr/local/bin/unifi-backup</code> using your favourite editor.<br />
<br />
Paste the following into the file.<br />
<br />
<pre><br />
#!/bin/ash<br />
<br />
conf_dir='/etc/unifi'<br />
backup_dir='/srv/backup/unifi'<br />
service_dir='/run/openrc/s6-scan/unifi'<br />
<br />
start_state='down'<br />
<br />
if s6-svok $service_dir; then<br />
if s6-svstat -o up,ready $service_dir | grep -q true; then<br />
echo 'Stopping the UniFi Controller'<br />
start_state='up'<br />
s6-svc -d $service_dir<br />
sleep 3<br />
fi<br />
else<br />
echo 'Warning: The UniFi Controller is not supervised'<br />
exit 1<br />
fi<br />
<br />
if s6-svstat -o up $service_dir | grep -q false; then<br />
echo 'Success: The UniFi Controller was stopped'<br />
else<br />
echo 'Error: The UniFi Controller is still running'<br />
exit 1<br />
fi<br />
<br />
stamp=`date +%Y-%m-%d_%H%M%S`<br />
<br />
mkdir -p $backup_dir<br />
cd $backup_dir<br />
mkdir "data-$stamp"<br />
<br />
echo "Backing up to /srv/backup/unifi/data-$stamp.tar.gz"<br />
<br />
if rsync -az /srv/unifi/data/ "data-$stamp"; then<br />
echo '* rsync succeeded'<br />
if tar czf "data-$stamp.tar.gz" "data-$stamp"; then<br />
echo '* tar succeeded'<br />
rm -rf "data-$stamp"<br />
echo 'Backup succeeded'<br />
else<br />
echo 'Backup failed: tar failed'<br />
exit 1<br />
fi<br />
fi<br />
<br />
if [ "$start_state" == 'up' ]; then<br />
echo 'Starting the UniFi Controller'<br />
s6-svc -u $service_dir<br />
sleep 5<br />
s6-svstat $service_dir<br />
fi<br />
</pre></div>
Zoot
https://wiki.alpinelinux.org/w/index.php?title=UniFi_Controller&diff=14225
UniFi Controller
2017-12-11T08:18:51Z
<p>Zoot: /* Introduction */ - corrected a spelling error</p>
<hr />
<div>= Introduction =<br />
<br />
This guide explains how to install the generic Unix UniFi Controller, as available from [http://www.ubnt.com/ Ubiquity Networks]. At the time of writing this, a native Alpine Linux package is not available.<br />
<br />
Furthermore, this guide uses the incredibly reliable and efficient [http://www.skarnet.org/software/s6/ s6] supervision suite to start and control the UniFi Controller.<br />
<br />
A summarised schematic of what will be installed on the filesystem.<br />
<br />
The choice of <code>/srv</code> for the UniFi Controller's root directory is based on the fact that it contains both run-time and configuration data, so installing to <code>/usr/local</code>, <code>/opt</code> or <code>/home</code> didn't seem apt. Feel free to adjust the steps below, replacing <code>/srv/unifi</code> with wherever you would prefer to install the UniFi Controller software.<br />
<br />
<pre><br />
/<br />
`--etc<br />
|-- unifi<br />
| `-- log<br />
|-- srv<br />
| `-- unifi<br />
| |-- bin<br />
| |-- conf<br />
| |-- data<br />
| |-- dl<br />
| |-- lib<br />
| |-- logs<br />
| |-- run<br />
| `-- webapps<br />
`-- run<br />
`-- openrc<br />
`-- s6-scan<br />
`-- unifi --> /etc/unifi<br />
</pre><br />
<br />
= Prerequisite Packages =<br />
<br />
== OpenJDK 8 JRE ==<br />
<br />
Install <code>openjdk8-jre</code> from the community repository.<br />
<br />
Edit <code>/etc/apk/respositories</code> and uncomment the appropriate community repository for your Alpine version:<br />
<br />
<code>http://host.name/alpine_version/community</code><br />
<br />
Update the package cache.<br />
<br />
<code>apk update</code><br />
<br />
Install the package.<br />
<br />
<code>apk add openjdk8-jre</code><br />
<br />
== MongoDB ==<br />
<br />
Install MongoDB<br />
<br />
<code>apk add mongodb</code><br />
<br />
== s6 ==<br />
<br />
Install [http://www.skarnet.org/software/s6/ s6]<br />
<br />
<code>apk add s6</code> which is a service supervision suite, for reliably and efficiently starting, stopping and keeping services running.<br />
<br />
The below shows a schematic process tree of how the UniFi Controller will be started and supervised by s6. The controller is written in Java, hence the Java process and it in turn, launches a dedicated instance of MongoDB to store its configuration and run-time data.<br />
<br />
<pre><br />
init<br />
`-- s6-svscan<br />
`-- s6-supervise<br />
|-- s6-log<br />
`-- java<br />
`-- mongod<br />
</pre><br />
<br />
= Install UniFi Controller =<br />
<br />
Create the <code>unifi</code> user and group.<br />
<br />
<code>adduser -D -H /srv/unifi unifi</code><br />
<br />
Change to the parent folder within which you wish to install the UniFi Controller.<br />
<br />
<code>cd /srv</code><br />
<br />
Download the generic unix archive of the <code>VERSION</code> you wish to install.<br />
<br />
<code>wget http://www.ubnt.com/downloads/unifi/VERSION/UniFi.unix.zip</code><br />
<br />
Unpack the archive.<br />
<br />
<code>unzip UniFi.unix.zip</code><br />
<br />
Rename the unpacked directory.<br />
<br />
<code>mv UniFi unifi</code><br />
<br />
Change ownership.<br />
<br />
<code>chown unifi:unifi unifi</code><br />
<br />
Lock down permissions.<br />
<br />
<code>chmod o-rwx unifi</code><br />
<br />
Change into the UniFi bin directory.<br />
<br />
<code>cd /srv/unifi/bin</code><br />
<br />
Remove the existing file.<br />
<br />
<code>rm mongod</code><br />
<br />
Create a symlink to <code>/usr/bin/mongod</code><br />
<br />
<code>ln -s /usr/bin/mongod</code><br />
<br />
= Configure Service Management =<br />
<br />
== Create UniFi Service Directory and Files ==<br />
<br />
Create an s6 service directory for UniFi.<br />
<br />
<code>mkdir -p /etc/unifi/log</code><br />
<br />
Add the <code>run</code> script, using your favourite editor.<br />
<br />
<code>vim /etc/unifi/run</code><br />
<br />
Copy and paste the following into it.<br />
<br />
<pre><br />
#!/bin/ash<br />
<br />
user='unifi'<br />
group='unifi'<br />
<br />
exec 2>&1<br />
<br />
base='/srv/unifi'<br />
<br />
if [ -d $base ]; then<br />
cd $base<br />
chown -R $user:$group .<br />
version=`head -1 webapps/ROOT/app-unifi/.version`<br />
echo "Starting UniFi Controller $version"<br />
exec s6-setuidgid $user java -jar lib/ace.jar start<br />
else<br />
echo "Missing $base ... aborting"<br />
touch down<br />
fi<br />
</pre><br />
<br />
Ensure that the <code>run</code> script is executable:<br />
<br />
<code>chmod 755 /etc/unifi/run</code><br />
<br />
Add the <code>log/run</code> script, using your favourite editor.<br />
<br />
<code>vim /etc/unifi/log/run</code><br />
<br />
Copy and paste the following into it.<br />
<br />
<pre><br />
#!/bin/ash<br />
<br />
log_user='log'<br />
<br />
exec s6-setuidgid $log_user s6-log -b n20 s1000000 t /var/log/unifi<br />
</pre><br />
<br />
Ensure that the log/run script is executable:<br />
<br />
<code>chmod 755 /etc/unifi/run</code><br />
<br />
== Create log User and Directory ==<br />
<br />
Create the <code>log</code> user and group.<br />
<br />
<code>adduser -D -H /var/log -g log log</code><br />
<br />
Create the <code>/var/log/unifi</code> directory<br />
<br />
<code>mkdir -p /var/log/unifi</code><br />
<br />
Update the directory ownership.<br />
<br />
<code>chown log:log /var/log/unifi</code><br />
<br />
Lock down the permissions.<br />
<br />
<code>chmod 750 /var/log/unifi</code><br />
<br />
== Create the OpenRC Service Script ==<br />
<br />
Open the script file using your favourite editor.<br />
<br />
<code>vim /etc/init.d/unifi</code><br />
<br />
Paste the following into it.<br />
<br />
<pre><br />
#!/sbin/openrc-run<br />
<br />
name="unifi"<br />
supervisor=s6<br />
s6_service_path="${RC_SVCDIR}/s6-scan/${name}"<br />
<br />
depend() {<br />
need net s6-svscan<br />
after firewall<br />
}<br />
<br />
start_pre() {<br />
if [ ! -L "${RC_SVCDIR}/s6-scan/${name}" ]; then<br />
ln -s "/etc/${name}" "${RC_SVCDIR}/s6-scan/${name}"<br />
fi<br />
}<br />
</pre><br />
<br />
Ensure that the script is executable.<br />
<br />
<code>chmod 755 /etc/init.d/unifi</code><br />
<br />
== Start the UniFi Controller Service ==<br />
<br />
<code>rc-service unifi start</code><br />
<br />
== Configure the UniFi Controller Service to start on boot ==<br />
<br />
<code>rc-update add unifi boot</code><br />
<br />
= Simple Backup Script =<br />
<br />
Create <code>/usr/local/bin/unifi-backup</code> using your favourite editor.<br />
<br />
Paste the following into the file.<br />
<br />
<pre><br />
#!/bin/ash<br />
<br />
conf_dir='/etc/unifi'<br />
backup_dir='/srv/backup/unifi'<br />
service_dir='/run/openrc/s6-scan/unifi'<br />
<br />
start_state='down'<br />
<br />
if s6-svok $service_dir; then<br />
if s6-svstat -o up,ready $service_dir | grep -q true; then<br />
echo 'Stopping the UniFi Controller'<br />
start_state='up'<br />
s6-svc -d $service_dir<br />
sleep 3<br />
fi<br />
else<br />
echo 'Warning: The UniFi Controller is not supervised'<br />
exit 1<br />
fi<br />
<br />
if s6-svstat -o up $service_dir | grep -q false; then<br />
echo 'Success: The UniFi Controller was stopped'<br />
else<br />
echo 'Error: The UniFi Controller is still running'<br />
exit 1<br />
fi<br />
<br />
stamp=`date +%Y-%m-%d_%H%M%S`<br />
<br />
mkdir -p $backup_dir<br />
cd $backup_dir<br />
mkdir "data-$stamp"<br />
<br />
echo "Backing up to /srv/backup/unifi/data-$stamp.tar.gz"<br />
<br />
if rsync -az /srv/unifi/data/ "data-$stamp"; then<br />
echo '* rsync succeeded'<br />
if tar czf "data-$stamp.tar.gz" "data-$stamp"; then<br />
echo '* tar succeeded'<br />
rm -rf "data-$stamp"<br />
echo 'Backup succeeded'<br />
else<br />
echo 'Backup failed: tar failed'<br />
exit 1<br />
fi<br />
fi<br />
<br />
if [ "$start_state" == 'up' ]; then<br />
echo 'Starting the UniFi Controller'<br />
s6-svc -u $service_dir<br />
sleep 5<br />
s6-svstat $service_dir<br />
fi<br />
</pre></div>
Zoot
https://wiki.alpinelinux.org/w/index.php?title=UniFi_Controller&diff=14224
UniFi Controller
2017-12-11T08:18:02Z
<p>Zoot: </p>
<hr />
<div>= Introduction =<br />
<br />
This guide explains how to install the generic Unix UniFi Controller, as available from [http://www.ubnt.com/ Ubiquity Networks]. At the time of writing this, a native Alpine Linux package is not available.<br />
<br />
Furthermore, this guide uses the incredible reliable and efficient [http://www.skarnet.org/software/s6/ s6] supervision suite to start and control the UniFi Controller.<br />
<br />
A summarised schematic of what will be installed on the filesystem.<br />
<br />
The choice of <code>/srv</code> for the UniFi Controller's root directory is based on the fact that it contains both run-time and configuration data, so installing to <code>/usr/local</code>, <code>/opt</code> or <code>/home</code> didn't seem apt. Feel free to adjust the steps below, replacing <code>/srv/unifi</code> with wherever you would prefer to install the UniFi Controller software.<br />
<br />
<pre><br />
/<br />
`--etc<br />
|-- unifi<br />
| `-- log<br />
|-- srv<br />
| `-- unifi<br />
| |-- bin<br />
| |-- conf<br />
| |-- data<br />
| |-- dl<br />
| |-- lib<br />
| |-- logs<br />
| |-- run<br />
| `-- webapps<br />
`-- run<br />
`-- openrc<br />
`-- s6-scan<br />
`-- unifi --> /etc/unifi<br />
</pre><br />
<br />
= Prerequisite Packages =<br />
<br />
== OpenJDK 8 JRE ==<br />
<br />
Install <code>openjdk8-jre</code> from the community repository.<br />
<br />
Edit <code>/etc/apk/respositories</code> and uncomment the appropriate community repository for your Alpine version:<br />
<br />
<code>http://host.name/alpine_version/community</code><br />
<br />
Update the package cache.<br />
<br />
<code>apk update</code><br />
<br />
Install the package.<br />
<br />
<code>apk add openjdk8-jre</code><br />
<br />
== MongoDB ==<br />
<br />
Install MongoDB<br />
<br />
<code>apk add mongodb</code><br />
<br />
== s6 ==<br />
<br />
Install [http://www.skarnet.org/software/s6/ s6]<br />
<br />
<code>apk add s6</code> which is a service supervision suite, for reliably and efficiently starting, stopping and keeping services running.<br />
<br />
The below shows a schematic process tree of how the UniFi Controller will be started and supervised by s6. The controller is written in Java, hence the Java process and it in turn, launches a dedicated instance of MongoDB to store its configuration and run-time data.<br />
<br />
<pre><br />
init<br />
`-- s6-svscan<br />
`-- s6-supervise<br />
|-- s6-log<br />
`-- java<br />
`-- mongod<br />
</pre><br />
<br />
= Install UniFi Controller =<br />
<br />
Create the <code>unifi</code> user and group.<br />
<br />
<code>adduser -D -H /srv/unifi unifi</code><br />
<br />
Change to the parent folder within which you wish to install the UniFi Controller.<br />
<br />
<code>cd /srv</code><br />
<br />
Download the generic unix archive of the <code>VERSION</code> you wish to install.<br />
<br />
<code>wget http://www.ubnt.com/downloads/unifi/VERSION/UniFi.unix.zip</code><br />
<br />
Unpack the archive.<br />
<br />
<code>unzip UniFi.unix.zip</code><br />
<br />
Rename the unpacked directory.<br />
<br />
<code>mv UniFi unifi</code><br />
<br />
Change ownership.<br />
<br />
<code>chown unifi:unifi unifi</code><br />
<br />
Lock down permissions.<br />
<br />
<code>chmod o-rwx unifi</code><br />
<br />
Change into the UniFi bin directory.<br />
<br />
<code>cd /srv/unifi/bin</code><br />
<br />
Remove the existing file.<br />
<br />
<code>rm mongod</code><br />
<br />
Create a symlink to <code>/usr/bin/mongod</code><br />
<br />
<code>ln -s /usr/bin/mongod</code><br />
<br />
= Configure Service Management =<br />
<br />
== Create UniFi Service Directory and Files ==<br />
<br />
Create an s6 service directory for UniFi.<br />
<br />
<code>mkdir -p /etc/unifi/log</code><br />
<br />
Add the <code>run</code> script, using your favourite editor.<br />
<br />
<code>vim /etc/unifi/run</code><br />
<br />
Copy and paste the following into it.<br />
<br />
<pre><br />
#!/bin/ash<br />
<br />
user='unifi'<br />
group='unifi'<br />
<br />
exec 2>&1<br />
<br />
base='/srv/unifi'<br />
<br />
if [ -d $base ]; then<br />
cd $base<br />
chown -R $user:$group .<br />
version=`head -1 webapps/ROOT/app-unifi/.version`<br />
echo "Starting UniFi Controller $version"<br />
exec s6-setuidgid $user java -jar lib/ace.jar start<br />
else<br />
echo "Missing $base ... aborting"<br />
touch down<br />
fi<br />
</pre><br />
<br />
Ensure that the <code>run</code> script is executable:<br />
<br />
<code>chmod 755 /etc/unifi/run</code><br />
<br />
Add the <code>log/run</code> script, using your favourite editor.<br />
<br />
<code>vim /etc/unifi/log/run</code><br />
<br />
Copy and paste the following into it.<br />
<br />
<pre><br />
#!/bin/ash<br />
<br />
log_user='log'<br />
<br />
exec s6-setuidgid $log_user s6-log -b n20 s1000000 t /var/log/unifi<br />
</pre><br />
<br />
Ensure that the log/run script is executable:<br />
<br />
<code>chmod 755 /etc/unifi/run</code><br />
<br />
== Create log User and Directory ==<br />
<br />
Create the <code>log</code> user and group.<br />
<br />
<code>adduser -D -H /var/log -g log log</code><br />
<br />
Create the <code>/var/log/unifi</code> directory<br />
<br />
<code>mkdir -p /var/log/unifi</code><br />
<br />
Update the directory ownership.<br />
<br />
<code>chown log:log /var/log/unifi</code><br />
<br />
Lock down the permissions.<br />
<br />
<code>chmod 750 /var/log/unifi</code><br />
<br />
== Create the OpenRC Service Script ==<br />
<br />
Open the script file using your favourite editor.<br />
<br />
<code>vim /etc/init.d/unifi</code><br />
<br />
Paste the following into it.<br />
<br />
<pre><br />
#!/sbin/openrc-run<br />
<br />
name="unifi"<br />
supervisor=s6<br />
s6_service_path="${RC_SVCDIR}/s6-scan/${name}"<br />
<br />
depend() {<br />
need net s6-svscan<br />
after firewall<br />
}<br />
<br />
start_pre() {<br />
if [ ! -L "${RC_SVCDIR}/s6-scan/${name}" ]; then<br />
ln -s "/etc/${name}" "${RC_SVCDIR}/s6-scan/${name}"<br />
fi<br />
}<br />
</pre><br />
<br />
Ensure that the script is executable.<br />
<br />
<code>chmod 755 /etc/init.d/unifi</code><br />
<br />
== Start the UniFi Controller Service ==<br />
<br />
<code>rc-service unifi start</code><br />
<br />
== Configure the UniFi Controller Service to start on boot ==<br />
<br />
<code>rc-update add unifi boot</code><br />
<br />
= Simple Backup Script =<br />
<br />
Create <code>/usr/local/bin/unifi-backup</code> using your favourite editor.<br />
<br />
Paste the following into the file.<br />
<br />
<pre><br />
#!/bin/ash<br />
<br />
conf_dir='/etc/unifi'<br />
backup_dir='/srv/backup/unifi'<br />
service_dir='/run/openrc/s6-scan/unifi'<br />
<br />
start_state='down'<br />
<br />
if s6-svok $service_dir; then<br />
if s6-svstat -o up,ready $service_dir | grep -q true; then<br />
echo 'Stopping the UniFi Controller'<br />
start_state='up'<br />
s6-svc -d $service_dir<br />
sleep 3<br />
fi<br />
else<br />
echo 'Warning: The UniFi Controller is not supervised'<br />
exit 1<br />
fi<br />
<br />
if s6-svstat -o up $service_dir | grep -q false; then<br />
echo 'Success: The UniFi Controller was stopped'<br />
else<br />
echo 'Error: The UniFi Controller is still running'<br />
exit 1<br />
fi<br />
<br />
stamp=`date +%Y-%m-%d_%H%M%S`<br />
<br />
mkdir -p $backup_dir<br />
cd $backup_dir<br />
mkdir "data-$stamp"<br />
<br />
echo "Backing up to /srv/backup/unifi/data-$stamp.tar.gz"<br />
<br />
if rsync -az /srv/unifi/data/ "data-$stamp"; then<br />
echo '* rsync succeeded'<br />
if tar czf "data-$stamp.tar.gz" "data-$stamp"; then<br />
echo '* tar succeeded'<br />
rm -rf "data-$stamp"<br />
echo 'Backup succeeded'<br />
else<br />
echo 'Backup failed: tar failed'<br />
exit 1<br />
fi<br />
fi<br />
<br />
if [ "$start_state" == 'up' ]; then<br />
echo 'Starting the UniFi Controller'<br />
s6-svc -u $service_dir<br />
sleep 5<br />
s6-svstat $service_dir<br />
fi<br />
</pre></div>
Zoot
https://wiki.alpinelinux.org/w/index.php?title=UniFi_Controller&diff=14223
UniFi Controller
2017-12-11T07:53:50Z
<p>Zoot: /* s6 */ - elaborate a little, for clarity</p>
<hr />
<div>= Prerequisite Packages =<br />
<br />
== OpenJDK 8 JRE ==<br />
<br />
Install <code>openjdk8-jre</code> from the community repository.<br />
<br />
Edit <code>/etc/apk/respositories</code> and uncomment the appropriate community repository for your Alpine version:<br />
<br />
<code>http://host.name/alpine_version/community</code><br />
<br />
Update the package cache.<br />
<br />
<code>apk update</code><br />
<br />
Install the package.<br />
<br />
<code>apk add openjdk8-jre</code><br />
<br />
== MongoDB ==<br />
<br />
Install MongoDB<br />
<br />
<code>apk add mongodb</code><br />
<br />
== s6 ==<br />
<br />
Install [http://www.skarnet.org/software/s6/ s6]<br />
<br />
<code>apk add s6</code> which is a service supervision suite, for reliably and efficiently starting, stopping and keeping services running.<br />
<br />
The below shows a schematic process tree of how the UniFi Controller will be started and supervised by s6. The controller is written in Java, hence the Java process and it in turn, launches a dedicated instance of MongoDB to store its configuration and run-time data.<br />
<br />
<pre><br />
init<br />
`-- s6-svscan<br />
`-- s6-supervise<br />
|-- s6-log<br />
`-- java<br />
`-- mongod<br />
</pre><br />
<br />
= Install UniFi Controller =<br />
<br />
Create the <code>unifi</code> user and group.<br />
<br />
<code>adduser -D -H /srv/unifi unifi</code><br />
<br />
Change to the parent folder within which you wish to install the UniFi Controller.<br />
<br />
<code>cd /srv</code><br />
<br />
Download the generic unix archive of the <code>VERSION</code> you wish to install.<br />
<br />
<code>wget http://www.ubnt.com/downloads/unifi/VERSION/UniFi.unix.zip</code><br />
<br />
Unpack the archive.<br />
<br />
<code>unzip UniFi.unix.zip</code><br />
<br />
Rename the unpacked directory.<br />
<br />
<code>mv UniFi unifi</code><br />
<br />
Change ownership.<br />
<br />
<code>chown unifi:unifi unifi</code><br />
<br />
Lock down permissions.<br />
<br />
<code>chmod o-rwx unifi</code><br />
<br />
Change into the UniFi bin directory.<br />
<br />
<code>cd /srv/unifi/bin</code><br />
<br />
Remove the existing file.<br />
<br />
<code>rm mongod</code><br />
<br />
Create a symlink to <code>/usr/bin/mongod</code><br />
<br />
<code>ln -s /usr/bin/mongod</code><br />
<br />
= Configure Service Management =<br />
<br />
== Create UniFi Service Directory and Files ==<br />
<br />
Create an s6 service directory for UniFi.<br />
<br />
<code>mkdir -p /etc/unifi/log</code><br />
<br />
Add the <code>run</code> script, using your favourite editor.<br />
<br />
<code>vim /etc/unifi/run</code><br />
<br />
Copy and paste the following into it.<br />
<br />
<pre><br />
#!/bin/ash<br />
<br />
user='unifi'<br />
group='unifi'<br />
<br />
exec 2>&1<br />
<br />
base='/srv/unifi'<br />
<br />
if [ -d $base ]; then<br />
cd $base<br />
chown -R $user:$group .<br />
version=`head -1 webapps/ROOT/app-unifi/.version`<br />
echo "Starting UniFi Controller $version"<br />
exec s6-setuidgid $user java -jar lib/ace.jar start<br />
else<br />
echo "Missing $base ... aborting"<br />
touch down<br />
fi<br />
</pre><br />
<br />
Ensure that the <code>run</code> script is executable:<br />
<br />
<code>chmod 755 /etc/unifi/run</code><br />
<br />
Add the <code>log/run</code> script, using your favourite editor.<br />
<br />
<code>vim /etc/unifi/log/run</code><br />
<br />
Copy and paste the following into it.<br />
<br />
<pre><br />
#!/bin/ash<br />
<br />
log_user='log'<br />
<br />
exec s6-setuidgid $log_user s6-log -b n20 s1000000 t /var/log/unifi<br />
</pre><br />
<br />
Ensure that the log/run script is executable:<br />
<br />
<code>chmod 755 /etc/unifi/run</code><br />
<br />
== Create log User and Directory ==<br />
<br />
Create the <code>log</code> user and group.<br />
<br />
<code>adduser -D -H /var/log -g log log</code><br />
<br />
Create the <code>/var/log/unifi</code> directory<br />
<br />
<code>mkdir -p /var/log/unifi</code><br />
<br />
Update the directory ownership.<br />
<br />
<code>chown log:log /var/log/unifi</code><br />
<br />
Lock down the permissions.<br />
<br />
<code>chmod 750 /var/log/unifi</code><br />
<br />
== Create the OpenRC Service Script ==<br />
<br />
Open the script file using your favourite editor.<br />
<br />
<code>vim /etc/init.d/unifi</code><br />
<br />
Paste the following into it.<br />
<br />
<pre><br />
#!/sbin/openrc-run<br />
<br />
name="unifi"<br />
supervisor=s6<br />
s6_service_path="${RC_SVCDIR}/s6-scan/${name}"<br />
<br />
depend() {<br />
need net s6-svscan<br />
after firewall<br />
}<br />
<br />
start_pre() {<br />
if [ ! -L "${RC_SVCDIR}/s6-scan/${name}" ]; then<br />
ln -s "/etc/${name}" "${RC_SVCDIR}/s6-scan/${name}"<br />
fi<br />
}<br />
</pre><br />
<br />
Ensure that the script is executable.<br />
<br />
<code>chmod 755 /etc/init.d/unifi</code><br />
<br />
== Start the UniFi Controller Service ==<br />
<br />
<code>rc-service unifi start</code><br />
<br />
== Configure the UniFi Controller Service to start on boot ==<br />
<br />
<code>rc-update add unifi boot</code><br />
<br />
= Simple Backup Script =<br />
<br />
Create <code>/usr/local/bin/unifi-backup</code> using your favourite editor.<br />
<br />
Paste the following into the file.<br />
<br />
<pre><br />
#!/bin/ash<br />
<br />
conf_dir='/etc/unifi'<br />
backup_dir='/srv/backup/unifi'<br />
service_dir='/run/openrc/s6-scan/unifi'<br />
<br />
start_state='down'<br />
<br />
if s6-svok $service_dir; then<br />
if s6-svstat -o up,ready $service_dir | grep -q true; then<br />
echo 'Stopping the UniFi Controller'<br />
start_state='up'<br />
s6-svc -d $service_dir<br />
sleep 3<br />
fi<br />
else<br />
echo 'Warning: The UniFi Controller is not supervised'<br />
exit 1<br />
fi<br />
<br />
if s6-svstat -o up $service_dir | grep -q false; then<br />
echo 'Success: The UniFi Controller was stopped'<br />
else<br />
echo 'Error: The UniFi Controller is still running'<br />
exit 1<br />
fi<br />
<br />
stamp=`date +%Y-%m-%d_%H%M%S`<br />
<br />
mkdir -p $backup_dir<br />
cd $backup_dir<br />
mkdir "data-$stamp"<br />
<br />
echo "Backing up to /srv/backup/unifi/data-$stamp.tar.gz"<br />
<br />
if rsync -az /srv/unifi/data/ "data-$stamp"; then<br />
echo '* rsync succeeded'<br />
if tar czf "data-$stamp.tar.gz" "data-$stamp"; then<br />
echo '* tar succeeded'<br />
rm -rf "data-$stamp"<br />
echo 'Backup succeeded'<br />
else<br />
echo 'Backup failed: tar failed'<br />
exit 1<br />
fi<br />
fi<br />
<br />
if [ "$start_state" == 'up' ]; then<br />
echo 'Starting the UniFi Controller'<br />
s6-svc -u $service_dir<br />
sleep 5<br />
s6-svstat $service_dir<br />
fi<br />
</pre></div>
Zoot
https://wiki.alpinelinux.org/w/index.php?title=UniFi_Controller&diff=14222
UniFi Controller
2017-12-11T07:22:03Z
<p>Zoot: /* s6 */ - better explanation of what s6 is</p>
<hr />
<div>= Prerequisite Packages =<br />
<br />
== OpenJDK 8 JRE ==<br />
<br />
Install <code>openjdk8-jre</code> from the community repository.<br />
<br />
Edit <code>/etc/apk/respositories</code> and uncomment the appropriate community repository for your Alpine version:<br />
<br />
<code>http://host.name/alpine_version/community</code><br />
<br />
Update the package cache.<br />
<br />
<code>apk update</code><br />
<br />
Install the package.<br />
<br />
<code>apk add openjdk8-jre</code><br />
<br />
== MongoDB ==<br />
<br />
Install MongoDB<br />
<br />
<code>apk add mongodb</code><br />
<br />
== s6 ==<br />
<br />
Install [http://www.skarnet.org/software/s6/ s6]<br />
<br />
<code>apk add s6</code> which is a service supervision suite, for reliably and efficiently starting, stopping and keeping services running.<br />
<br />
= Install UniFi Controller =<br />
<br />
Create the <code>unifi</code> user and group.<br />
<br />
<code>adduser -D -H /srv/unifi unifi</code><br />
<br />
Change to the parent folder within which you wish to install the UniFi Controller.<br />
<br />
<code>cd /srv</code><br />
<br />
Download the generic unix archive of the <code>VERSION</code> you wish to install.<br />
<br />
<code>wget http://www.ubnt.com/downloads/unifi/VERSION/UniFi.unix.zip</code><br />
<br />
Unpack the archive.<br />
<br />
<code>unzip UniFi.unix.zip</code><br />
<br />
Rename the unpacked directory.<br />
<br />
<code>mv UniFi unifi</code><br />
<br />
Change ownership.<br />
<br />
<code>chown unifi:unifi unifi</code><br />
<br />
Lock down permissions.<br />
<br />
<code>chmod o-rwx unifi</code><br />
<br />
Change into the UniFi bin directory.<br />
<br />
<code>cd /srv/unifi/bin</code><br />
<br />
Remove the existing file.<br />
<br />
<code>rm mongod</code><br />
<br />
Create a symlink to <code>/usr/bin/mongod</code><br />
<br />
<code>ln -s /usr/bin/mongod</code><br />
<br />
= Configure Service Management =<br />
<br />
== Create UniFi Service Directory and Files ==<br />
<br />
Create an s6 service directory for UniFi.<br />
<br />
<code>mkdir -p /etc/unifi/log</code><br />
<br />
Add the <code>run</code> script, using your favourite editor.<br />
<br />
<code>vim /etc/unifi/run</code><br />
<br />
Copy and paste the following into it.<br />
<br />
<pre><br />
#!/bin/ash<br />
<br />
user='unifi'<br />
group='unifi'<br />
<br />
exec 2>&1<br />
<br />
base='/srv/unifi'<br />
<br />
if [ -d $base ]; then<br />
cd $base<br />
chown -R $user:$group .<br />
version=`head -1 webapps/ROOT/app-unifi/.version`<br />
echo "Starting UniFi Controller $version"<br />
exec s6-setuidgid $user java -jar lib/ace.jar start<br />
else<br />
echo "Missing $base ... aborting"<br />
touch down<br />
fi<br />
</pre><br />
<br />
Ensure that the <code>run</code> script is executable:<br />
<br />
<code>chmod 755 /etc/unifi/run</code><br />
<br />
Add the <code>log/run</code> script, using your favourite editor.<br />
<br />
<code>vim /etc/unifi/log/run</code><br />
<br />
Copy and paste the following into it.<br />
<br />
<pre><br />
#!/bin/ash<br />
<br />
log_user='log'<br />
<br />
exec s6-setuidgid $log_user s6-log -b n20 s1000000 t /var/log/unifi<br />
</pre><br />
<br />
Ensure that the log/run script is executable:<br />
<br />
<code>chmod 755 /etc/unifi/run</code><br />
<br />
== Create log User and Directory ==<br />
<br />
Create the <code>log</code> user and group.<br />
<br />
<code>adduser -D -H /var/log -g log log</code><br />
<br />
Create the <code>/var/log/unifi</code> directory<br />
<br />
<code>mkdir -p /var/log/unifi</code><br />
<br />
Update the directory ownership.<br />
<br />
<code>chown log:log /var/log/unifi</code><br />
<br />
Lock down the permissions.<br />
<br />
<code>chmod 750 /var/log/unifi</code><br />
<br />
== Create the OpenRC Service Script ==<br />
<br />
Open the script file using your favourite editor.<br />
<br />
<code>vim /etc/init.d/unifi</code><br />
<br />
Paste the following into it.<br />
<br />
<pre><br />
#!/sbin/openrc-run<br />
<br />
name="unifi"<br />
supervisor=s6<br />
s6_service_path="${RC_SVCDIR}/s6-scan/${name}"<br />
<br />
depend() {<br />
need net s6-svscan<br />
after firewall<br />
}<br />
<br />
start_pre() {<br />
if [ ! -L "${RC_SVCDIR}/s6-scan/${name}" ]; then<br />
ln -s "/etc/${name}" "${RC_SVCDIR}/s6-scan/${name}"<br />
fi<br />
}<br />
</pre><br />
<br />
Ensure that the script is executable.<br />
<br />
<code>chmod 755 /etc/init.d/unifi</code><br />
<br />
== Start the UniFi Controller Service ==<br />
<br />
<code>rc-service unifi start</code><br />
<br />
== Configure the UniFi Controller Service to start on boot ==<br />
<br />
<code>rc-update add unifi boot</code><br />
<br />
= Simple Backup Script =<br />
<br />
Create <code>/usr/local/bin/unifi-backup</code> using your favourite editor.<br />
<br />
Paste the following into the file.<br />
<br />
<pre><br />
#!/bin/ash<br />
<br />
conf_dir='/etc/unifi'<br />
backup_dir='/srv/backup/unifi'<br />
service_dir='/run/openrc/s6-scan/unifi'<br />
<br />
start_state='down'<br />
<br />
if s6-svok $service_dir; then<br />
if s6-svstat -o up,ready $service_dir | grep -q true; then<br />
echo 'Stopping the UniFi Controller'<br />
start_state='up'<br />
s6-svc -d $service_dir<br />
sleep 3<br />
fi<br />
else<br />
echo 'Warning: The UniFi Controller is not supervised'<br />
exit 1<br />
fi<br />
<br />
if s6-svstat -o up $service_dir | grep -q false; then<br />
echo 'Success: The UniFi Controller was stopped'<br />
else<br />
echo 'Error: The UniFi Controller is still running'<br />
exit 1<br />
fi<br />
<br />
stamp=`date +%Y-%m-%d_%H%M%S`<br />
<br />
mkdir -p $backup_dir<br />
cd $backup_dir<br />
mkdir "data-$stamp"<br />
<br />
echo "Backing up to /srv/backup/unifi/data-$stamp.tar.gz"<br />
<br />
if rsync -az /srv/unifi/data/ "data-$stamp"; then<br />
echo '* rsync succeeded'<br />
if tar czf "data-$stamp.tar.gz" "data-$stamp"; then<br />
echo '* tar succeeded'<br />
rm -rf "data-$stamp"<br />
echo 'Backup succeeded'<br />
else<br />
echo 'Backup failed: tar failed'<br />
exit 1<br />
fi<br />
fi<br />
<br />
if [ "$start_state" == 'up' ]; then<br />
echo 'Starting the UniFi Controller'<br />
s6-svc -u $service_dir<br />
sleep 5<br />
s6-svstat $service_dir<br />
fi<br />
</pre></div>
Zoot
https://wiki.alpinelinux.org/w/index.php?title=UniFi_Controller&diff=14221
UniFi Controller
2017-12-11T07:20:06Z
<p>Zoot: /* Install UniFi Controller */ - correct adduser arguments</p>
<hr />
<div>= Prerequisite Packages =<br />
<br />
== OpenJDK 8 JRE ==<br />
<br />
Install <code>openjdk8-jre</code> from the community repository.<br />
<br />
Edit <code>/etc/apk/respositories</code> and uncomment the appropriate community repository for your Alpine version:<br />
<br />
<code>http://host.name/alpine_version/community</code><br />
<br />
Update the package cache.<br />
<br />
<code>apk update</code><br />
<br />
Install the package.<br />
<br />
<code>apk add openjdk8-jre</code><br />
<br />
== MongoDB ==<br />
<br />
Install MongoDB<br />
<br />
<code>apk add mongodb</code><br />
<br />
== s6 ==<br />
<br />
Install [http://www.skarnet.org/software/s6/ s6]<br />
<br />
<code>apk add s6</code><br />
<br />
= Install UniFi Controller =<br />
<br />
Create the <code>unifi</code> user and group.<br />
<br />
<code>adduser -D -H /srv/unifi unifi</code><br />
<br />
Change to the parent folder within which you wish to install the UniFi Controller.<br />
<br />
<code>cd /srv</code><br />
<br />
Download the generic unix archive of the <code>VERSION</code> you wish to install.<br />
<br />
<code>wget http://www.ubnt.com/downloads/unifi/VERSION/UniFi.unix.zip</code><br />
<br />
Unpack the archive.<br />
<br />
<code>unzip UniFi.unix.zip</code><br />
<br />
Rename the unpacked directory.<br />
<br />
<code>mv UniFi unifi</code><br />
<br />
Change ownership.<br />
<br />
<code>chown unifi:unifi unifi</code><br />
<br />
Lock down permissions.<br />
<br />
<code>chmod o-rwx unifi</code><br />
<br />
Change into the UniFi bin directory.<br />
<br />
<code>cd /srv/unifi/bin</code><br />
<br />
Remove the existing file.<br />
<br />
<code>rm mongod</code><br />
<br />
Create a symlink to <code>/usr/bin/mongod</code><br />
<br />
<code>ln -s /usr/bin/mongod</code><br />
<br />
= Configure Service Management =<br />
<br />
== Create UniFi Service Directory and Files ==<br />
<br />
Create an s6 service directory for UniFi.<br />
<br />
<code>mkdir -p /etc/unifi/log</code><br />
<br />
Add the <code>run</code> script, using your favourite editor.<br />
<br />
<code>vim /etc/unifi/run</code><br />
<br />
Copy and paste the following into it.<br />
<br />
<pre><br />
#!/bin/ash<br />
<br />
user='unifi'<br />
group='unifi'<br />
<br />
exec 2>&1<br />
<br />
base='/srv/unifi'<br />
<br />
if [ -d $base ]; then<br />
cd $base<br />
chown -R $user:$group .<br />
version=`head -1 webapps/ROOT/app-unifi/.version`<br />
echo "Starting UniFi Controller $version"<br />
exec s6-setuidgid $user java -jar lib/ace.jar start<br />
else<br />
echo "Missing $base ... aborting"<br />
touch down<br />
fi<br />
</pre><br />
<br />
Ensure that the <code>run</code> script is executable:<br />
<br />
<code>chmod 755 /etc/unifi/run</code><br />
<br />
Add the <code>log/run</code> script, using your favourite editor.<br />
<br />
<code>vim /etc/unifi/log/run</code><br />
<br />
Copy and paste the following into it.<br />
<br />
<pre><br />
#!/bin/ash<br />
<br />
log_user='log'<br />
<br />
exec s6-setuidgid $log_user s6-log -b n20 s1000000 t /var/log/unifi<br />
</pre><br />
<br />
Ensure that the log/run script is executable:<br />
<br />
<code>chmod 755 /etc/unifi/run</code><br />
<br />
== Create log User and Directory ==<br />
<br />
Create the <code>log</code> user and group.<br />
<br />
<code>adduser -D -H /var/log -g log log</code><br />
<br />
Create the <code>/var/log/unifi</code> directory<br />
<br />
<code>mkdir -p /var/log/unifi</code><br />
<br />
Update the directory ownership.<br />
<br />
<code>chown log:log /var/log/unifi</code><br />
<br />
Lock down the permissions.<br />
<br />
<code>chmod 750 /var/log/unifi</code><br />
<br />
== Create the OpenRC Service Script ==<br />
<br />
Open the script file using your favourite editor.<br />
<br />
<code>vim /etc/init.d/unifi</code><br />
<br />
Paste the following into it.<br />
<br />
<pre><br />
#!/sbin/openrc-run<br />
<br />
name="unifi"<br />
supervisor=s6<br />
s6_service_path="${RC_SVCDIR}/s6-scan/${name}"<br />
<br />
depend() {<br />
need net s6-svscan<br />
after firewall<br />
}<br />
<br />
start_pre() {<br />
if [ ! -L "${RC_SVCDIR}/s6-scan/${name}" ]; then<br />
ln -s "/etc/${name}" "${RC_SVCDIR}/s6-scan/${name}"<br />
fi<br />
}<br />
</pre><br />
<br />
Ensure that the script is executable.<br />
<br />
<code>chmod 755 /etc/init.d/unifi</code><br />
<br />
== Start the UniFi Controller Service ==<br />
<br />
<code>rc-service unifi start</code><br />
<br />
== Configure the UniFi Controller Service to start on boot ==<br />
<br />
<code>rc-update add unifi boot</code><br />
<br />
= Simple Backup Script =<br />
<br />
Create <code>/usr/local/bin/unifi-backup</code> using your favourite editor.<br />
<br />
Paste the following into the file.<br />
<br />
<pre><br />
#!/bin/ash<br />
<br />
conf_dir='/etc/unifi'<br />
backup_dir='/srv/backup/unifi'<br />
service_dir='/run/openrc/s6-scan/unifi'<br />
<br />
start_state='down'<br />
<br />
if s6-svok $service_dir; then<br />
if s6-svstat -o up,ready $service_dir | grep -q true; then<br />
echo 'Stopping the UniFi Controller'<br />
start_state='up'<br />
s6-svc -d $service_dir<br />
sleep 3<br />
fi<br />
else<br />
echo 'Warning: The UniFi Controller is not supervised'<br />
exit 1<br />
fi<br />
<br />
if s6-svstat -o up $service_dir | grep -q false; then<br />
echo 'Success: The UniFi Controller was stopped'<br />
else<br />
echo 'Error: The UniFi Controller is still running'<br />
exit 1<br />
fi<br />
<br />
stamp=`date +%Y-%m-%d_%H%M%S`<br />
<br />
mkdir -p $backup_dir<br />
cd $backup_dir<br />
mkdir "data-$stamp"<br />
<br />
echo "Backing up to /srv/backup/unifi/data-$stamp.tar.gz"<br />
<br />
if rsync -az /srv/unifi/data/ "data-$stamp"; then<br />
echo '* rsync succeeded'<br />
if tar czf "data-$stamp.tar.gz" "data-$stamp"; then<br />
echo '* tar succeeded'<br />
rm -rf "data-$stamp"<br />
echo 'Backup succeeded'<br />
else<br />
echo 'Backup failed: tar failed'<br />
exit 1<br />
fi<br />
fi<br />
<br />
if [ "$start_state" == 'up' ]; then<br />
echo 'Starting the UniFi Controller'<br />
s6-svc -u $service_dir<br />
sleep 5<br />
s6-svstat $service_dir<br />
fi<br />
</pre></div>
Zoot
https://wiki.alpinelinux.org/w/index.php?title=Tutorials_and_Howtos&diff=14220
Tutorials and Howtos
2017-12-10T22:07:27Z
<p>Zoot: Add link to UniFi Controller page</p>
<hr />
<div>[[Image:package_edutainment.svg|right|link=]]<br />
{{TOC left}}<br />
'''Welcome to Tutorials and Howtos, a place of basic and advanced configuration tasks for your Alpine Linux.'''<br />
<br />
The tutorials are hands-on and the reader is expected to try and achieve the goals described in each step, possibly with the help of a good example. The output in one step is the starting point for the following step.<br />
<br />
Howtos are smaller articles explaining how to perform a particular task with Alpine Linux.<br />
<br />
We encourage people to send in both complete articles as well as requesting topics to be covered. If you think you have the skills and knowledge to write an Alpine Linux related article please do so on this Wiki. If you want to request a topic, please add your request in this page's [[Talk:Tutorials_and_Howtos|Discussion]].<br />
<br />
{{Clear}}<br />
== Storage ==<br />
<br />
* [[Alpine local backup|Alpine local backup (lbu)]] ''(Permanently store your modifications in case your box needs reboot)'' <!-- Installation and Storage --><br />
** [[Back Up a Flash Memory Installation]] <!-- Installation and Storage --><br />
** [[Manually editing a existing apkovl]]<br />
<br />
* [[Setting up disks manually]] <!-- Installation and Storage --><br />
* [[Setting up a software RAID array]]<br />
<!-- ** [[Setting up a /var partition on software IDE raid1]] Obsolete, Installation and Storage --> <br />
* [[Raid Administration]]<br />
* [[Setting up encrypted volumes with LUKS]]<br />
* [[Setting up LVM on LUKS]]<br />
* [[Setting up Logical Volumes with LVM]]<br />
** [[Setting up LVM on GPT-labeled disks]]<br />
** [[Installing on GPT LVM]]<br />
* [[Filesystems|Formatting HD/Floppy/Other]] <!-- just a stub --><br />
<br />
* [[Setting up iSCSI]]<br />
** [[iSCSI Raid and Clustered File Systems]]<br />
* [[Setting up NBD]]<br />
* [[High performance SCST iSCSI Target on Linux software Raid]] ''(deprecated)'' <!-- solution --><br />
* [[Linux iSCSI Target (TCM)]]<br />
* [[Disk Replication with DRBD]] <!-- draft --><br />
<br />
* [[Burning ISOs]] <!-- just some links now --><br />
* [[Partitioning and Bootmanagers]]<br />
* [[Migrating data]]<br />
* [[Create a bootable SDHC from a Mac]]<br />
* [[Alpine on ARM]]<br />
<br />
== Networking ==<br />
<br />
* [[Configure Networking]]<br />
* [[Connecting to a wireless access point]]<br />
* [[Bonding]]<br />
* [[Vlan]]<br />
* [[Bridge]]<br />
* [[OpenVSwitch]]<br />
* [[How to configure static routes]]<br />
<br />
* [[Alpine Wall]] - [[How-To Alpine Wall]] - [[Alpine Wall User's Guide]] ''(a new firewall management framework)''<br />
<br />
* [[PXE boot]]<br />
<br />
* [[Using serial modem]]<br />
* [[Using HSDPA modem]]<br />
* [[Setting up Satellite Internet Connection]]<br />
* [[Using Alpine on Windows domain with IPSEC isolation]]<br />
<br />
* [[Setting up a ssh-server]] ''(Using ssh is a good way to administer your box remotely)'' <!-- Server and Networking --><br />
* [[How to setup a wireless access point]] ''(Setting up Secure Wireless AP w/ WPA encryption with bridge to wired network)''<br />
* [[Setting up a OpenVPN server with Alpine]] ''(Allowing single users or devices to remotely connect to your network)''<br />
<!-- [[Using Racoon for Remote Sites]] is a different VPN tunnelling method, but that article is just a stub --><br />
* [[Experiences with OpenVPN-client on ALIX.2D3]] <!-- solution --><br />
<br />
* [[Generating SSL certs with ACF]] <!-- Generating SSL certs with ACF 1.9 --><br />
* [[Setting up unbound DNS server]]<br />
* [[Setting up nsd DNS server]]<br />
* [[TinyDNS Format]]<br />
* [[Fault Tolerant Routing with Alpine Linux]] <!-- solution --><br />
* [[Freeradius Active Directory Integration]]<br />
* [[Multi_ISP]] ''(Dual-ISP setup with load-balancing and automatic failover)''<br />
* [[OwnCloud]] ''(Installing OwnCloud)''<br />
<br />
* [[Seafile: setting up your own private cloud]]<br />
<br />
== Post-Install ==<br />
<!-- If you edit this, please coordinate with Installation#Post-Install and Developer_Documentation#Package_management. Note that these three sections are not exact duplicates. --><br />
<br />
* [[Alpine Linux package management|Package Management (apk)]] ''(How to add/remove packages on your Alpine)''<br />
<!-- [[Alpine Linux package management#Local_Cache|How to enable APK caching]] --><br />
** [[Comparison with other distros]]<br />
* [[Alpine local backup|Alpine local backup (lbu)]] ''(Permanently store your modifications in case your box needs reboot)''<br />
** [[Back Up a Flash Memory Installation]] <!-- new --><br />
** [[Manually editing a existing apkovl]]<br />
* [[Alpine Linux Init System|Init System (OpenRC)]] ''(Configure a service to automatically boot at next reboot)''<br />
** [[Multiple Instances of Services]]<br />
<!-- [[Writing Init Scripts]] --><br />
* [[Alpine setup scripts#setup-xorg-base|Setting up Xorg]]<br />
* [[Upgrading Alpine]]<br />
<!-- Obsolete<br />
[[Upgrading Alpine - v1.9.x]]<br />
[[Upgrading Alpine - CD v1.8.x]]<br />
[[Upgrading Alpine - HD v1.8.x]]<br />
[[Upgrade to repository main|Upgrading to signed repositories]]<br />
--><br />
<br />
* [[Setting up a ssh-server]] ''(Using ssh is a good way to administer your box remotely)''<br />
* [[setup-acf]] ''(Configures ACF (webconfiguration) so you can manage your box through https)''<br />
* [[Changing passwords for ACF|Changing passwords]]<br />
* [[Ansible]] ''(Configuration management)''<br />
<br />
* [[Enable Serial Console on Boot]]<br />
<!-- Obsolete?<br />
* [[Error message on boot: Address space collision: host bridge window conflicts with Adaptor ROM]]<br />
--><br />
* [[How to get regular stuff working]] ''some notes on need-to-know topics''<br />
* [[Installing Oracle Java]]<br />
* [[Rsnapshot|Setting up periodic backups with <samp>rsnapshot</samp>]]<br />
<br />
== Virtualization==<br />
<br />
* [[Xen Dom0]] ''(Setting up Alpine as a dom0 for Xen hypervisor)''<br />
* [[Xen Dom0 on USB or SD]]<br />
* [[Create Alpine Linux PV DomU]]<br />
* [[Xen PCI Passthrough]]<br />
* [[Xen LiveCD]]<br />
* [[qemu]]<br />
* [[KVM]] ''(Setting up Alpine as a KVM hypervisor)''<br />
* [[LXC]] ''(Setting up a Linux container in Alpine Linux)''<br />
* [[Docker]]<br />
* [[Install_Alpine_on_VirtualBox]]<br />
<br />
== Desktop Environment ==<br />
<br />
* [[Awesome(wm) Setup]]<br />
* [[EyeOS]] ''(Cloud Computing Desktop)''<br />
* [[Gnome Setup]]<br />
* [[MATE|MATE Setup]]<br />
* [[Oneye]] ''(Cloud Computing Desktop - Dropbox Alternative)''<br />
* [[Owncloud]] ''(Cloud Computing Desktop - Dropbox Alternative)''<br />
** (to be merged with [[OwnCloud]] ''(Your personal Cloud for storing and sharing your data on-line)'')<br />
* [[Remote Desktop Server]]<br />
* [[Suspend on LID close]]<br />
* [[XFCE Setup]] and [[Xfce Desktop|Desktop Ideas]]<br />
* [[Installing Adobe flash player for Firefox]]<br />
* [[Sound Setup]]<br />
* [[Printer Setup]]<br />
* [[Default applications]]<br />
<br />
== Raspberry Pi ==<br />
<br />
* [[Raspberry Pi|Raspberry Pi (Installation)]]<br />
* [[Classic install or sys mode on Raspberry Pi]]<br />
* [[RPI Video Receiver]] ''(network video decoder using Rasperry Pi and omxplayer)''<br />
* [[Linux Router with VPN on a Raspberry Pi]]<br />
* [[Raspberry Pi 3 - Configuring it as wireless access point -AP Mode]]<br />
* [[Raspberry Pi 3 - Setting Up Bluetooth]]<br />
<br />
== Applications ==<br />
<br />
=== Telephony ===<br />
* [[Setting up Zaptel/Asterisk on Alpine]]<br />
** [[Setting up Streaming an Asterisk Channel]]<br />
* [[Freepbx on Alpine Linux]]<br />
* [[FreePBX_V3]] ''(FreeSWITCH, Asterisk GUI web acces tool)''<br />
* [[2600hz]] ''(FreeSWITCH, Asterisk GUI web access tool)''<br />
* [[Kamailio]] ''(SIP Server, formerly OpenSER)''<br />
<br />
=== Mail ===<br />
* [[Hosting services on Alpine]] ''(Hosting mail, webservices and other services)''<br />
** [[Hosting Web/Email services on Alpine]]<br />
* [[ISP Mail Server HowTo]] <!-- solution, Mail --><br />
** [[ISP Mail Server Upgrade 2.x]]<br />
** [[ISP Mail Server 2.x HowTo]] ''(Beta, please test)''<br />
** [[ISP Mail Server 3.x HowTo]]<br />
* [[Roundcube]] ''(Webmail system)''<br />
* [[Setting up postfix with virtual domains]]<br />
* [[Protecting your email server with Alpine]]<br />
* [[Setting up clamsmtp]]<br />
* [[Setting up dovecot with imap and ssl]]<br />
* [[relay email to gmail (msmtp, mailx, sendmail]]<br />
<br />
=== HTTP ===<br />
* [[Lighttpd]]<br />
** [[Lighttpd Https access]]<br />
** [[Setting Up Lighttpd with PHP]]<br />
** [[Setting Up Lighttpd With FastCGI]]<br />
* [[Cherokee]]<br />
* [[Nginx]]<br />
** [[Nginx_with_PHP#Nginx_with_PHP|Nginx with PHP]]<br />
** [[Nginx as reverse proxy with acme (letsencrypt)]]<br />
* [[Apache]]<br />
** [[Apache with php-fpm]]<br />
** [[Setting Up Apache with PHP]]<br />
** [[Apache authentication: NTLM Single Signon]]<br />
<br />
* [[High Availability High Performance Web Cache]] ''(uCarp + HAProxy for High Availability Services such as Squid web proxy)'' <!-- solution, Server --><br />
<br />
* [[Setting up Transparent Squid Proxy]] <!-- draft --><br />
** [[SqStat]] ''(Script to look at active squid users connections)''<br />
** [[Obtaining user information via SNMP]] ''(Using squark-auth-snmp as a Squid authentication helper)'' <!-- Networking and Server, <== Using squark-auth-snmp --><br />
* [[Setting up Explicit Squid Proxy]]<br />
<br />
* [[Drupal]] ''(Content Management System (CMS) written in PHP)''<br />
* [[WordPress]] ''(Web software to create website or blog)''<br />
* [[MediaWiki]] ''(Free web-based wiki software application)''<br />
* [[DokuWiki]]<br />
* [[Darkhttpd]]<br />
* [[Tomcat]]<br />
<br />
=== Other Servers ===<br />
* [[Setting up a ssh-server]] ''(Using ssh is a good way to administer your box remotely)''<br />
<br />
* [[Setting up a nfs-server]]<br />
* [[Setting up a samba-server]] ''(standard file sharing)''<br />
* [[Setting up a samba-ad-dc]] ''(Active Directory compatible domain controller)''<br />
* [[Phpizabi]] ''(Social Networking Platform)''<br />
* [[Statusnet]] ''(Microblogging Platform)''<br />
* [[Pastebin]] ''(Pastebin software application)''<br />
* [[Setting up Transmission (bittorrent) with Clutch WebUI]]<br />
<br />
* [[Patchwork]] ''(Patch review management system)''<br />
* [[Redmine]] ''(Project management system)''<br />
* [[Request-Tracker]] ''(Ticket system)''<br />
* [[OsTicket]] ''(Ticket system)''<br />
* [[Setting up trac wiki|Trac]] ''(Enhanced wiki and issue tracking system for software development projects)''<br />
<br />
* [[Cgit]]<br />
** [[Setting up a git repository server with gitolite and cgit]] <!-- doesn't exist yet --><br />
* [[Roundcube]] ''(Webmail system)''<br />
* [[Glpi]] ''(Manage inventory of technical resources)''<br />
<br />
* [[How to setup a Alpine Linux mirror]]<br />
* [[Cups]]<br />
* [[NgIRCd]] ''(Server for Internet Relay Chat/IRC)''<br />
* [[How To Setup Your Own IRC Network]] ''(Using {{Pkg|charybdis}} and {{Pkg|atheme-iris}})''<br />
* [[OpenVCP]] ''(VServer Control Panel)''<br />
* [[Mahara]] ''(E-portfolio and social networking system)''<br />
* [[Chrony and GPSD | Using chrony, gpsd, and a garmin LVC 18 as a Stratum 1 NTP source ]]<br />
* [[Sending SMS using gnokii]]<br />
* [[IPTV How To|Internet Protocol television (IPTV)]]<br />
* [[UniFi_Controller]]<br />
<br />
=== Monitoring ===<br />
* Setting up [[collectd]]<br />
* [[Traffic monitoring]] <!-- Networking and Monitoring --><br />
* [[Setting up traffic monitoring using rrdtool (and snmp)]] <!-- Monitoring --><br />
* [[Setting up monitoring using rrdtool (and rrdcollect)]]<br />
* [[Setting up Cacti|Cacti]] ''(Front-end for rrdtool networking monitor)''<br />
* [[LTTng]] ''(Kernel and userspace tracing)''<br />
* [[Setting up Zabbix|Zabbix]] ''(Monitor and track the status of network services and hardware)''<br />
* [[Setting up A Network Monitoring and Inventory System]] ''(Nagios + OpenAudit and related components)'' <!-- draft, solution, Networking and Monitoring and Server --><br />
** [[Setting up NRPE daemon]] ''(Performs remote Nagios checks)'' <!-- Networking and Monitoring --><br />
* [[Setting up Smokeping|Smokeping]] ''(Network latency monitoring)'' <!-- Networking and Monitoring --><br />
** [[Setting up MRTG and Smokeping to Monitor Bandwidth Usage and Network Latency]]<br />
* [[Setting Up Fprobe And Ntop|Ntop]] ''(NetFlow collection and analysis using a remote fprobe instance)'' <!-- Networking and Monitoring --><br />
* [[Cvechecker]] ''(Compare installed packages for Common Vulnerabilities Exposure)'' <!-- Monitoring and Security --><br />
<br />
* [[IP Accounting]] <!-- Networking and Monitoring --><br />
* [[Obtaining user information via SNMP]] ''(Using squark-auth-snmp as a Squid authentication helper)'' <!-- Networking and Server, <== Using squark-auth-snmp --><br />
* [[SqStat]] ''(Script to look at active squid users connections)''<br />
<br />
* [[Piwik]] ''(A real time web analytics software program)''<br />
* [[Awstats]] ''(Free log file analyzer)''<br />
* [[Intrusion Detection using Snort]]<br />
** [[Intrusion Detection using Snort, Sguil, Barnyard and more]]<br />
* [[Dglog]] ''(Log analyzer for the web content filter DansGuardian)''<br />
<br />
* [[Webmin]] ''(A web-based interface for Linux system)''<br />
* [[PhpPgAdmin]] ''(Web-based administration tool for PostgreSQL)''<br />
* [[PhpMyAdmin]] ''(Web-based administration tool for MYSQL)''<br />
* [[PhpSysInfo]] ''(A simple application that displays information about the host it's running on)''<br />
* [[Linfo]]<br />
<br />
* [[Setting up lm_sensors]]<br />
<br />
* [[ZoneMinder video camera security and surveillance]]<br />
<br />
== Misc ==<br />
<br />
* [[:Category:Shell]]<br />
* [[:Category:Programming]]<br />
* [[Running glibc programs]]<br />
* [[:Category:Drivers]]<br />
* [[:Category:Multimedia]]<br />
* [[Kernel Modesetting]]<br />
* [[CPU frequency scaling]]<br />
<br />
== Complete Solutions ==<br />
* [[DIY Fully working Alpine Linux for Allwinner and Other ARM SOCs]]<br />
* [[Replacing non-Alpine Linux with Alpine remotely]]<br />
* [[High performance SCST iSCSI Target on Linux software Raid]]<br />
* [[Fault Tolerant Routing with Alpine Linux]]<br />
* [[Experiences with OpenVPN-client on ALIX.2D3]]<br />
* [[Building a cloud with Alpine Linux]]<br />
<br />
* [[ISP Mail Server HowTo]] ''(Postfix+PostfixAdmin+DoveCot+Roundcube+ClamAV+Spamd - A full-serivce ISP mail server)''<br />
** [[ISP Mail Server Upgrade 2.x]]<br />
** [[ISP Mail Server 2.x HowTo]] ''(Beta, please test)''<br />
* [[High Availability High Performance Web Cache]] ''(uCarp + HAProxy for High Availability Services such as Squid web proxy)''<br />
* [[Setting up A Network Monitoring and Inventory System]] ''(Nagios + OpenAudit and related components)'' <!-- draft --><br />
* [[Streaming Security Camera Video with VLC]]<br />
* [[Dynamic Multipoint VPN (DMVPN)]] combined with [[Small_Office_Services]]<br />
<br />
<br />
<!--<br />
This does not attempt to be complete. Is it useful to have these listed here? I find them more accessible if grouped with their topics; also, an up-to-date list of all Draft or Obsolete pages can be found at [[Project:Wiki maintenance]].<br />
<br />
== Drafts ==<br />
Currently unfinished/works-in-progress.<br />
* [[Using Racoon for Remote Sites]]<br />
* [[Setting up Transparent Squid Proxy]] ''(Covers Squid proxy and URL Filtering system)''<br />
** [[Obtaining user information via SNMP]] ''(Using the Squark Squid authentication helper)'' [!-- no longer a draft --]<br />
* [[Setting up Streaming an Asterisk Channel]]<br />
* [[Setting up A Network Monitoring and Inventory System]] ''(Nagios + OpenAudit and related components)''<br />
* [[Intrusion Detection using Snort]] ''(Installing and configuring Snort and related applications on Alpine 2.0.x)''<br />
* [[IP Accounting]] ''(Installing and configuring pmacct for IP Accounting, Netflow/sFlow collector)''<br />
* [[Disk Replication with DRBD]]<br />
--></div>
Zoot
https://wiki.alpinelinux.org/w/index.php?title=UniFi_Controller&diff=14219
UniFi Controller
2017-12-10T21:50:39Z
<p>Zoot: Complete all steps. Will re-test soon.</p>
<hr />
<div>= Prerequisite Packages =<br />
<br />
== OpenJDK 8 JRE ==<br />
<br />
Install <code>openjdk8-jre</code> from the community repository.<br />
<br />
Edit <code>/etc/apk/respositories</code> and uncomment the appropriate community repository for your Alpine version:<br />
<br />
<code>http://host.name/alpine_version/community</code><br />
<br />
Update the package cache.<br />
<br />
<code>apk update</code><br />
<br />
Install the package.<br />
<br />
<code>apk add openjdk8-jre</code><br />
<br />
== MongoDB ==<br />
<br />
Install MongoDB<br />
<br />
<code>apk add mongodb</code><br />
<br />
== s6 ==<br />
<br />
Install [http://www.skarnet.org/software/s6/ s6]<br />
<br />
<code>apk add s6</code><br />
<br />
= Install UniFi Controller =<br />
<br />
Create the <code>unifi</code> user and group.<br />
<br />
<code>adduser -D -H /srv/unifi -g unifi unifi</code><br />
<br />
Change to the parent folder within which you wish to install the UniFi Controller.<br />
<br />
<code>cd /srv</code><br />
<br />
Download the generic unix archive of the <code>VERSION</code> you wish to install.<br />
<br />
<code>wget http://www.ubnt.com/downloads/unifi/VERSION/UniFi.unix.zip</code><br />
<br />
Unpack the archive.<br />
<br />
<code>unzip UniFi.unix.zip</code><br />
<br />
Rename the unpacked directory.<br />
<br />
<code>mv UniFi unifi</code><br />
<br />
Change ownership.<br />
<br />
<code>chown unifi:unifi unifi</code><br />
<br />
Lock down permissions.<br />
<br />
<code>chmod o-rwx unifi</code><br />
<br />
Change into the UniFi bin directory.<br />
<br />
<code>cd /srv/unifi/bin</code><br />
<br />
Remove the existing file.<br />
<br />
<code>rm mongod</code><br />
<br />
Create a symlink to <code>/usr/bin/mongod</code><br />
<br />
<code>ln -s /usr/bin/mongod</code><br />
<br />
= Configure Service Management =<br />
<br />
== Create UniFi Service Directory and Files ==<br />
<br />
Create an s6 service directory for UniFi.<br />
<br />
<code>mkdir -p /etc/unifi/log</code><br />
<br />
Add the <code>run</code> script, using your favourite editor.<br />
<br />
<code>vim /etc/unifi/run</code><br />
<br />
Copy and paste the following into it.<br />
<br />
<pre><br />
#!/bin/ash<br />
<br />
user='unifi'<br />
group='unifi'<br />
<br />
exec 2>&1<br />
<br />
base='/srv/unifi'<br />
<br />
if [ -d $base ]; then<br />
cd $base<br />
chown -R $user:$group .<br />
version=`head -1 webapps/ROOT/app-unifi/.version`<br />
echo "Starting UniFi Controller $version"<br />
exec s6-setuidgid $user java -jar lib/ace.jar start<br />
else<br />
echo "Missing $base ... aborting"<br />
touch down<br />
fi<br />
</pre><br />
<br />
Ensure that the <code>run</code> script is executable:<br />
<br />
<code>chmod 755 /etc/unifi/run</code><br />
<br />
Add the <code>log/run</code> script, using your favourite editor.<br />
<br />
<code>vim /etc/unifi/log/run</code><br />
<br />
Copy and paste the following into it.<br />
<br />
<pre><br />
#!/bin/ash<br />
<br />
log_user='log'<br />
<br />
exec s6-setuidgid $log_user s6-log -b n20 s1000000 t /var/log/unifi<br />
</pre><br />
<br />
Ensure that the log/run script is executable:<br />
<br />
<code>chmod 755 /etc/unifi/run</code><br />
<br />
== Create log User and Directory ==<br />
<br />
Create the <code>log</code> user and group.<br />
<br />
<code>adduser -D -H /var/log -g log log</code><br />
<br />
Create the <code>/var/log/unifi</code> directory<br />
<br />
<code>mkdir -p /var/log/unifi</code><br />
<br />
Update the directory ownership.<br />
<br />
<code>chown log:log /var/log/unifi</code><br />
<br />
Lock down the permissions.<br />
<br />
<code>chmod 750 /var/log/unifi</code><br />
<br />
== Create the OpenRC Service Script ==<br />
<br />
Open the script file using your favourite editor.<br />
<br />
<code>vim /etc/init.d/unifi</code><br />
<br />
Paste the following into it.<br />
<br />
<pre><br />
#!/sbin/openrc-run<br />
<br />
name="unifi"<br />
supervisor=s6<br />
s6_service_path="${RC_SVCDIR}/s6-scan/${name}"<br />
<br />
depend() {<br />
need net s6-svscan<br />
after firewall<br />
}<br />
<br />
start_pre() {<br />
if [ ! -L "${RC_SVCDIR}/s6-scan/${name}" ]; then<br />
ln -s "/etc/${name}" "${RC_SVCDIR}/s6-scan/${name}"<br />
fi<br />
}<br />
</pre><br />
<br />
Ensure that the script is executable.<br />
<br />
<code>chmod 755 /etc/init.d/unifi</code><br />
<br />
== Start the UniFi Controller Service ==<br />
<br />
<code>rc-service unifi start</code><br />
<br />
== Configure the UniFi Controller Service to start on boot ==<br />
<br />
<code>rc-update add unifi boot</code><br />
<br />
= Simple Backup Script =<br />
<br />
Create <code>/usr/local/bin/unifi-backup</code> using your favourite editor.<br />
<br />
Paste the following into the file.<br />
<br />
<pre><br />
#!/bin/ash<br />
<br />
conf_dir='/etc/unifi'<br />
backup_dir='/srv/backup/unifi'<br />
service_dir='/run/openrc/s6-scan/unifi'<br />
<br />
start_state='down'<br />
<br />
if s6-svok $service_dir; then<br />
if s6-svstat -o up,ready $service_dir | grep -q true; then<br />
echo 'Stopping the UniFi Controller'<br />
start_state='up'<br />
s6-svc -d $service_dir<br />
sleep 3<br />
fi<br />
else<br />
echo 'Warning: The UniFi Controller is not supervised'<br />
exit 1<br />
fi<br />
<br />
if s6-svstat -o up $service_dir | grep -q false; then<br />
echo 'Success: The UniFi Controller was stopped'<br />
else<br />
echo 'Error: The UniFi Controller is still running'<br />
exit 1<br />
fi<br />
<br />
stamp=`date +%Y-%m-%d_%H%M%S`<br />
<br />
mkdir -p $backup_dir<br />
cd $backup_dir<br />
mkdir "data-$stamp"<br />
<br />
echo "Backing up to /srv/backup/unifi/data-$stamp.tar.gz"<br />
<br />
if rsync -az /srv/unifi/data/ "data-$stamp"; then<br />
echo '* rsync succeeded'<br />
if tar czf "data-$stamp.tar.gz" "data-$stamp"; then<br />
echo '* tar succeeded'<br />
rm -rf "data-$stamp"<br />
echo 'Backup succeeded'<br />
else<br />
echo 'Backup failed: tar failed'<br />
exit 1<br />
fi<br />
fi<br />
<br />
if [ "$start_state" == 'up' ]; then<br />
echo 'Starting the UniFi Controller'<br />
s6-svc -u $service_dir<br />
sleep 5<br />
s6-svstat $service_dir<br />
fi<br />
</pre></div>
Zoot
https://wiki.alpinelinux.org/w/index.php?title=UniFi_Controller&diff=14218
UniFi Controller
2017-12-10T21:49:23Z
<p>Zoot: </p>
<hr />
<div>{{Draft}}<br />
<br />
= Prerequisite Packages =<br />
<br />
== OpenJDK 8 JRE ==<br />
<br />
Install <code>openjdk8-jre</code> from the community repository.<br />
<br />
Edit <code>/etc/apk/respositories</code> and uncomment the appropriate community repository for your Alpine version:<br />
<br />
<code>http://host.name/alpine_version/community</code><br />
<br />
Update the package cache.<br />
<br />
<code>apk update</code><br />
<br />
Install the package.<br />
<br />
<code>apk add openjdk8-jre</code><br />
<br />
== MongoDB ==<br />
<br />
Install MongoDB<br />
<br />
<code>apk add mongodb</code><br />
<br />
== s6 ==<br />
<br />
Install [http://www.skarnet.org/software/s6/ s6]<br />
<br />
<code>apk add s6</code><br />
<br />
= Install UniFi Controller =<br />
<br />
Create the <code>unifi</code> user and group.<br />
<br />
<code>adduser -D -H /srv/unifi -g unifi unifi</code><br />
<br />
Change to the parent folder within which you wish to install the UniFi Controller.<br />
<br />
<code>cd /srv</code><br />
<br />
Download the generic unix archive of the <code>VERSION</code> you wish to install.<br />
<br />
<code>wget http://www.ubnt.com/downloads/unifi/VERSION/UniFi.unix.zip</code><br />
<br />
Unpack the archive.<br />
<br />
<code>unzip UniFi.unix.zip</code><br />
<br />
Rename the unpacked directory.<br />
<br />
<code>mv UniFi unifi</code><br />
<br />
Change ownership.<br />
<br />
<code>chown unifi:unifi unifi</code><br />
<br />
Lock down permissions.<br />
<br />
<code>chmod o-rwx unifi</code><br />
<br />
Change into the UniFi bin directory.<br />
<br />
<code>cd /srv/unifi/bin</code><br />
<br />
Remove the existing file.<br />
<br />
<code>rm mongod</code><br />
<br />
Create a symlink to <code>/usr/bin/mongod</code><br />
<br />
<code>ln -s /usr/bin/mongod</code><br />
<br />
= Configure Service Management =<br />
<br />
== Create UniFi Service Directory and Files ==<br />
<br />
Create an s6 service directory for UniFi.<br />
<br />
<code>mkdir -p /etc/unifi/log</code><br />
<br />
Add the <code>run</code> script, using your favourite editor.<br />
<br />
<code>vim /etc/unifi/run</code><br />
<br />
Copy and paste the following into it.<br />
<br />
<pre><br />
#!/bin/ash<br />
<br />
user='unifi'<br />
group='unifi'<br />
<br />
exec 2>&1<br />
<br />
base='/srv/unifi'<br />
<br />
if [ -d $base ]; then<br />
cd $base<br />
chown -R $user:$group .<br />
version=`head -1 webapps/ROOT/app-unifi/.version`<br />
echo "Starting UniFi Controller $version"<br />
exec s6-setuidgid $user java -jar lib/ace.jar start<br />
else<br />
echo "Missing $base ... aborting"<br />
touch down<br />
fi<br />
</pre><br />
<br />
Ensure that the <code>run</code> script is executable:<br />
<br />
<code>chmod 755 /etc/unifi/run</code><br />
<br />
Add the <code>log/run</code> script, using your favourite editor.<br />
<br />
<code>vim /etc/unifi/log/run</code><br />
<br />
Copy and paste the following into it.<br />
<br />
<pre><br />
#!/bin/ash<br />
<br />
log_user='log'<br />
<br />
exec s6-setuidgid $log_user s6-log -b n20 s1000000 t /var/log/unifi<br />
</pre><br />
<br />
Ensure that the log/run script is executable:<br />
<br />
<code>chmod 755 /etc/unifi/run</code><br />
<br />
== Create log User and Directory ==<br />
<br />
Create the <code>log</code> user and group.<br />
<br />
<code>adduser -D -H /var/log -g log log</code><br />
<br />
Create the <code>/var/log/unifi</code> directory<br />
<br />
<code>mkdir -p /var/log/unifi</code><br />
<br />
Update the directory ownership.<br />
<br />
<code>chown log:log /var/log/unifi</code><br />
<br />
Lock down the permissions.<br />
<br />
<code>chmod 750 /var/log/unifi</code><br />
<br />
== Create the OpenRC Service Script ==<br />
<br />
Open the script file using your favourite editor.<br />
<br />
<code>vim /etc/init.d/unifi</code><br />
<br />
Paste the following into it.<br />
<br />
<pre><br />
#!/sbin/openrc-run<br />
<br />
name="unifi"<br />
supervisor=s6<br />
s6_service_path="${RC_SVCDIR}/s6-scan/${name}"<br />
<br />
depend() {<br />
need net s6-svscan<br />
after firewall<br />
}<br />
<br />
start_pre() {<br />
if [ ! -L "${RC_SVCDIR}/s6-scan/${name}" ]; then<br />
ln -s "/etc/${name}" "${RC_SVCDIR}/s6-scan/${name}"<br />
fi<br />
}<br />
</pre><br />
<br />
Ensure that the script is executable.<br />
<br />
<code>chmod 755 /etc/init.d/unifi</code><br />
<br />
== Start the UniFi Controller Service ==<br />
<br />
<code>rc-service unifi start</code><br />
<br />
== Configure the UniFi Controller Service to start on boot ==<br />
<br />
<code>rc-update add unifi boot</code><br />
<br />
= Simple Backup Script =<br />
<br />
Create <code>/usr/local/bin/unifi-backup</code> using your favourite editor.<br />
<br />
Paste the following into the file.<br />
<br />
<pre><br />
#!/bin/ash<br />
<br />
conf_dir='/etc/unifi'<br />
backup_dir='/srv/backup/unifi'<br />
service_dir='/run/openrc/s6-scan/unifi'<br />
<br />
start_state='down'<br />
<br />
if s6-svok $service_dir; then<br />
if s6-svstat -o up,ready $service_dir | grep -q true; then<br />
echo 'Stopping the UniFi Controller'<br />
start_state='up'<br />
s6-svc -d $service_dir<br />
sleep 3<br />
fi<br />
else<br />
echo 'Warning: The UniFi Controller is not supervised'<br />
exit 1<br />
fi<br />
<br />
if s6-svstat -o up $service_dir | grep -q false; then<br />
echo 'Success: The UniFi Controller was stopped'<br />
else<br />
echo 'Error: The UniFi Controller is still running'<br />
exit 1<br />
fi<br />
<br />
stamp=`date +%Y-%m-%d_%H%M%S`<br />
<br />
mkdir -p $backup_dir<br />
cd $backup_dir<br />
mkdir "data-$stamp"<br />
<br />
echo "Backing up to /srv/backup/unifi/data-$stamp.tar.gz"<br />
<br />
if rsync -az /srv/unifi/data/ "data-$stamp"; then<br />
echo '* rsync succeeded'<br />
if tar czf "data-$stamp.tar.gz" "data-$stamp"; then<br />
echo '* tar succeeded'<br />
rm -rf "data-$stamp"<br />
echo 'Backup succeeded'<br />
else<br />
echo 'Backup failed: tar failed'<br />
exit 1<br />
fi<br />
fi<br />
<br />
if [ "$start_state" == 'up' ]; then<br />
echo 'Starting the UniFi Controller'<br />
s6-svc -u $service_dir<br />
sleep 5<br />
s6-svstat $service_dir<br />
fi<br />
</pre></div>
Zoot
https://wiki.alpinelinux.org/w/index.php?title=UniFi_Controller&diff=14217
UniFi Controller
2017-12-10T21:40:43Z
<p>Zoot: </p>
<hr />
<div>{{Draft}}<br />
<br />
= Prerequisite Packages =<br />
<br />
== OpenJDK 8 JRE ==<br />
<br />
Install <code>openjdk8-jre</code> from the community repository.<br />
<br />
Edit <code>/etc/apk/respositories</code> and uncomment the appropriate community repository for your Alpine version:<br />
<br />
<code>http://host.name/alpine_version/community</code><br />
<br />
Update the package cache.<br />
<br />
<code>apk update</code><br />
<br />
Install the package.<br />
<br />
<code>apk add openjdk8-jre</code><br />
<br />
== MongoDB ==<br />
<br />
Install MongoDB<br />
<br />
<code>apk add mongodb</code><br />
<br />
== s6 ==<br />
<br />
Install [http://www.skarnet.org/software/s6/ s6]<br />
<br />
<code>apk add s6</code><br />
<br />
= Install UniFi Controller =<br />
<br />
Create the <code>unifi</code> user and group.<br />
<br />
<code>adduser -D -H /srv/unifi -g unifi unifi</code><br />
<br />
Change to the parent folder within which you wish to install the UniFi Controller.<br />
<br />
<code>cd /srv</code><br />
<br />
Download the generic unix archive of the <code>VERSION</code> you wish to install.<br />
<br />
<code>wget http://www.ubnt.com/downloads/unifi/VERSION/UniFi.unix.zip</code><br />
<br />
Unpack the archive.<br />
<br />
<code>unzip UniFi.unix.zip</code><br />
<br />
Rename the unpacked directory.<br />
<br />
<code>mv UniFi unifi</code><br />
<br />
Change ownership.<br />
<br />
<code>chown unifi:unifi unifi</code><br />
<br />
Lock down permissions.<br />
<br />
<code>chmod o-rwx unifi</code><br />
<br />
Change into the UniFi bin directory.<br />
<br />
<code>cd /srv/unifi/bin</code><br />
<br />
Remove the existing file.<br />
<br />
<code>rm mongod</code><br />
<br />
Create a symlink to <code>/usr/bin/mongod</code><br />
<br />
<code>ln -s /usr/bin/mongod</code><br />
<br />
= Configure Service Management =<br />
<br />
== Create UniFi Service Directory and Files ==<br />
<br />
Create an s6 service directory for UniFi.<br />
<br />
<code>mkdir -p /etc/unifi/log</code><br />
<br />
Add the <code>run</code> script, using your favourite editor.<br />
<br />
<code>vim /etc/unifi/run</code><br />
<br />
Copy and paste the following into it.<br />
<br />
<pre><br />
#!/bin/ash<br />
<br />
user='unifi'<br />
group='unifi'<br />
<br />
exec 2>&1<br />
<br />
base='/srv/unifi'<br />
<br />
if [ -d $base ]; then<br />
cd $base<br />
chown -R $user:$group .<br />
version=`head -1 webapps/ROOT/app-unifi/.version`<br />
echo "Starting UniFi Controller $version"<br />
exec s6-setuidgid $user java -jar lib/ace.jar start<br />
else<br />
echo "Missing $base ... aborting"<br />
touch down<br />
fi<br />
</pre><br />
<br />
Ensure that the <code>run</code> script is executable:<br />
<br />
<code>chmod 755 /etc/unifi/run</code><br />
<br />
Add the <code>log/run</code> script, using your favourite editor.<br />
<br />
<code>vim /etc/unifi/log/run</code><br />
<br />
Copy and paste the following into it.<br />
<br />
<pre><br />
#!/bin/ash<br />
<br />
log_user='log'<br />
<br />
exec s6-setuidgid $log_user s6-log -b n20 s1000000 t /var/log/unifi<br />
</pre><br />
<br />
Ensure that the log/run script is executable:<br />
<br />
<code>chmod 755 /etc/unifi/run</code><br />
<br />
== Create log User and Directory<br />
<br />
Create the <code>log</code> user and group.<br />
<br />
<code>adduser -D -H /var/log -g log log</code><br />
<br />
Create the <code>/var/log/unifi</code> directory<br />
<br />
<code>mkdir -p /var/log/unifi</code><br />
<br />
Update the directory ownership.<br />
<br />
<code>chown log:log /var/log/unifi</code><br />
<br />
Lock down the permissions.<br />
<br />
<code>chmod 750 /var/log/unifi</code><br />
<br />
== Create the OpenRC Service Script ==<br />
<br />
Open the script file using your favourite editor.<br />
<br />
<code>vim /etc/init.d/unifi</code><br />
<br />
Paste the following into it.<br />
<br />
<pre><br />
#!/sbin/openrc-run<br />
<br />
name="unifi"<br />
supervisor=s6<br />
s6_service_path="${RC_SVCDIR}/s6-scan/${name}"<br />
<br />
depend() {<br />
need net s6-svscan<br />
after firewall<br />
}<br />
<br />
start_pre() {<br />
if [ ! -L "${RC_SVCDIR}/s6-scan/${name}" ]; then<br />
ln -s "/etc/${name}" "${RC_SVCDIR}/s6-scan/${name}"<br />
fi<br />
}<br />
</pre><br />
<br />
Ensure that the script is executable.<br />
<br />
<code>chmod 755 /etc/init.d/unifi</code></div>
Zoot
https://wiki.alpinelinux.org/w/index.php?title=UniFi_Controller&diff=14216
UniFi Controller
2017-12-10T21:31:02Z
<p>Zoot: </p>
<hr />
<div>{{Draft}}<br />
<br />
= Prerequisite Packages =<br />
<br />
== OpenJDK 8 JRE ==<br />
<br />
Install <code>openjdk8-jre</code> from the community repository.<br />
<br />
Edit /etc/apk/respositories and uncomment the appropriate community repository for your Alpine version:<br />
<br />
<code>http://host.name/alpine_version/community</code><br />
<br />
Update the package cache.<br />
<br />
<code>apk update</code><br />
<br />
Install the package.<br />
<br />
<code>apk add openjdk8-jre</code><br />
<br />
== MongoDB ==<br />
<br />
Install MongoDB<br />
<br />
<code>apk add mongodb</code><br />
<br />
== s6 ==<br />
<br />
Install [http://www.skarnet.org/software/s6/ s6]<br />
<br />
<code>apk add s6</code><br />
<br />
= Install UniFi Controller =<br />
<br />
Create the <code>unifi</code> user and group.<br />
<br />
<code>adduser -D -H /srv/unifi -g unifi unifi</code><br />
<br />
Change to the parent folder within which you wish to install the UniFi Controller.<br />
<br />
<code>cd /srv</code><br />
<br />
Download the generic unix archive of the <code>VERSION</code> you wish to install.<br />
<br />
<code>wget http://www.ubnt.com/downloads/unifi/VERSION/UniFi.unix.zip</code><br />
<br />
Unpack the archive.<br />
<br />
<code>unzip UniFi.unix.zip</code><br />
<br />
Rename the unpacked directory.<br />
<br />
<code>mv UniFi unifi</code><br />
<br />
Change ownership.<br />
<br />
<code>chown unifi:unifi unifi</code><br />
<br />
Lock down permissions.<br />
<br />
<code>chmod o-rwx unifi</code><br />
<br />
= Service Management =<br />
<br />
Create an s6 service directory for UniFi.<br />
<br />
<code>mkdir -p /etc/unifi/log</code><br />
<br />
Add the <code>run</code> script, using your favourite editor.<br />
<br />
<code>vim /etc/unifi/run</code><br />
<br />
Copy and paste the following into it.<br />
<br />
<pre><br />
#!/bin/ash<br />
<br />
user='unifi'<br />
group='unifi'<br />
<br />
exec 2>&1<br />
<br />
base='/srv/unifi'<br />
<br />
if [ -d $base ]; then<br />
cd $base<br />
chown -R $user:$group .<br />
version=`head -1 webapps/ROOT/app-unifi/.version`<br />
echo "Starting UniFi Controller $version"<br />
exec s6-setuidgid $user java -jar lib/ace.jar start<br />
else<br />
echo "Missing $base ... aborting"<br />
touch down<br />
fi<br />
</pre><br />
<br />
Ensure that the <code>run</code> script is executable:<br />
<br />
<code>chmod 755 /etc/unifi/run</code><br />
<br />
Add the <code>log/run</code> script, using your favourite editor.<br />
<br />
<code>vim /etc/unifi/log/run</code><br />
<br />
Copy and paste the following into it.<br />
<br />
<pre><br />
#!/bin/ash<br />
<br />
log_user='log'<br />
<br />
exec s6-setuidgid $log_user s6-log -b n20 s1000000 t /var/log/unifi<br />
</pre><br />
<br />
Ensure that the log/run script is executable:<br />
<br />
<code>chmod 755 /etc/unifi/run</code><br />
<br />
Create the <code>log</code> user and group.<br />
<br />
<code>adduser -D -H /var/log -g log log</code><br />
<br />
Create the <code>/var/log/unifi</code> directory<br />
<br />
<code>mkdir -p /var/log/unifi</code><br />
<br />
Update the directory ownership.<br />
<br />
<code>chown log:log /var/log/unifi</code><br />
<br />
Lock down the permissions.<br />
<br />
<code>chmod 750 /var/log/unifi</code></div>
Zoot
https://wiki.alpinelinux.org/w/index.php?title=UniFi_Controller&diff=14215
UniFi Controller
2017-12-10T21:29:54Z
<p>Zoot: </p>
<hr />
<div>{{Draft}}<br />
<br />
= Prerequisite Packages =<br />
<br />
== OpenJDK 8 JRE ==<br />
<br />
Install <code>openjdk8-jre</code> from the community repository.<br />
<br />
Edit /etc/apk/respositories and uncomment the appropriate community repository for your Alpine version:<br />
<br />
<code>http://host.name/alpine_version/community</code><br />
<br />
Update the package cache.<br />
<br />
<code>apk update</code><br />
<br />
Install the package.<br />
<br />
<code>apk add openjdk8-jre</code><br />
<br />
== MongoDB ==<br />
<br />
Install MongoDB<br />
<br />
<code>apk add mongodb</code><br />
<br />
== s6 ==<br />
<br />
Install [http://www.skarnet.org/software/s6/ s6]<br />
<br />
<code>apk add s6</code><br />
<br />
= Install UniFi Controller =<br />
<br />
Create the <code>unifi</code> user and group.<br />
<br />
<code>adduser -D -H /srv/unifi -g unifi unifi</code><br />
<br />
Change to the parent folder within which you wish to install the UniFi Controller.<br />
<br />
<code>cd /srv</code><br />
<br />
Download the generic unix archive of the <code>VERSION</code> you wish to install.<br />
<br />
<code>wget http://www.ubnt.com/downloads/unifi/VERSION/UniFi.unix.zip</code><br />
<br />
Unpack the archive.<br />
<br />
<code>unzip UniFi.unix.zip</code><br />
<br />
Rename the unpacked directory.<br />
<br />
<code>mv UniFi unifi</code><br />
<br />
Change ownership.<br />
<br />
<code>chown unifi:unifi unifi</code><br />
<br />
Lock down permissions.<br />
<br />
<code>chmod o-rwx unifi</code><br />
<br />
= Service Management =<br />
<br />
Create an s6 service directory for UniFi.<br />
<br />
<code>mkdir -p /etc/unifi/log</code><br />
<br />
Add the <code>run</code> script, using your favourite editor.<br />
<br />
<code>vim /etc/unifi/run</code><br />
<br />
Copy and paste the following into it.<br />
<br />
<pre><br />
#!/bin/ash<br />
<br />
user='unifi'<br />
group='unifi'<br />
<br />
exec 2>&1<br />
<br />
base='/srv/unifi'<br />
<br />
if [ -d $base ]; then<br />
cd $base<br />
chown -R $user:$group .<br />
version=`head -1 webapps/ROOT/app-unifi/.version`<br />
echo "Starting UniFi Controller $version"<br />
exec s6-setuidgid $user java -jar lib/ace.jar start<br />
else<br />
echo "Missing $base ... aborting"<br />
touch down<br />
fi<br />
</pre><br />
<br />
Ensure that the run script is executable:<br />
<br />
<code>chmod 755 /etc/unifi/run</code><br />
<br />
Add the <code>log/run</code> script, using your favourite editor.<br />
<br />
<code>vim /etc/unifi/log/run</code><br />
<br />
Copy and paste the following into it.<br />
<br />
<pre><br />
#!/bin/ash<br />
<br />
log_user='log'<br />
<br />
exec s6-setuidgid $log_user s6-log -b n20 s1000000 t /var/log/unifi<br />
</pre><br />
<br />
Ensure that the log/run script is executable:<br />
<br />
<code>chmod 755 /etc/unifi/run</code><br />
<br />
Create the <code>log</code> user and group.<br />
<br />
<code>adduser -D -H /var/log -g log log</code><br />
<br />
Create the <code>/var/log/unifi</code> directory<br />
<br />
<code>mkdir -p /var/log/unifi</code><br />
<br />
Update the directory ownership.<br />
<br />
<code>chown log:log /var/log/unifi</code><br />
<br />
Lock down the permissions.<br />
<br />
<code>chmod 750 /var/log/unifi</code></div>
Zoot
https://wiki.alpinelinux.org/w/index.php?title=UniFi_Controller&diff=14214
UniFi Controller
2017-12-10T21:25:58Z
<p>Zoot: </p>
<hr />
<div>{{Draft}}<br />
<br />
= Prerequisite Packages =<br />
<br />
== OpenJDK 8 JRE ==<br />
<br />
Install <code>openjdk8-jre</code> from the community repository.<br />
<br />
Edit /etc/apk/respositories and uncomment the appropriate community repository for your Alpine version:<br />
<br />
<code>http://host.name/alpine_version/community</code><br />
<br />
Update the package cache.<br />
<br />
<code>apk update</code><br />
<br />
Install the package.<br />
<br />
<code>apk add openjdk8-jre</code><br />
<br />
== MongoDB ==<br />
<br />
Install MongoDB<br />
<br />
<code>apk add mongodb</code><br />
<br />
== s6 ==<br />
<br />
Install [http://www.skarnet.org/software/s6/ s6]<br />
<br />
<code>apk add s6</code><br />
<br />
= Install UniFi Controller =<br />
<br />
Create the <code>unifi</code> user and group.<br />
<br />
<code>adduser -D -H /srv/unifi -g unifi unifi</code><br />
<br />
Change to the parent folder within which you wish to install the UniFi Controller.<br />
<br />
<code>cd /srv</code><br />
<br />
Download the generic unix archive of the <code>VERSION</code> you wish to install.<br />
<br />
<code>wget http://www.ubnt.com/downloads/unifi/VERSION/UniFi.unix.zip</code><br />
<br />
Unpack the archive.<br />
<br />
<code>unzip UniFi.unix.zip</code><br />
<br />
Rename the unpacked directory.<br />
<br />
<code>mv UniFi unifi</code><br />
<br />
Change ownership.<br />
<br />
<code>chown unifi:unifi unifi</code><br />
<br />
Lock down permissions.<br />
<br />
<code>chmod o-rwx unifi</code><br />
<br />
= Service Management =<br />
<br />
Create an s6 service directory for UniFi.<br />
<br />
<code>mkdir -p /etc/unifi/log</code><br />
<br />
Add the <code>run</code> script, using your favourite editor.<br />
<br />
<code>vim /etc/unifi/run</code><br />
<br />
Copy and paste the following into it.<br />
<br />
<pre><br />
#!/bin/ash<br />
<br />
user='unifi'<br />
group='unifi'<br />
<br />
exec 2>&1<br />
<br />
base='/srv/unifi'<br />
<br />
if [ -d $base ]; then<br />
cd $base<br />
chown -R $user:$group .<br />
version=`head -1 webapps/ROOT/app-unifi/.version`<br />
echo "Starting UniFi Controller $version"<br />
exec s6-setuidgid $user java -jar lib/ace.jar start<br />
else<br />
echo "Missing $base ... aborting"<br />
touch down<br />
fi<br />
</pre><br />
<br />
Ensure that the run script is executable:<br />
<br />
<code>chmod 755 /etc/unifi/run</code><br />
<br />
Add the <code>log/run</code> script, using your favourite editor.<br />
<br />
<code>vim /etc/unifi/log/run</code><br />
<br />
Copy and paste the following into it.<br />
<br />
<pre><br />
#!/bin/ash<br />
<br />
log_user='log'<br />
<br />
exec s6-setuidgid $log_user s6-log -b n20 s1000000 t /var/log/unifi<br />
</pre><br />
<br />
Ensure that the log/run script is executable:<br />
<br />
<code>chmod 755 /etc/unifi/run</code><br />
<br />
Add the <code>log</code> user</div>
Zoot
https://wiki.alpinelinux.org/w/index.php?title=UniFi_Controller&diff=14213
UniFi Controller
2017-12-10T21:16:59Z
<p>Zoot: </p>
<hr />
<div>{{Draft}}<br />
<br />
= Install Prerequisites =<br />
<br />
== OpenJDK 8 JRE ==<br />
<br />
Install <code>openjdk8-jre</code> from the community repository.<br />
<br />
Edit /etc/apk/respositories and uncomment the appropriate community repository for your Alpine version:<br />
<br />
<code>http://host.name/alpine_version/community</code><br />
<br />
Update the package cache.<br />
<br />
<code>apk update</code><br />
<br />
Install the package.<br />
<br />
<code>apk add openjdk8-jre</code><br />
<br />
== MongoDB ==<br />
<br />
Install MongoDB<br />
<br />
<code>apk add mongodb</code><br />
<br />
== s6 ==<br />
<br />
Install [http://www.skarnet.org/software/s6/ s6]<br />
<br />
<code>apk add s6</code><br />
<br />
= Install UniFi Controller =<br />
<br />
Create the <code>unifi</code> user and group.<br />
<br />
<code>adduser -D -H /srv/unifi -g unifi unifi</code><br />
<br />
Change to the parent folder within which you wish to install the UniFi Controller.<br />
<br />
<code>cd /srv</code><br />
<br />
Download the generic unix archive of the <code>VERSION</code> you wish to install.<br />
<br />
<code>wget http://www.ubnt.com/downloads/unifi/VERSION/UniFi.unix.zip</code><br />
<br />
Unpack the archive.<br />
<br />
<code>unzip UniFi.unix.zip</code><br />
<br />
Rename the unpacked directory.<br />
<br />
<code>mv UniFi unifi</code><br />
<br />
Change ownership.<br />
<br />
<code>chown unifi:unifi unifi</code><br />
<br />
Lock down permissions.<br />
<br />
<code>chmod o-rwx unifi</code><br />
<br />
= Service Management =</div>
Zoot
https://wiki.alpinelinux.org/w/index.php?title=UniFi_Controller&diff=14212
UniFi Controller
2017-12-10T21:15:24Z
<p>Zoot: Created page with "= Prerequisites = == OpenJDK 8 JRE == Install <code>openjdk8-jre</code> from the community repository. Edit /etc/apk/respositories and uncomment the appropriate community r..."</p>
<hr />
<div>= Prerequisites =<br />
<br />
== OpenJDK 8 JRE ==<br />
<br />
Install <code>openjdk8-jre</code> from the community repository.<br />
<br />
Edit /etc/apk/respositories and uncomment the appropriate community repository for your Alpine version:<br />
<br />
<code>http://host.name/alpine_version/community</code><br />
<br />
Update the package cache.<br />
<br />
<code>apk update</code><br />
<br />
Install the package.<br />
<br />
<code>apk add openjdk8-jre</code><br />
<br />
== MongoDB ==<br />
<br />
Install MongoDB<br />
<br />
<code>apk add mongodb</code><br />
<br />
== s6 ==<br />
<br />
Install [http://www.skarnet.org/software/s6/ s6]<br />
<br />
<code>apk add s6</code><br />
<br />
= Installation =<br />
<br />
Create the <code>unifi</code> user and group.<br />
<br />
<code>adduser -D -H /srv/unifi -g unifi unifi</code><br />
<br />
Change to the parent folder within which you wish to install the UniFi Controller.<br />
<br />
<code>cd /srv</code><br />
<br />
Download the generic unix archive of the <code>VERSION</code> you wish to install.<br />
<br />
<code>wget http://www.ubnt.com/downloads/unifi/VERSION/UniFi.unix.zip</code><br />
<br />
Unpack the archive.<br />
<br />
<code>unzip UniFi.unix.zip</code><br />
<br />
Rename the unpacked directory.<br />
<br />
<code>mv UniFi unifi</code><br />
<br />
Change ownership.<br />
<br />
<code>chown unifi:unifi unifi</code><br />
<br />
Lock down permissions.<br />
<br />
<code>chmod o-rwx unifi</code><br />
<br />
= Service Management =</div>
Zoot
https://wiki.alpinelinux.org/w/index.php?title=Writing_Init_Scripts&diff=14211
Writing Init Scripts
2017-12-10T20:36:49Z
<p>Zoot: /* Services supervised by s6 */</p>
<hr />
<div>{{Draft}}<br />
<br />
== Introduction ==<br />
<br />
Alpine Linux uses the [https://github.com/OpenRC/openrc OpenRC] init system to start services. Don't confuse OpenRC init with out system init (the first process that is executed aka pid 1). Many of the current init.d script found in Alpine Linux are takes from Gentoo. If you want to save time you could search [https://packages.gentoo.org/categories Gentoo's repository] for an existing initscript for your service. You can also check [https://wiki.gentoo.org/wiki/Handbook:X86/Working/Initscripts#Writing_initscripts Gentoo's wiki] for some additional OpenRC information.<br />
<br />
If you cannot find an init.d script from Gentoo, or you just want to start to write your own init.d scripts, we provide you with some basic information on how to write simple OpenRC init scripts.<br />
<br />
Primary information about the OpenRC format can be found in the [http://manpages.org/openrc-run/8 OpenRC man page openrc-run].<br />
<br />
<code>apk add openrc-doc man</code><br />
<br />
<code>man openrc-run</code><br />
<br />
== Minimal Templates ==<br />
<br />
Every init.d script you write needs to start with a [https://en.wikipedia.org/wiki/Shebang_(Unix) shebang] like:<br />
<br />
<code>#!/sbin/openrc-run</code><br />
<br />
=== Services relying on OpenRC exclusively ===<br />
<br />
<pre><br />
#!/sbin/openrc-run<br />
<br />
command="/path/to/command"<br />
</pre><br />
<br />
=== Services supervised by [http://www.skarnet.org/software/s6/ s6] ===<br />
<br />
Notes:<br />
<br />
* Install and configure the <code>s6-scan</code> service to start on system boot<br />
* Exclude <code>start()</code>, <code>stop()</code> and <code>status()</code> functions in order for s6 supervision to work reliably. OpenRC has built-in equivalent functions which invoke the necessary s6 commands.<br />
* Include a <code>depend()</code> stanza to ensure that the <code>s6-svscan</code> service is already running.<br />
* Add a <code>start_pre()</code> stanza to symlink the service directory into the scan directory, because the <code>/etc/init.d/bootmisc</code> scripts cleans out the <code>/run</code> directory on system boot.<br />
<br />
<pre><br />
#!/sbin/openrc-run<br />
<br />
name="foo"<br />
supervisor="s6"<br />
s6_service_path="${RC_SVCDIR}/s6-scan/${name}"<br />
<br />
depend() {<br />
need s6-svscan<br />
}<br />
<br />
start_pre() {<br />
if [ ! -L "${RC_SVC_DIR}/s6-scan/${name}" ]; then<br />
ln -s "/path/to/${name}/service/dir" "${RC_SVCDIR}/s6-scan/${name}"<br />
fi<br />
}<br />
</pre><br />
<br />
The rest of the below basic example could be omitted, but that would most probably leave you with an non working initd script.<br />
<br />
== Basic example ==<br />
<br />
<pre><br />
#!/sbin/openrc-run<br />
<br />
name=$RC_SVCNAME<br />
cfgfile="/etc/$RC_SVCNAME/$RC_SVCNAME.conf"<br />
command="/usr/bin/my_daemon"<br />
command_args="--my-daemon-args"<br />
command_user="my_system_user"<br />
pidfile="/run/$RC_SVCNAME/$RC_SVCNAME.pid"<br />
start_stop_daemon_args="--args-for-start-stop-daemon"<br />
command_background="yes"<br />
<br />
depend() {<br />
need net<br />
}<br />
<br />
start_pre() {<br />
checkpath --directory --owner $command_user:$command_user --mode 0775 \<br />
/run/$RC_SVCNAME /var/log/$RC_SVCNAME<br />
}<br />
</pre><br />
<br />
== start, stop, restart functions ==<br />
<br />
OpenRC defined a few basic functions ie: start, stop, restart. These functions are defined by default but can be overwritten by defining your own set of functions.<br />
This is generally only necessary if you want to do something special which is not provided by the default start/stop/restart implementations.<br />
<br />
=== start ===<br />
<br />
<pre><br />
start() {<br />
ebegin "Starting mydaemon"<br />
start-stop-daemon --start \<br />
--exec /usr/sbin/mydaemon \<br />
--pidfile /var/run/mydaemon.pid \<br />
-- \<br />
--args-for-mydaemon<br />
eend $?<br />
}<br />
</pre><br />
<br />
=== stop ===<br />
<br />
=== restart ===<br />
<br />
== Daemon, Forking, Logging ==<br />
<br />
TODO...<br />
<br />
[[Category:Booting]]</div>
Zoot
https://wiki.alpinelinux.org/w/index.php?title=Writing_Init_Scripts&diff=14210
Writing Init Scripts
2017-12-10T20:22:00Z
<p>Zoot: /* Mandatory */</p>
<hr />
<div>{{Draft}}<br />
<br />
== Introduction ==<br />
<br />
Alpine Linux uses the [https://github.com/OpenRC/openrc OpenRC] init system to start services. Don't confuse OpenRC init with out system init (the first process that is executed aka pid 1). Many of the current init.d script found in Alpine Linux are takes from Gentoo. If you want to save time you could search [https://packages.gentoo.org/categories Gentoo's repository] for an existing initscript for your service. You can also check [https://wiki.gentoo.org/wiki/Handbook:X86/Working/Initscripts#Writing_initscripts Gentoo's wiki] for some additional OpenRC information.<br />
<br />
If you cannot find an init.d script from Gentoo, or you just want to start to write your own init.d scripts, we provide you with some basic information on how to write simple OpenRC init scripts.<br />
<br />
Primary information about the OpenRC format can be found in the [http://manpages.org/openrc-run/8 OpenRC man page openrc-run].<br />
<br />
<code>apk add openrc-doc man</code><br />
<br />
<code>man openrc-run</code><br />
<br />
== Minimal Templates ==<br />
<br />
Every init.d script you write needs to start with a [https://en.wikipedia.org/wiki/Shebang_(Unix) shebang] like:<br />
<br />
<code>#!/sbin/openrc-run</code><br />
<br />
=== Services relying on OpenRC exclusively ===<br />
<br />
<pre><br />
#!/sbin/openrc-run<br />
<br />
command="/path/to/command"<br />
</pre><br />
<br />
=== Services supervised by [http://www.skarnet.org/software/s6/ s6] ===<br />
<br />
Note that you must '''exclude start, stop and status functions''' in order for s6 supervision to work, as OpenRC has replacement functions for these which interact reliably with the various s6 commands, without having to call them explicitly.<br />
<br />
<pre><br />
#!/sbin/openrc-run<br />
<br />
name="foo"<br />
supervisor="s6"<br />
s6_service_path="${RC_SVCDIR}/s6-scan/${name}"<br />
<br />
depend() {<br />
need s6-svscan<br />
}<br />
</pre><br />
<br />
The rest of the below basic example could be omitted, but that would most probably leave you with an non working initd script.<br />
<br />
== Basic example ==<br />
<br />
<pre><br />
#!/sbin/openrc-run<br />
<br />
name=$RC_SVCNAME<br />
cfgfile="/etc/$RC_SVCNAME/$RC_SVCNAME.conf"<br />
command="/usr/bin/my_daemon"<br />
command_args="--my-daemon-args"<br />
command_user="my_system_user"<br />
pidfile="/run/$RC_SVCNAME/$RC_SVCNAME.pid"<br />
start_stop_daemon_args="--args-for-start-stop-daemon"<br />
command_background="yes"<br />
<br />
depend() {<br />
need net<br />
}<br />
<br />
start_pre() {<br />
checkpath --directory --owner $command_user:$command_user --mode 0775 \<br />
/run/$RC_SVCNAME /var/log/$RC_SVCNAME<br />
}<br />
</pre><br />
<br />
== start, stop, restart functions ==<br />
<br />
OpenRC defined a few basic functions ie: start, stop, restart. These functions are defined by default but can be overwritten by defining your own set of functions.<br />
This is generally only necessary if you want to do something special which is not provided by the default start/stop/restart implementations.<br />
<br />
=== start ===<br />
<br />
<pre><br />
start() {<br />
ebegin "Starting mydaemon"<br />
start-stop-daemon --start \<br />
--exec /usr/sbin/mydaemon \<br />
--pidfile /var/run/mydaemon.pid \<br />
-- \<br />
--args-for-mydaemon<br />
eend $?<br />
}<br />
</pre><br />
<br />
=== stop ===<br />
<br />
=== restart ===<br />
<br />
== Daemon, Forking, Logging ==<br />
<br />
TODO...<br />
<br />
[[Category:Booting]]</div>
Zoot
https://wiki.alpinelinux.org/w/index.php?title=Writing_Init_Scripts&diff=14209
Writing Init Scripts
2017-12-10T20:21:14Z
<p>Zoot: /* Mandatory */</p>
<hr />
<div>{{Draft}}<br />
<br />
== Introduction ==<br />
<br />
Alpine Linux uses the [https://github.com/OpenRC/openrc OpenRC] init system to start services. Don't confuse OpenRC init with out system init (the first process that is executed aka pid 1). Many of the current init.d script found in Alpine Linux are takes from Gentoo. If you want to save time you could search [https://packages.gentoo.org/categories Gentoo's repository] for an existing initscript for your service. You can also check [https://wiki.gentoo.org/wiki/Handbook:X86/Working/Initscripts#Writing_initscripts Gentoo's wiki] for some additional OpenRC information.<br />
<br />
If you cannot find an init.d script from Gentoo, or you just want to start to write your own init.d scripts, we provide you with some basic information on how to write simple OpenRC init scripts.<br />
<br />
Primary information about the OpenRC format can be found in the [http://manpages.org/openrc-run/8 OpenRC man page openrc-run].<br />
<br />
<code>apk add openrc-doc man</code><br />
<br />
<code>man openrc-run</code><br />
<br />
== Mandatory ==<br />
<br />
Every init.d script you write needs to start with a [https://en.wikipedia.org/wiki/Shebang_(Unix) shebang] like:<br />
<br />
<code>#!/sbin/openrc-run</code><br />
<br />
=== Minimal template for services relying on OpenRC exclusively ===<br />
<br />
<pre><br />
#!/sbin/openrc-run<br />
<br />
command="/path/to/command"<br />
</pre><br />
<br />
=== Minimal template for services supervised by [http://www.skarnet.org/software/s6/ s6] ===<br />
<br />
Note that you must '''exclude start, stop and status functions''' in order for s6 supervision to work, as OpenRC has replacement functions for these which interact reliably with the various s6 commands, without having to call them explicitly.<br />
<br />
<pre><br />
#!/sbin/openrc-run<br />
<br />
name="foo"<br />
supervisor="s6"<br />
s6_service_path="${RC_SVCDIR}/s6-scan/${name}"<br />
<br />
depend() {<br />
need s6-svscan<br />
}<br />
</pre><br />
<br />
The rest of the below basic example could be omitted, but that would most probably leave you with an non working initd script.<br />
<br />
== Basic example ==<br />
<br />
<pre><br />
#!/sbin/openrc-run<br />
<br />
name=$RC_SVCNAME<br />
cfgfile="/etc/$RC_SVCNAME/$RC_SVCNAME.conf"<br />
command="/usr/bin/my_daemon"<br />
command_args="--my-daemon-args"<br />
command_user="my_system_user"<br />
pidfile="/run/$RC_SVCNAME/$RC_SVCNAME.pid"<br />
start_stop_daemon_args="--args-for-start-stop-daemon"<br />
command_background="yes"<br />
<br />
depend() {<br />
need net<br />
}<br />
<br />
start_pre() {<br />
checkpath --directory --owner $command_user:$command_user --mode 0775 \<br />
/run/$RC_SVCNAME /var/log/$RC_SVCNAME<br />
}<br />
</pre><br />
<br />
== start, stop, restart functions ==<br />
<br />
OpenRC defined a few basic functions ie: start, stop, restart. These functions are defined by default but can be overwritten by defining your own set of functions.<br />
This is generally only necessary if you want to do something special which is not provided by the default start/stop/restart implementations.<br />
<br />
=== start ===<br />
<br />
<pre><br />
start() {<br />
ebegin "Starting mydaemon"<br />
start-stop-daemon --start \<br />
--exec /usr/sbin/mydaemon \<br />
--pidfile /var/run/mydaemon.pid \<br />
-- \<br />
--args-for-mydaemon<br />
eend $?<br />
}<br />
</pre><br />
<br />
=== stop ===<br />
<br />
=== restart ===<br />
<br />
== Daemon, Forking, Logging ==<br />
<br />
TODO...<br />
<br />
[[Category:Booting]]</div>
Zoot
https://wiki.alpinelinux.org/w/index.php?title=Writing_Init_Scripts&diff=14208
Writing Init Scripts
2017-12-10T20:13:36Z
<p>Zoot: /* Mandatory */</p>
<hr />
<div>{{Draft}}<br />
<br />
== Introduction ==<br />
<br />
Alpine Linux uses the [https://github.com/OpenRC/openrc OpenRC] init system to start services. Don't confuse OpenRC init with out system init (the first process that is executed aka pid 1). Many of the current init.d script found in Alpine Linux are takes from Gentoo. If you want to save time you could search [https://packages.gentoo.org/categories Gentoo's repository] for an existing initscript for your service. You can also check [https://wiki.gentoo.org/wiki/Handbook:X86/Working/Initscripts#Writing_initscripts Gentoo's wiki] for some additional OpenRC information.<br />
<br />
If you cannot find an init.d script from Gentoo, or you just want to start to write your own init.d scripts, we provide you with some basic information on how to write simple OpenRC init scripts.<br />
<br />
Primary information about the OpenRC format can be found in the [http://manpages.org/openrc-run/8 OpenRC man page openrc-run].<br />
<br />
<code>apk add openrc-doc man</code><br />
<br />
<code>man openrc-run</code><br />
<br />
== Mandatory ==<br />
<br />
Every init.d script you write needs to start with a [https://en.wikipedia.org/wiki/Shebang_(Unix) shebang] like:<br />
<br />
<code>#!/sbin/openrc-run</code><br />
<br />
For services relying on OpenRC exclusively, the only mandatory variable is:<br />
<br />
<code>command="/path/to/command"</code><br />
<br />
For services supervised by [http://www.skarnet.org/software/s6/ s6], the following minimal template should be used:<br />
<br />
<pre><br />
name="foo"<br />
supervisor="s6"<br />
s6_service_path="${RC_SVCDIR}/s6-scan/${name}"<br />
<br />
depend() {<br />
need s6-svscan<br />
}<br />
</pre><br />
<br />
The rest of the below basic example could be omitted, but that would most probably leave you with an non working initd script.<br />
<br />
== Basic example ==<br />
<br />
<pre><br />
#!/sbin/openrc-run<br />
<br />
name=$RC_SVCNAME<br />
cfgfile="/etc/$RC_SVCNAME/$RC_SVCNAME.conf"<br />
command="/usr/bin/my_daemon"<br />
command_args="--my-daemon-args"<br />
command_user="my_system_user"<br />
pidfile="/run/$RC_SVCNAME/$RC_SVCNAME.pid"<br />
start_stop_daemon_args="--args-for-start-stop-daemon"<br />
command_background="yes"<br />
<br />
depend() {<br />
need net<br />
}<br />
<br />
start_pre() {<br />
checkpath --directory --owner $command_user:$command_user --mode 0775 \<br />
/run/$RC_SVCNAME /var/log/$RC_SVCNAME<br />
}<br />
</pre><br />
<br />
== start, stop, restart functions ==<br />
<br />
OpenRC defined a few basic functions ie: start, stop, restart. These functions are defined by default but can be overwritten by defining your own set of functions.<br />
This is generally only necessary if you want to do something special which is not provided by the default start/stop/restart implementations.<br />
<br />
=== start ===<br />
<br />
<pre><br />
start() {<br />
ebegin "Starting mydaemon"<br />
start-stop-daemon --start \<br />
--exec /usr/sbin/mydaemon \<br />
--pidfile /var/run/mydaemon.pid \<br />
-- \<br />
--args-for-mydaemon<br />
eend $?<br />
}<br />
</pre><br />
<br />
=== stop ===<br />
<br />
=== restart ===<br />
<br />
== Daemon, Forking, Logging ==<br />
<br />
TODO...<br />
<br />
[[Category:Booting]]</div>
Zoot
https://wiki.alpinelinux.org/w/index.php?title=Setting_up_a_samba-ad-dc&diff=14145
Setting up a samba-ad-dc
2017-11-21T11:51:15Z
<p>Zoot: /* MS-SNTP signing support */ - include restarting chronyd after upgrade</p>
<hr />
<div>= Notes =<br />
<br />
==== Active Directory Naming ====<br />
<br />
In all examples below, replace EXAMPLE with your NetBIOS domain name in caps, example.com with your DNS domain name, HOSTNAME with your system's host name in caps, and hostname with your system's host name.<br />
<br />
Refer to the [https://wiki.samba.org/index.php/Active_Directory_Naming_FAQ Active Directory naming FAQ] before choosing your domain name. <br />
<br />
==== MS-SNTP signing support ====<br />
<br />
AD Domain time sync requires MS-SNTP signing support, so be sure to check whether the NTP server you choose to deploy, does support it.<br />
<br />
<span style="color:red">Some of the NTP server versions available in the Alpine repositories (chrony, openntpd, busybox) do not currently support it. This will cause time sync issues for the domain, so be forewarned.</span><br />
<br />
NTP implementations which do support MS-SNTP signing:<br />
<br />
* chrony (version >= 3.2) [https://pkgs.alpinelinux.org/packages?name=chrony&branch=edge&repo=&arch=&maintainer= Alpine package in edge] [https://git.tuxfamily.org/chrony/chrony.git/tag/?h=3.2 Source download v3.2] [https://git.tuxfamily.org/chrony/chrony.git/commit/?h=3.2&id=577aed484207addd054441ee8be7e6e30ce36cb2 - Source code commit]<br />
* The ntp.org "ntpd" server [http://ntp.org/downloads.html - Download ntpd]<br />
* Windows<br />
<br />
'''Install Chrony version 3.2 on Alpine 3.6.2:'''<br />
<br />
Uncomment and pin the edge/main repository in /etc/apk/repositories<br />
<br />
Note that the below URLs are invalid and used for illustrative purposes only. Replace with the valid repository URLs used by your installation.<br />
<br />
See [https://wiki.alpinelinux.org/wiki/Alpine_Linux_package_management#Repository_pinning Package Repository Pinning] for further details.<br />
<br />
<pre><br />
http://mirror/alpine/v3.6/main<br />
@edge http://mirror/alpine/edge/main<br />
</pre><br />
<br />
Update the package index:<br />
<br />
{{Cmd|apk update}}<br />
<br />
Upgrade chrony using the @edge tag<br />
<br />
{{Cmd|apk add chrony chrony@edge}}<br />
<br />
Upgrade chrony-doc using the @edge tag<br />
<br />
{{Cmd|apk add chrony-doc chrony-doc@edge}}<br />
<br />
Confirm that the installed version is from the edge repository:<br />
<br />
{{Cmd|cat /etc/apk/world | grep chrony}}<br />
<br />
<pre><br />
chrony@edge<br />
chrony-doc@edge<br />
</pre><br />
<br />
Restart chronyd to use the newly upgraded version:<br />
<br />
{{Cmd|/etc/init.d/chronyd restart}}<br />
<br />
= Installation =<br />
Install packages:<br />
{{Cmd|apk add samba-dc krb5 }}<br />
<br />
= Edit hosts file =<br />
You need to modify your {{Path|/etc/hosts}} file to look similar to this.<br />
<br />
127.0.0.1 localhost.localdomain localhost<br />
10.1.1.10 hostname.example.com hostname<br />
<br />
= Create smb.conf =<br />
Alpine doesn't provide an example configuration file in the package so you'll need to create one at {{Path|/etc/samba/smb.conf}}. <br />
<br />
[global]<br />
server role = domain controller<br />
workgroup = EXAMPLE<br />
realm = example.com<br />
netbios name = HOSTNAME<br />
passdb backend = samba4<br />
idmap_ldb:use rfc2307 = yes<br />
<br />
[netlogon]<br />
path = /var/lib/samba/sysvol/example.com/scripts<br />
read only = No<br />
<br />
[sysvol]<br />
path = /var/lib/samba/sysvol<br />
read only = No<br />
<br />
= Provision your Samba domain =<br />
Answer the questions with your domain information:<br />
{{Cmd|samba-tool domain provision --use-rfc2307 --interactive}}<br />
Use the SAMBA_INTERNAL DNS option.<br />
When asked for a forwarder IP, choose your internet DNS server. You can use your ISP or other public services (like Google) here.<br />
<br />
= Configure resolv.conf =<br />
Modify your {{Path|/etc/resolv.conf}} to include your new domain as a search domain and point to itself as the first nameserver.<br />
<br />
search example.com<br />
nameserver 10.1.1.10<br />
<br />
= Configure Kerberos =<br />
You need to replace krb5.conf with a link to the one generated by samba.<br />
{{Cmd|ln -sf /var/lib/samba/private/krb5.conf /etc/krb5.conf}}<br />
<br />
= Install new init script =<br />
As of 3/31/2016 and Alpine 3.3.3, the included samba init script doesn't support starting it as a domain controller. Modify your {{Path|/etc/init.d/samba}} script like the one below.<br />
<br />
#!/sbin/openrc-run<br />
<br />
extra_started_commands="reload"<br />
<br />
DAEMON=${SVCNAME#samba.}<br />
SERVER_ROLE=`samba-tool testparm --parameter-name="server role" 2>/dev/null | tail -1`<br />
if [ "$SERVER_ROLE" = "active directory domain controller" ]; then<br />
daemon_list="samba"<br />
elif [ "$DAEMON" != "samba" ]; then<br />
daemon_list=$DAEMON<br />
fi<br />
<br />
depend() {<br />
need net<br />
after firewall<br />
}<br />
<br />
<br />
start_samba() {<br />
mkdir -p /var/run/samba<br />
start-stop-daemon --start --quiet --exec /usr/sbin/samba --<br />
}<br />
<br />
stop_samba() {<br />
start-stop-daemon --stop --quiet --pidfile /var/run/samba/samba.pid<br />
}<br />
<br />
<br />
start_smbd() {<br />
start-stop-daemon --start --quiet --exec /usr/sbin/smbd -- \<br />
${smbd_options:-"-D"}<br />
}<br />
<br />
stop_smbd() {<br />
start-stop-daemon --stop --quiet --pidfile /var/run/samba/smbd.pid<br />
}<br />
<br />
start_nmbd() {<br />
start-stop-daemon --start --quiet --exec /usr/sbin/nmbd -- \<br />
${nmbd_options:-"-D"}<br />
}<br />
<br />
stop_nmbd() {<br />
start-stop-daemon --stop --quiet --pidfile /var/run/samba/nmbd.pid<br />
}<br />
<br />
start_winbindd() {<br />
start-stop-daemon --start --quiet --exec /usr/sbin/winbindd -- \<br />
$winbindd_options<br />
}<br />
<br />
stop_winbindd() {<br />
start-stop-daemon --stop --quiet --pidfile /var/run/samba/winbindd.pid<br />
}<br />
<br />
start() {<br />
for i in $daemon_list; do<br />
ebegin "Starting $i"<br />
start_$i<br />
eend $?<br />
done<br />
}<br />
<br />
stop() {<br />
for i in $daemon_list; do<br />
ebegin "Stopping $i"<br />
stop_$i<br />
eend $?<br />
done<br />
}<br />
<br />
reload() {<br />
for i in $daemon_list; do<br />
ebegin "Reloading $i"<br />
killall -HUP $i<br />
eend $?<br />
done<br />
}<br />
<br />
= Configure the Samba service =<br />
Run this command to start the service on boot.<br />
{{Cmd|rc-update add samba}}<br />
<br />
Run this command to start the service right now.<br />
{{Cmd|rc-service samba start}}<br />
<br />
[[Category:Printers]]<br />
[[Category:Authentication]]</div>
Zoot
https://wiki.alpinelinux.org/w/index.php?title=Setting_up_a_samba-ad-dc&diff=14144
Setting up a samba-ad-dc
2017-11-21T11:49:17Z
<p>Zoot: /* MS-SNTP signing support */ - clarify how to install the latest chrony version from the edge package repository</p>
<hr />
<div>= Notes =<br />
<br />
==== Active Directory Naming ====<br />
<br />
In all examples below, replace EXAMPLE with your NetBIOS domain name in caps, example.com with your DNS domain name, HOSTNAME with your system's host name in caps, and hostname with your system's host name.<br />
<br />
Refer to the [https://wiki.samba.org/index.php/Active_Directory_Naming_FAQ Active Directory naming FAQ] before choosing your domain name. <br />
<br />
==== MS-SNTP signing support ====<br />
<br />
AD Domain time sync requires MS-SNTP signing support, so be sure to check whether the NTP server you choose to deploy, does support it.<br />
<br />
<span style="color:red">Some of the NTP server versions available in the Alpine repositories (chrony, openntpd, busybox) do not currently support it. This will cause time sync issues for the domain, so be forewarned.</span><br />
<br />
NTP implementations which do support MS-SNTP signing:<br />
<br />
* chrony (version >= 3.2) [https://pkgs.alpinelinux.org/packages?name=chrony&branch=edge&repo=&arch=&maintainer= Alpine package in edge] [https://git.tuxfamily.org/chrony/chrony.git/tag/?h=3.2 Source download v3.2] [https://git.tuxfamily.org/chrony/chrony.git/commit/?h=3.2&id=577aed484207addd054441ee8be7e6e30ce36cb2 - Source code commit]<br />
* The ntp.org "ntpd" server [http://ntp.org/downloads.html - Download ntpd]<br />
* Windows<br />
<br />
'''Install Chrony version 3.2 on Alpine 3.6.2:'''<br />
<br />
Uncomment and pin the edge/main repository in /etc/apk/repositories<br />
<br />
Note that the below URLs are invalid and used for illustrative purposes only. Replace with the valid repository URLs used by your installation.<br />
<br />
See [https://wiki.alpinelinux.org/wiki/Alpine_Linux_package_management#Repository_pinning Package Repository Pinning] for further details.<br />
<br />
<pre><br />
http://mirror/alpine/v3.6/main<br />
@edge http://mirror/alpine/edge/main<br />
</pre><br />
<br />
Update the package index:<br />
<br />
{{Cmd|apk update}}<br />
<br />
Upgrade chrony using the @edge tag<br />
<br />
{{Cmd|apk add chrony chrony@edge}}<br />
<br />
Upgrade chrony-doc using the @edge tag<br />
<br />
{{Cmd|apk add chrony-doc chrony-doc@edge}}<br />
<br />
Confirm that the installed version is from the edge repository:<br />
<br />
{{Cmd|cat /etc/apk/world | grep chrony}}<br />
<br />
<pre><br />
chrony@edge<br />
chrony-doc@edge<br />
</pre><br />
<br />
= Installation =<br />
Install packages:<br />
{{Cmd|apk add samba-dc krb5 }}<br />
<br />
= Edit hosts file =<br />
You need to modify your {{Path|/etc/hosts}} file to look similar to this.<br />
<br />
127.0.0.1 localhost.localdomain localhost<br />
10.1.1.10 hostname.example.com hostname<br />
<br />
= Create smb.conf =<br />
Alpine doesn't provide an example configuration file in the package so you'll need to create one at {{Path|/etc/samba/smb.conf}}. <br />
<br />
[global]<br />
server role = domain controller<br />
workgroup = EXAMPLE<br />
realm = example.com<br />
netbios name = HOSTNAME<br />
passdb backend = samba4<br />
idmap_ldb:use rfc2307 = yes<br />
<br />
[netlogon]<br />
path = /var/lib/samba/sysvol/example.com/scripts<br />
read only = No<br />
<br />
[sysvol]<br />
path = /var/lib/samba/sysvol<br />
read only = No<br />
<br />
= Provision your Samba domain =<br />
Answer the questions with your domain information:<br />
{{Cmd|samba-tool domain provision --use-rfc2307 --interactive}}<br />
Use the SAMBA_INTERNAL DNS option.<br />
When asked for a forwarder IP, choose your internet DNS server. You can use your ISP or other public services (like Google) here.<br />
<br />
= Configure resolv.conf =<br />
Modify your {{Path|/etc/resolv.conf}} to include your new domain as a search domain and point to itself as the first nameserver.<br />
<br />
search example.com<br />
nameserver 10.1.1.10<br />
<br />
= Configure Kerberos =<br />
You need to replace krb5.conf with a link to the one generated by samba.<br />
{{Cmd|ln -sf /var/lib/samba/private/krb5.conf /etc/krb5.conf}}<br />
<br />
= Install new init script =<br />
As of 3/31/2016 and Alpine 3.3.3, the included samba init script doesn't support starting it as a domain controller. Modify your {{Path|/etc/init.d/samba}} script like the one below.<br />
<br />
#!/sbin/openrc-run<br />
<br />
extra_started_commands="reload"<br />
<br />
DAEMON=${SVCNAME#samba.}<br />
SERVER_ROLE=`samba-tool testparm --parameter-name="server role" 2>/dev/null | tail -1`<br />
if [ "$SERVER_ROLE" = "active directory domain controller" ]; then<br />
daemon_list="samba"<br />
elif [ "$DAEMON" != "samba" ]; then<br />
daemon_list=$DAEMON<br />
fi<br />
<br />
depend() {<br />
need net<br />
after firewall<br />
}<br />
<br />
<br />
start_samba() {<br />
mkdir -p /var/run/samba<br />
start-stop-daemon --start --quiet --exec /usr/sbin/samba --<br />
}<br />
<br />
stop_samba() {<br />
start-stop-daemon --stop --quiet --pidfile /var/run/samba/samba.pid<br />
}<br />
<br />
<br />
start_smbd() {<br />
start-stop-daemon --start --quiet --exec /usr/sbin/smbd -- \<br />
${smbd_options:-"-D"}<br />
}<br />
<br />
stop_smbd() {<br />
start-stop-daemon --stop --quiet --pidfile /var/run/samba/smbd.pid<br />
}<br />
<br />
start_nmbd() {<br />
start-stop-daemon --start --quiet --exec /usr/sbin/nmbd -- \<br />
${nmbd_options:-"-D"}<br />
}<br />
<br />
stop_nmbd() {<br />
start-stop-daemon --stop --quiet --pidfile /var/run/samba/nmbd.pid<br />
}<br />
<br />
start_winbindd() {<br />
start-stop-daemon --start --quiet --exec /usr/sbin/winbindd -- \<br />
$winbindd_options<br />
}<br />
<br />
stop_winbindd() {<br />
start-stop-daemon --stop --quiet --pidfile /var/run/samba/winbindd.pid<br />
}<br />
<br />
start() {<br />
for i in $daemon_list; do<br />
ebegin "Starting $i"<br />
start_$i<br />
eend $?<br />
done<br />
}<br />
<br />
stop() {<br />
for i in $daemon_list; do<br />
ebegin "Stopping $i"<br />
stop_$i<br />
eend $?<br />
done<br />
}<br />
<br />
reload() {<br />
for i in $daemon_list; do<br />
ebegin "Reloading $i"<br />
killall -HUP $i<br />
eend $?<br />
done<br />
}<br />
<br />
= Configure the Samba service =<br />
Run this command to start the service on boot.<br />
{{Cmd|rc-update add samba}}<br />
<br />
Run this command to start the service right now.<br />
{{Cmd|rc-service samba start}}<br />
<br />
[[Category:Printers]]<br />
[[Category:Authentication]]</div>
Zoot
https://wiki.alpinelinux.org/w/index.php?title=Wi-Fi&diff=14143
Wi-Fi
2017-11-21T10:05:32Z
<p>Zoot: Separate manual from automatic configuration and add more detail for less experienced users.</p>
<hr />
<div>This document describes how to set up a wireless network connection with WPA encryption.<br />
<br />
== Install necessary drivers and software ==<br />
<br />
First make sure your wireless drivers are loaded properly. (if you are using a '''Broadcom chipset''', see the [[#Broadcom_Wi-Fi_Chipset_Users|section at the bottom of this post]].)<br />
<br />
Install {{Pkg|wireless-tools}} and {{Pkg|wpa_supplicant}}.<br />
{{Cmd|apk add wireless-tools wpa_supplicant}}<br />
<br />
== Manual Configuration ==<br />
<br />
Bring the link up so we can look for wireless networks. (An error here means you probably need extra drivers/firmware.)<br />
{{Cmd|ip link set wlan0 up}}<br />
<br />
Find a network to connect to. Look for the ESSID. In this example we will use the ESSID "MyNet".<br />
{{Cmd|iwlist wlan0 scanning}}<br />
<br />
Configure the wlan0 interface to associate with the MyNet ESSID:<br />
{{Cmd|iwconfig wlan0 essid MyNet}}<br />
<br />
Print its configuration, to check:<br />
{{Cmd|iwconfig wlan0}}<br />
<br />
Create a wpa_supplicant configuration stanza for wpa_supplicant by executing the following:<br />
{{Cmd|wpa_passphrase MyNet > wpa.conf}} <br />
<br />
wpa_passphrase expects the password to be passed via stdin. <br />
<br />
So, type the password and press ENTER.<br />
<br />
The above commands creates the file {{Path|wpa.conf}} which includes the pre-shared key. <br />
<br />
From one terminal/console, start wpa_supplicant with the generated config:<br />
{{Cmd|wpa_supplicant -Dwext -iwlan0 -c ./wpa.conf}}<br />
<br />
From another terminal/console, start dhcpcd:<br />
{{Cmd|udhcpc -i wlan0}}<br />
<br />
The wlan0 interface should be configured with an IP address at this point:<br />
{{Cmd|ifconfig wlan0}}<br />
<br />
== Automatic Configuration on System Boot ==<br />
<br />
Add an interface stanza for wlan0 to the file {{Path|/etc/network/interfaces}}<br />
<br />
<pre><br />
auto wlan0<br />
iface wlan0 inet dhcp<br />
</pre><br />
<br />
Create {{Path|/etc/wpa_supplicant}} if it doesn't already exist, set sane permissions and append the configuration {{Path|wpa.conf}} to {{Path|wpa_supplicant.conf}}.<br />
<br />
<pre><br />
mkdir -p /etc/wpa_supplicant<br />
chmod 750 /etc/wpa_supplicant<br />
cat wpa.conf >> /etc/wpa_supplicant/wpa_supplicant.conf<br />
</pre><br />
<br />
Test the automatic interface configuration:<br />
<br />
Bring the interface down:<br />
<br />
{{Cmd|ifconfig wlan0 down}}<br />
<br />
Manually start wpa_supplicant<br />
<br />
{{Cmd|/etc/init.d/wpa_supplicant start}}<br />
<br />
The wlan0 interface should be associated with the MyNet SSID:<br />
<br />
{{Cmd|iwconfig wlan0}}<br />
<br />
The wlan0 interface should have been assigned an IP address via DHCP:<br />
<br />
{{Cmd|ifconfig wlan0}}<br />
<br />
Configure wpa_supplicant to start automatically on boot:<br />
<br />
{{Cmd|rc-update add wpa_supplicant boot}}<br />
<br />
Reboot:<br />
<br />
{{Cmd|reboot}}<br />
<br />
Log in and check that the interface is associated with the access point:<br />
<br />
{{Cmd|iwconfig wlan0}}<br />
<br />
Check that the interface was assigned an IP address via DHCP:<br />
<br />
{{Cmd|ifconfig wlan0 {{!}} grep addr}}<br />
<br />
== Broadcom Wi-Fi Chipset Users ==<br />
<br />
The Broadcom chipset is quite popular among older computers. You will need to compile the firmware manually for this chipset as it is not included. <br />
<br />
You can check if you have a Broadcom chipset by using dmesg:<br />
<br />
{{Cmd|dmesg {{!}} grep Broadcom}}<br />
<br />
First install the SDK an Git:<br />
{{Cmd|apk add alpine-sdk git}}<br />
<br />
Then git clone aports from git.alpinelinux.org.<br />
<br />
<br />
{{Cmd|git clone git://git.alpinelinux.org/aports}}<br />
<br />
Change your directory to '''aports/non-free/b43-firmware''', then build it.<br />
<br />
''You can't be root and must be a user of the group abuild (use groupadd)''<br />
<br />
{{Cmd|abuild -r}}<br />
<br />
Install the generated packge file (it will be in ~/packages/) - make sure to pass '''--allow-untrusted'''<br />
<br />
{{Cmd|apk add --allow-untrusted ~/packages/...pkg}}<br />
<br />
Now we need fwcutter, which is executed from the firmware package:<br />
<br />
{{Cmd|apk add b43-fwcutter b43-firmware}}<br />
<br />
Now you need to use modprobe so the device will show up:<br />
<br />
{{Cmd|modprobe b43}}<br />
<br />
To automate this on startup add it to /etc/modules:<br />
<br />
{{Cmd|echo b43 >> /etc/modules}}<br />
<br />
Now continue with the normal instructions. <br />
<br />
[[Category:Networking]]</div>
Zoot
https://wiki.alpinelinux.org/w/index.php?title=Setting_up_a_samba-ad-dc&diff=14104
Setting up a samba-ad-dc
2017-10-25T13:34:28Z
<p>Zoot: Added link to chrony version 3.2 package for Alpine edge</p>
<hr />
<div>= Notes =<br />
<br />
==== Active Directory Naming ====<br />
<br />
In all examples below, replace EXAMPLE with your NetBIOS domain name in caps, example.com with your DNS domain name, HOSTNAME with your system's host name in caps, and hostname with your system's host name.<br />
<br />
Refer to the [https://wiki.samba.org/index.php/Active_Directory_Naming_FAQ Active Directory naming FAQ] before choosing your domain name. <br />
<br />
==== MS-SNTP signing support ====<br />
<br />
AD Domain time sync requires MS-SNTP signing support, so be sure to check whether the NTP server you choose to deploy, does support it.<br />
<br />
<span style="color:red">Some of the NTP server versions available in the Alpine repositories (chrony, openntpd, busybox) do not currently support it. This will cause time sync issues for the domain, so be forewarned.</span><br />
<br />
NTP implementations which do support MS-SNTP signing:<br />
<br />
* chrony (version >= 3.2) [https://pkgs.alpinelinux.org/packages?name=chrony&branch=edge&repo=&arch=&maintainer= Alpine package in edge] [https://git.tuxfamily.org/chrony/chrony.git/tag/?h=3.2 Source download v3.2] [https://git.tuxfamily.org/chrony/chrony.git/commit/?h=3.2&id=577aed484207addd054441ee8be7e6e30ce36cb2 - Source code commit]<br />
* The ntp.org "ntpd" server [http://ntp.org/downloads.html - Download ntpd]<br />
* Windows<br />
<br />
= Installation =<br />
Install packages:<br />
{{Cmd|apk add samba-dc krb5 }}<br />
<br />
= Edit hosts file =<br />
You need to modify your {{Path|/etc/hosts}} file to look similar to this.<br />
<br />
127.0.0.1 localhost.localdomain localhost<br />
10.1.1.10 hostname.example.com hostname<br />
<br />
= Create smb.conf =<br />
Alpine doesn't provide an example configuration file in the package so you'll need to create one at {{Path|/etc/samba/smb.conf}}. <br />
<br />
[global]<br />
server role = domain controller<br />
workgroup = EXAMPLE<br />
realm = example.com<br />
netbios name = HOSTNAME<br />
passdb backend = samba4<br />
idmap_ldb:use rfc2307 = yes<br />
<br />
[netlogon]<br />
path = /var/lib/samba/sysvol/example.com/scripts<br />
read only = No<br />
<br />
[sysvol]<br />
path = /var/lib/samba/sysvol<br />
read only = No<br />
<br />
= Provision your Samba domain =<br />
Answer the questions with your domain information:<br />
{{Cmd|samba-tool domain provision --use-rfc2307 --interactive}}<br />
Use the SAMBA_INTERNAL DNS option.<br />
When asked for a forwarder IP, choose your internet DNS server. You can use your ISP or other public services (like Google) here.<br />
<br />
= Configure resolv.conf =<br />
Modify your {{Path|/etc/resolv.conf}} to include your new domain as a search domain and point to itself as the first nameserver.<br />
<br />
search example.com<br />
nameserver 10.1.1.10<br />
<br />
= Configure Kerberos =<br />
You need to replace krb5.conf with a link to the one generated by samba.<br />
{{Cmd|ln -sf /var/lib/samba/private/krb5.conf /etc/krb5.conf}}<br />
<br />
= Install new init script =<br />
As of 3/31/2016 and Alpine 3.3.3, the included samba init script doesn't support starting it as a domain controller. Modify your {{Path|/etc/init.d/samba}} script like the one below.<br />
<br />
#!/sbin/openrc-run<br />
<br />
extra_started_commands="reload"<br />
<br />
DAEMON=${SVCNAME#samba.}<br />
SERVER_ROLE=`samba-tool testparm --parameter-name="server role" 2>/dev/null | tail -1`<br />
if [ "$SERVER_ROLE" = "active directory domain controller" ]; then<br />
daemon_list="samba"<br />
elif [ "$DAEMON" != "samba" ]; then<br />
daemon_list=$DAEMON<br />
fi<br />
<br />
depend() {<br />
need net<br />
after firewall<br />
}<br />
<br />
<br />
start_samba() {<br />
mkdir -p /var/run/samba<br />
start-stop-daemon --start --quiet --exec /usr/sbin/samba --<br />
}<br />
<br />
stop_samba() {<br />
start-stop-daemon --stop --quiet --pidfile /var/run/samba/samba.pid<br />
}<br />
<br />
<br />
start_smbd() {<br />
start-stop-daemon --start --quiet --exec /usr/sbin/smbd -- \<br />
${smbd_options:-"-D"}<br />
}<br />
<br />
stop_smbd() {<br />
start-stop-daemon --stop --quiet --pidfile /var/run/samba/smbd.pid<br />
}<br />
<br />
start_nmbd() {<br />
start-stop-daemon --start --quiet --exec /usr/sbin/nmbd -- \<br />
${nmbd_options:-"-D"}<br />
}<br />
<br />
stop_nmbd() {<br />
start-stop-daemon --stop --quiet --pidfile /var/run/samba/nmbd.pid<br />
}<br />
<br />
start_winbindd() {<br />
start-stop-daemon --start --quiet --exec /usr/sbin/winbindd -- \<br />
$winbindd_options<br />
}<br />
<br />
stop_winbindd() {<br />
start-stop-daemon --stop --quiet --pidfile /var/run/samba/winbindd.pid<br />
}<br />
<br />
start() {<br />
for i in $daemon_list; do<br />
ebegin "Starting $i"<br />
start_$i<br />
eend $?<br />
done<br />
}<br />
<br />
stop() {<br />
for i in $daemon_list; do<br />
ebegin "Stopping $i"<br />
stop_$i<br />
eend $?<br />
done<br />
}<br />
<br />
reload() {<br />
for i in $daemon_list; do<br />
ebegin "Reloading $i"<br />
killall -HUP $i<br />
eend $?<br />
done<br />
}<br />
<br />
= Configure the Samba service =<br />
Run this command to start the service on boot.<br />
{{Cmd|rc-update add samba}}<br />
<br />
Run this command to start the service right now.<br />
{{Cmd|rc-service samba start}}<br />
<br />
[[Category:Printers]]<br />
[[Category:Authentication]]</div>
Zoot
https://wiki.alpinelinux.org/w/index.php?title=Setting_up_a_samba-ad-dc&diff=14103
Setting up a samba-ad-dc
2017-10-25T13:18:29Z
<p>Zoot: Mention the problem which a lack of MS-SNTP support in the NTP server will cause</p>
<hr />
<div>= Notes =<br />
<br />
==== Active Directory Naming ====<br />
<br />
In all examples below, replace EXAMPLE with your NetBIOS domain name in caps, example.com with your DNS domain name, HOSTNAME with your system's host name in caps, and hostname with your system's host name.<br />
<br />
Refer to the [https://wiki.samba.org/index.php/Active_Directory_Naming_FAQ Active Directory naming FAQ] before choosing your domain name. <br />
<br />
==== MS-SNTP signing support ====<br />
<br />
AD Domain time sync requires MS-SNTP signing support, so be sure to check whether the NTP server you choose to deploy, does support it.<br />
<br />
<span style="color:red">Some of the NTP server versions available in the Alpine repositories (chrony, openntpd, busybox) do not currently support it. This will cause time sync issues for the domain, so be forewarned.</span><br />
<br />
NTP implementations which do support MS-SNTP signing:<br />
<br />
* chrony (version >= 3.2) [https://git.tuxfamily.org/chrony/chrony.git/tag/?h=3.2 Download v3.2] [https://git.tuxfamily.org/chrony/chrony.git/commit/?h=3.2&id=577aed484207addd054441ee8be7e6e30ce36cb2 - Review the applicable v3.2 commit]<br />
* The ntp.org "ntpd" server [http://ntp.org/downloads.html - Download ntpd]<br />
* Windows<br />
<br />
= Installation =<br />
Install packages:<br />
{{Cmd|apk add samba-dc krb5 }}<br />
<br />
= Edit hosts file =<br />
You need to modify your {{Path|/etc/hosts}} file to look similar to this.<br />
<br />
127.0.0.1 localhost.localdomain localhost<br />
10.1.1.10 hostname.example.com hostname<br />
<br />
= Create smb.conf =<br />
Alpine doesn't provide an example configuration file in the package so you'll need to create one at {{Path|/etc/samba/smb.conf}}. <br />
<br />
[global]<br />
server role = domain controller<br />
workgroup = EXAMPLE<br />
realm = example.com<br />
netbios name = HOSTNAME<br />
passdb backend = samba4<br />
idmap_ldb:use rfc2307 = yes<br />
<br />
[netlogon]<br />
path = /var/lib/samba/sysvol/example.com/scripts<br />
read only = No<br />
<br />
[sysvol]<br />
path = /var/lib/samba/sysvol<br />
read only = No<br />
<br />
= Provision your Samba domain =<br />
Answer the questions with your domain information:<br />
{{Cmd|samba-tool domain provision --use-rfc2307 --interactive}}<br />
Use the SAMBA_INTERNAL DNS option.<br />
When asked for a forwarder IP, choose your internet DNS server. You can use your ISP or other public services (like Google) here.<br />
<br />
= Configure resolv.conf =<br />
Modify your {{Path|/etc/resolv.conf}} to include your new domain as a search domain and point to itself as the first nameserver.<br />
<br />
search example.com<br />
nameserver 10.1.1.10<br />
<br />
= Configure Kerberos =<br />
You need to replace krb5.conf with a link to the one generated by samba.<br />
{{Cmd|ln -sf /var/lib/samba/private/krb5.conf /etc/krb5.conf}}<br />
<br />
= Install new init script =<br />
As of 3/31/2016 and Alpine 3.3.3, the included samba init script doesn't support starting it as a domain controller. Modify your {{Path|/etc/init.d/samba}} script like the one below.<br />
<br />
#!/sbin/openrc-run<br />
<br />
extra_started_commands="reload"<br />
<br />
DAEMON=${SVCNAME#samba.}<br />
SERVER_ROLE=`samba-tool testparm --parameter-name="server role" 2>/dev/null | tail -1`<br />
if [ "$SERVER_ROLE" = "active directory domain controller" ]; then<br />
daemon_list="samba"<br />
elif [ "$DAEMON" != "samba" ]; then<br />
daemon_list=$DAEMON<br />
fi<br />
<br />
depend() {<br />
need net<br />
after firewall<br />
}<br />
<br />
<br />
start_samba() {<br />
mkdir -p /var/run/samba<br />
start-stop-daemon --start --quiet --exec /usr/sbin/samba --<br />
}<br />
<br />
stop_samba() {<br />
start-stop-daemon --stop --quiet --pidfile /var/run/samba/samba.pid<br />
}<br />
<br />
<br />
start_smbd() {<br />
start-stop-daemon --start --quiet --exec /usr/sbin/smbd -- \<br />
${smbd_options:-"-D"}<br />
}<br />
<br />
stop_smbd() {<br />
start-stop-daemon --stop --quiet --pidfile /var/run/samba/smbd.pid<br />
}<br />
<br />
start_nmbd() {<br />
start-stop-daemon --start --quiet --exec /usr/sbin/nmbd -- \<br />
${nmbd_options:-"-D"}<br />
}<br />
<br />
stop_nmbd() {<br />
start-stop-daemon --stop --quiet --pidfile /var/run/samba/nmbd.pid<br />
}<br />
<br />
start_winbindd() {<br />
start-stop-daemon --start --quiet --exec /usr/sbin/winbindd -- \<br />
$winbindd_options<br />
}<br />
<br />
stop_winbindd() {<br />
start-stop-daemon --stop --quiet --pidfile /var/run/samba/winbindd.pid<br />
}<br />
<br />
start() {<br />
for i in $daemon_list; do<br />
ebegin "Starting $i"<br />
start_$i<br />
eend $?<br />
done<br />
}<br />
<br />
stop() {<br />
for i in $daemon_list; do<br />
ebegin "Stopping $i"<br />
stop_$i<br />
eend $?<br />
done<br />
}<br />
<br />
reload() {<br />
for i in $daemon_list; do<br />
ebegin "Reloading $i"<br />
killall -HUP $i<br />
eend $?<br />
done<br />
}<br />
<br />
= Configure the Samba service =<br />
Run this command to start the service on boot.<br />
{{Cmd|rc-update add samba}}<br />
<br />
Run this command to start the service right now.<br />
{{Cmd|rc-service samba start}}<br />
<br />
[[Category:Printers]]<br />
[[Category:Authentication]]</div>
Zoot
https://wiki.alpinelinux.org/w/index.php?title=Setting_up_a_samba-ad-dc&diff=14102
Setting up a samba-ad-dc
2017-10-25T13:13:58Z
<p>Zoot: Consolidated Notes & Caveats under Notes section and corrected information related to chrony supporting MS-SNTP</p>
<hr />
<div>= Notes =<br />
<br />
==== Active Directory Naming ====<br />
<br />
In all examples below, replace EXAMPLE with your NetBIOS domain name in caps, example.com with your DNS domain name, HOSTNAME with your system's host name in caps, and hostname with your system's host name.<br />
<br />
Refer to the [https://wiki.samba.org/index.php/Active_Directory_Naming_FAQ Active Directory naming FAQ] before choosing your domain name. <br />
<br />
==== MS-SNTP signing support ====<br />
<br />
AD Domain time sync requires MS-SNTP signing support, so be sure to check whether the NTP server you choose to deploy, does support it.<br />
<br />
<span style="color:red">Some of the NTP server versions available in the Alpine repositories (chrony, openntpd, busybox) do not currently support it.</span><br />
<br />
NTP implementations which do support MS-SNTP signing:<br />
<br />
* chrony (version >= 3.2) [https://git.tuxfamily.org/chrony/chrony.git/tag/?h=3.2 Download v3.2] [https://git.tuxfamily.org/chrony/chrony.git/commit/?h=3.2&id=577aed484207addd054441ee8be7e6e30ce36cb2 - Review the applicable v3.2 commit]<br />
* The ntp.org "ntpd" server [http://ntp.org/downloads.html - Download ntpd]<br />
* Windows<br />
<br />
= Installation =<br />
Install packages:<br />
{{Cmd|apk add samba-dc krb5 }}<br />
<br />
= Edit hosts file =<br />
You need to modify your {{Path|/etc/hosts}} file to look similar to this.<br />
<br />
127.0.0.1 localhost.localdomain localhost<br />
10.1.1.10 hostname.example.com hostname<br />
<br />
= Create smb.conf =<br />
Alpine doesn't provide an example configuration file in the package so you'll need to create one at {{Path|/etc/samba/smb.conf}}. <br />
<br />
[global]<br />
server role = domain controller<br />
workgroup = EXAMPLE<br />
realm = example.com<br />
netbios name = HOSTNAME<br />
passdb backend = samba4<br />
idmap_ldb:use rfc2307 = yes<br />
<br />
[netlogon]<br />
path = /var/lib/samba/sysvol/example.com/scripts<br />
read only = No<br />
<br />
[sysvol]<br />
path = /var/lib/samba/sysvol<br />
read only = No<br />
<br />
= Provision your Samba domain =<br />
Answer the questions with your domain information:<br />
{{Cmd|samba-tool domain provision --use-rfc2307 --interactive}}<br />
Use the SAMBA_INTERNAL DNS option.<br />
When asked for a forwarder IP, choose your internet DNS server. You can use your ISP or other public services (like Google) here.<br />
<br />
= Configure resolv.conf =<br />
Modify your {{Path|/etc/resolv.conf}} to include your new domain as a search domain and point to itself as the first nameserver.<br />
<br />
search example.com<br />
nameserver 10.1.1.10<br />
<br />
= Configure Kerberos =<br />
You need to replace krb5.conf with a link to the one generated by samba.<br />
{{Cmd|ln -sf /var/lib/samba/private/krb5.conf /etc/krb5.conf}}<br />
<br />
= Install new init script =<br />
As of 3/31/2016 and Alpine 3.3.3, the included samba init script doesn't support starting it as a domain controller. Modify your {{Path|/etc/init.d/samba}} script like the one below.<br />
<br />
#!/sbin/openrc-run<br />
<br />
extra_started_commands="reload"<br />
<br />
DAEMON=${SVCNAME#samba.}<br />
SERVER_ROLE=`samba-tool testparm --parameter-name="server role" 2>/dev/null | tail -1`<br />
if [ "$SERVER_ROLE" = "active directory domain controller" ]; then<br />
daemon_list="samba"<br />
elif [ "$DAEMON" != "samba" ]; then<br />
daemon_list=$DAEMON<br />
fi<br />
<br />
depend() {<br />
need net<br />
after firewall<br />
}<br />
<br />
<br />
start_samba() {<br />
mkdir -p /var/run/samba<br />
start-stop-daemon --start --quiet --exec /usr/sbin/samba --<br />
}<br />
<br />
stop_samba() {<br />
start-stop-daemon --stop --quiet --pidfile /var/run/samba/samba.pid<br />
}<br />
<br />
<br />
start_smbd() {<br />
start-stop-daemon --start --quiet --exec /usr/sbin/smbd -- \<br />
${smbd_options:-"-D"}<br />
}<br />
<br />
stop_smbd() {<br />
start-stop-daemon --stop --quiet --pidfile /var/run/samba/smbd.pid<br />
}<br />
<br />
start_nmbd() {<br />
start-stop-daemon --start --quiet --exec /usr/sbin/nmbd -- \<br />
${nmbd_options:-"-D"}<br />
}<br />
<br />
stop_nmbd() {<br />
start-stop-daemon --stop --quiet --pidfile /var/run/samba/nmbd.pid<br />
}<br />
<br />
start_winbindd() {<br />
start-stop-daemon --start --quiet --exec /usr/sbin/winbindd -- \<br />
$winbindd_options<br />
}<br />
<br />
stop_winbindd() {<br />
start-stop-daemon --stop --quiet --pidfile /var/run/samba/winbindd.pid<br />
}<br />
<br />
start() {<br />
for i in $daemon_list; do<br />
ebegin "Starting $i"<br />
start_$i<br />
eend $?<br />
done<br />
}<br />
<br />
stop() {<br />
for i in $daemon_list; do<br />
ebegin "Stopping $i"<br />
stop_$i<br />
eend $?<br />
done<br />
}<br />
<br />
reload() {<br />
for i in $daemon_list; do<br />
ebegin "Reloading $i"<br />
killall -HUP $i<br />
eend $?<br />
done<br />
}<br />
<br />
= Configure the Samba service =<br />
Run this command to start the service on boot.<br />
{{Cmd|rc-update add samba}}<br />
<br />
Run this command to start the service right now.<br />
{{Cmd|rc-service samba start}}<br />
<br />
[[Category:Printers]]<br />
[[Category:Authentication]]</div>
Zoot