# Startup Script for Wowza Server

**URL:** <https://community.wowza.com/t/startup-script-for-wowza-server/36802>\
**Category:** Wowza Streaming Engine\
**Created:** [July 8, 2011, 2:57pm UTC](https://community.wowza.com/t/startup-script-for-wowza-server/36802 "2011-07-08T14:57:06Z")\
**Posts on this page:** 8\
**Page:** 1

<div class="post-metadata">

**Author:** ![Karuna\_Pai](https://avatars.discourse-cdn.com/v4/letter/k/8dc957/32.png) [@Karuna\_Pai](https://community.wowza.com/u/Karuna_Pai)\
**Post date:** [July 8, 2011, 2:57pm UTC](https://community.wowza.com/t/startup-script-for-wowza-server/36802/1 "2011-07-08T14:57:06Z")

</div>

Hi,

I have a Wowza EC2 instance created from pre-built EC2 AMI.

I have written a script ‘mount.sh’ which mounts certain s3 buckets.

I want to run this script on machine startup before wowza server starts.

There is a ‘StartupStreams.xml’ in /home/wowza/conf directory which can be used to start certain streams. On similar lines, is there a ‘startup.xml’ file on wowza where i can register the script to run before server starts?

Any pointers will be helpful.

Thanks,

Karuna.

---

<div class="post-metadata">

**Author:** ![Ian\_Beyer](https://avatars.discourse-cdn.com/v4/letter/i/e99b99/32.png) [@Ian\_Beyer](https://community.wowza.com/u/Ian_Beyer)\
**Post date:** [July 8, 2011, 10:12am UTC](https://community.wowza.com/t/startup-script-for-wowza-server/36802/2 "2011-07-08T10:12:21Z")

</div>

Karuna,

You may want to check out my blog post on startup packages:

[http://blog.ianbeyer.com/wowza-startup-packages/](http://blog.ianbeyer.com/wowza-startup-packages/)

---

<div class="post-metadata">

**Author:** ![Richard\_Lanham](https://avatars.discourse-cdn.com/v4/letter/r/c68b51/32.png) [@Richard\_Lanham](https://community.wowza.com/u/Richard_Lanham)\
**Post date:** [July 11, 2011, 1:34pm UTC](https://community.wowza.com/t/startup-script-for-wowza-server/36802/3 "2011-07-11T13:34:36Z")

</div>

Do it like this:

```auto
<RunScript>
     <Script>tuning/tune.sh</Script>
</RunScript>
<RunScript>
     <Script>mount.sh</Script>
</RunScript>

```

To debug the script if necessary, start without the above and run the script yourself on new new instance.

Richard

---

<div class="post-metadata">

**Author:** ![Karuna\_Pai](https://avatars.discourse-cdn.com/v4/letter/k/8dc957/32.png) [@Karuna\_Pai](https://community.wowza.com/u/Karuna_Pai)\
**Post date:** [July 11, 2011, 6:47pm UTC](https://community.wowza.com/t/startup-script-for-wowza-server/36802/4 "2011-07-11T18:47:29Z")

</div>

Hi,

I tried to edit the ‘startup.xml’ file as mentioned in the blog:

[http://blog.ianbeyer.com/wowza-startup-packages/](http://blog.ianbeyer.com/wowza-startup-packages/)

My “startup.xml” file path was: /opt/working/default\_2.2

The file contents are:

```auto
<Startup>
	<Commands>
		<Install>
			<Folder>wowza</Folder>
		</Install>
		<RunScript>
			<Script>tuning/tune.sh</Script>
			<Script>mount.sh</Script>
		</RunScript>
	</Commands>
</Startup>

```

The “mount.sh” file is at the same location as startup.xml.

Its contents are:

```auto
#!/bin/sh
logmsg="/usr/bin/logger -t WowzaUserScript "
$logmsg "Wowza Mount Script"
#create Wowza Content and Logs folder in mnt
if ! [-d /mnt/WowzaMediaServer]; then 
	$logmsg "Creating /mnt/WowzaMediaServer dir"
	mkdir /mnt/WowzaMediaServer
	mkdir /mnt/WowzaMediaServer/content
	mkdir /mnt/WowzaMediaServer/logs
	$logmsg "Created Wowza content and logs directories"
fi
#create required keys
export AWSACCESSKEYID=XXX
export AWSSECRETACCESSKEY=YYY
#create config directory and mount it
if ! [-d /mnt/config]; then 
	$logmsg "Creating /mnt/config dir"
	mkdir /mnt/config;
fi
s3fs ABC -o default_acl=public-read /mnt/config
$logmsg "Mounted /mnt/config dir"
#copy the loadbalancertargets.txt file
cp -f /mnt/config/loadbalancertargets.txt /home/wowza/conf
$logmsg "Copied /mnt/config/loadbalancertargets.txt to /home/wowza/conf"
#umonunt config and delete the folder
fusermount -uz /mnt/config
$logmsg "Unmount /mnt/config"
#mount today's bucket
if ! [-d /mnt/`date +%Y%m%d`]; then 
	mkdir /mnt/`date +%Y%m%d`; 
	$logmsg "Created today's directory: /mnt/`date +%Y%m%d`"
fi
s3fs ABC-53e39950-0b63-48dc-8e5d-098c62b97440-`date +%Y%m%d` -o default_acl=public-read /mnt/`date +%Y%m%d`
$logmsg "Mounted today's directory: /mnt/`date +%Y%m%d` with bucket: ABC-53e39950-0b63-48dc-8e5d-098c62b97440-`date +%Y%m%d`"
#mount tomorrow's bucket
if ! [-d /mnt/`date --date="tomorrow" +%Y%m%d`]; then 
	mkdir /mnt/`date --date="tomorrow" +%Y%m%d`; 
	$logmsg "Created tomorrow's directory: /mnt/`date --date=\"tomorrow\" +%Y%m%d`"
fi
s3fs ABC-53e39950-0b63-48dc-8e5d-098c62b97440-`date --date="tomorrow" +%Y%m%d` -o default_acl=public-read /mnt/`date --date="tomorrow" +%Y%m%d`
$logmsg "Mounted tomorrow's directory: /mnt/`date --date=\"tomorrow\" +%Y%m%d` with bucket: ABC-53e39950-0b63-48dc-8e5d-098c62b97440-`date --date=\"tomorrow\" +%Y%m%d`"
$logmsg "Wowza Mount Script Completed"

```

I then created a AMI of this Wowza server EC2 instance, say ami-123abc

When I created a new instance from the AMI “ami-123abc”, the above mount.sh script did not run when the server started.

Any pointers will be helpful.

Thanks,

Karuna.

---

<div class="post-metadata">

**Author:** ![Karuna\_Pai](https://avatars.discourse-cdn.com/v4/letter/k/8dc957/32.png) [@Karuna\_Pai](https://community.wowza.com/u/Karuna_Pai)\
**Post date:** [July 12, 2011, 11:43am UTC](https://community.wowza.com/t/startup-script-for-wowza-server/36802/5 "2011-07-12T11:43:01Z")

</div>

Hi Richard,

I did the changes in startup.xml like you suggested.

The script still did not run on the new instance created from the AMI. ☹

When I manually ran the script, it executed successfully.

Any pointers will be helpful.

Thanks,

Karuna.

---

<div class="post-metadata">

**Author:** ![Karuna\_Pai](https://avatars.discourse-cdn.com/v4/letter/k/8dc957/32.png) [@Karuna\_Pai](https://community.wowza.com/u/Karuna_Pai)\
**Post date:** [July 13, 2011, 11:09am UTC](https://community.wowza.com/t/startup-script-for-wowza-server/36802/6 "2011-07-13T11:09:42Z")

</div>

Hi,

I finally got it working by putting the script in “init.d” folder and scheduling it to run before the wowza media server starts 🙂

Thanks,

Karuna.

---

<div class="post-metadata">

**Author:** ![Sam\_Weitzman](https://avatars.discourse-cdn.com/v4/letter/s/96bed5/32.png) [@Sam\_Weitzman](https://community.wowza.com/u/Sam_Weitzman)\
**Post date:** [January 26, 2021, 1:36pm UTC](https://community.wowza.com/t/startup-script-for-wowza-server/36802/7 "2021-01-26T13:36:21Z")

</div>

How you acheive it?  
I am using aws ec2 instance and i need to schedule script to running in background before wowza media engine starting, any suggestions?

---

<div class="post-metadata">

**Author:** ![Connessione](https://avatars.discourse-cdn.com/v4/letter/c/43a26b/32.png) [@Connessione](https://community.wowza.com/u/Connessione)\
**Post date:** [April 26, 2021, 7:09pm UTC](https://community.wowza.com/t/startup-script-for-wowza-server/36802/8 "2021-04-26T19:09:52Z")

</div>

If you are running in ec2 consider taking advantage of user data scripts section. [https://aws.amazon.com/premiumsupport/knowledge-center/execute-user-data-ec2/](https://aws.amazon.com/premiumsupport/knowledge-center/execute-user-data-ec2/)
